API Documentation for BayRewards (1.0.0)

Download OpenAPI specification:Download

This documentation covers BayRewards APIs. Use the Authentication endpoints to obtain an access token and include the bearer token in the Authorization header for protected endpoints.

Authentication

Use this endpoint for authentication. Securely include an access token in all API calls.

Generate Access Token

Obtain an access token using client credentials.

Request Body schema: application/x-www-form-urlencoded
client_id
required
string

INSERT_YOUR_CLIENT_ID_HERE

client_secret
required
string

INSERT_YOUR_CLIENT_SECRET_HERE.

grant_type
required
string

client_credentials

scope
required
string

Provide necessary scope Eg. read_customer write_customer

Responses

Response samples

Content type
application/json
{
  • "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  • "token_type": "bearer",
  • "expires_in": 3600,
  • "scope": "read_customer write_customer"
}

Contacts

Use these API endpoints to create, update, or delete contacts in your BayRewards account.

Create and Update an Email contact in BayRewards

You can include contact details along with the email when creating a new contact. If the email already exists, the contact details will be updated accordingly. Authorization: This endpoint requires a bearer token with the write_customer scope.

Authorizations:
bearerAuth
Request Body schema: application/json
required
string or integer

The customer ID that you maintain in your platform. This value can be passed either as a string or an integer.

email
required
string

This is the email address of the customer.

referred_id
string

This is the unique referral ID of the referrer (existing customer) who shared the referral link. The value is extracted from the resolved referral parameter after short-URL expansion. Pass this field only when a new customer is created via a referral; otherwise, this field is optional.

subscription_status
boolean

The subscription status of the customer. Possible values are: true(Subscribed),false(Unsubscribed). This indicates whether the customer is currently subscribed to the platform's services or not.

phone
string

The phone number of the customer in E.164 format. e.g +14155552671

created_at
required
string

The date when the customer account was created format (YYYY-MM-DD).

updated_at
required
string

The date when the customer account was updated format (YYYY-MM-DD).

date_of_birth
string

The customer's birthdate in format (YYYY-MM-DD)

reward_eligibility
boolean

Indicates whether the customer is eligible to earn points for creating an account. When true, the customer receives points for this action (if the rule is enabled). When false or not passed, no points are awarded. By default, it is set to false. Help Article : https://help.targetbay.com/s/article/Understanding-rewards-eligibility-in-the-Customer-Create-Update-API

first_name
string

This is the customer's first name.

last_name
string

This is the customer's last name.

full_name
string

This is the customer's full name.

address1
string
address2
string
city
string
state
string
country
string
country_code
string
zip
integer

Responses

Request samples

Content type
application/json
Example
{
  • "platform_customer_id": "8223704023221",
  • "email": "johndoe@targetbay.com",
  • "referred_id": "69785a978d6796ee090dd4d0",
  • "subscription_status": true,
  • "phone": "+14155552671",
  • "created_at": "2021-08-04",
  • "updated_at": "2021-08-05",
  • "date_of_birth": "1990-05-20",
  • "reward_eligibility": true,
  • "first_name": "John",
  • "last_name": "Doe",
  • "full_name": "John Doe",
  • "address1": "Melrose Avenu",
  • "address2": "No 102",
  • "city": "Los Angeles",
  • "state": "Michigan",
  • "country": "United States",
  • "country_code": "US",
  • "zip": 30303
}

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Retrieve customer information.

Retrieves the information for a specific customer identified by their unique platform customer ID / Email. Authorization: This endpoint requires a bearer token with the read_customer scope.

Authorizations:
bearerAuth
path Parameters
required
string or integer

The path identifier to fetch customer information. This value can be either - a string / integer platform_customer_id (e.g. 8223704023221), or - an email address (e.g. aabbcc@gmail.com) only when the query parameter lookup=email is provided. If lookup=email is omitted, the path value will be treated as a platform_customer_id.

query Parameters
lookup
string
Value: "email"
Example: lookup=email

Optional modifier to indicate the path platform_customer_id contains an email address. Provide lookup=email when passing an email in the path so the API will resolve by email.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Delete an Email contact in BayRewards

Deletes a specified email contact from the BayRewards system using the provided platform customer ID. This action will delete all associated data for the contact, including points balance and any other related information. Authorization: This endpoint requires a bearer token with the write_customer scope.

Authorizations:
bearerAuth
path Parameters
required
string or integer

The unique ID of the customer whose email contact is to be deleted from BayRewards. This value can be passed either as a string or an integer.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Ecommerce Data

Use these API endpoints to create, update, or delete collections, products, and orders in your BayRewards account.

Create and Update Collection in BayRewards

This endpoint allows for the creation and updating of collections within the BayRewards system. Authorization: This endpoint requires a bearer token with the write_collection scope.

Authorizations:
bearerAuth
Request Body schema: application/json
required
integer or string

This is the unique ID for the collection within your platform. It can be passed as either an integer or a string.

string or integer

This is the ID of the parent collection, if the current collection is a sub-collection. If there is no parent collection, this field can be omitted. It can be passed as either an integer or a string.

title
required
string

This is the name or title of the collection. It serves as the identifier or label for the collection within the platform.

Responses

Request samples

Content type
application/json
Example
{
  • "platform_collection_id": "8223704023221",
  • "title": "Vehicles"
}

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Delete a Collection in BayRewards

This endpoint allows for the deletion of collections within the BayRewards system. Authorization: This endpoint requires a bearer token with the write_collection scope.

Authorizations:
bearerAuth
path Parameters
required
string or integer

The unique ID of the collection you wish to delete. This value can be passed as either an integer or a string.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Create and Update a Product in BayRewards

This endpoint allows for the creation or updating of a product within the BayRewards system. Authorization: This endpoint requires a bearer token with the write_product scope.

Authorizations:
bearerAuth
Request Body schema: application/json
required
string or integer

The unique identifier for the product in your platform. This value can be passed as either an integer or a string.

string or integer

The unique identifiers for the product's collection(s) in your platform. This value can be passed as either an integer or a string.

product_title
required
string

The name of the product.

product_type
string

The type of the product. Must be either simple or variant. Use variant if your product has multiple variants.

product_url
string

The URL where the product can be found on your website.

created_at
string

The timestamp when the product was created format (YYYY-MM-DD).

updated_at
string

The timestamp when the product was last updated format (YYYY-MM-DD).

price
required
number

The price of the product.

Array of objects

A list of images associated with the product.

required
Array of objects

Detailed variant information for the product.

Responses

Request samples

Content type
application/json
Example
{
  • "platform_product_id": "822370402970",
  • "platform_collection_id": [
    ],
  • "product_title": "Shirt",
  • "product_type": "variant",
  • "created_at": "2021-08-04",
  • "updated_at": "2021-08-05",
  • "price": 79.99,
  • "images": [],
  • "variants": [
    ]
}

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "string",
  • "data": {
    }
}

Delete a Product in BayRewards

Deletes a specific product from the BayRewards platform using the provided product ID. Authorization: This endpoint requires a bearer token with the write_product scope.

Authorizations:
bearerAuth
path Parameters
required
string or integer

The Product ID that you wish to delete. This value can be passed as either a string or an integer.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Create and Update an Order in BayRewards

Creates a new order within the BayRewards system. This endpoint allows users to submit or update an order by providing necessary details. Authorization: This endpoint requires a bearer token with the write_order scope.

Authorizations:
bearerAuth
Request Body schema: application/json
required
string or integer

The unique identifier for the order in your platform. This value can be passed as either a string or an integer.

integer or string

The unique identifier for the customer placing the order. If not provided, the order will be marked as a guest order (customer without an account). This value can be passed as either a string or an integer.

email
required
string

The email address of the customer associated with the order.

phone
string

The phone number of the customer in E.164 format.

created_at
required
string

The timestamp when the order was created format (YYYY-MM-DD).

updated_at
required
string

The timestamp when the order was last updated format (YYYY-MM-DD).

completed_at
string

The timestamp when the order was completed format (YYYY-MM-DD). To learn more about this field, please refer to the Help article attached under reward_eligibility.

reward_eligibility
boolean

Indicates whether the customer is eligible to earn points for placing an order. When true, the customer receives points for eligible order actions (if the rule is enabled). When false or not passed, no points are awarded. By default, it is set to false. Help Article : https://help.targetbay.com/s/article/BayRewards-API-Understanding-reward-eligibility-in-Order-Create-Update

currency
string

Currency used for the order.

subtotal_price
required
number

The subtotal amount of the order before any discounts or taxes.

total_discounts
string

The total amount of discounts applied to the order.

total_price
required
number

The total amount of the order, including taxes and discounts.

total_tax
number

The total tax amount applied to the order.

Array of objects

List of discount codes applied to the order. If left blank, no discount will be applied.

Array of objects

Refund details associated with the order.

order_status
required
string

The current status of the order (open, completed, cancelled).

financial_status
string

The financial status of the order (paid, pending, failed).

order_number
number

Unique identifier for the order, typically assigned by the system.

required
Array of objects

The list of products within the order.

Responses

Request samples

Content type
application/json
{
  • "platform_order_id": "4112002",
  • "platform_customer_id": "643456",
  • "email": "jaygatsbytest@gmail.com",
  • "phone": "+14155552671",
  • "created_at": "2021-08-05",
  • "updated_at": "2021-08-06",
  • "completed_at": "2021-08-06",
  • "reward_eligibility": false,
  • "currency": "USD",
  • "subtotal_price": 500,
  • "total_discounts": "10",
  • "total_price": 500,
  • "total_tax": 0,
  • "discount_codes": [
    ],
  • "refunds": [
    ],
  • "order_status": "open",
  • "financial_status": "paid",
  • "order_number": 5674898,
  • "line_items": [
    ]
}

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Delete an Order in BayRewards

This endpoint allows you to delete an existing order from the BayRewards system. Authorization: This endpoint requires a bearer token with the write_order scope.

Authorizations:
bearerAuth
path Parameters
required
string or integer

The unique ID of the order that you wish to delete. This value can be passed as either a string or an integer.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Points

Use these API endpoints to perform admin actions in your BayRewards account.

Adjust customer points balance information.

Adjust customer points balance based on the email/platform_customer_id provided. Authorization: This endpoint requires a bearer token with the write_customer scope.

Authorizations:
bearerAuth
Request Body schema: application/json
One of
email
required
string

The email address of the customer whose points you want to adjust. Either this field or platform_customer_id is required to access this API.

points
required
integer

The number of points you want to adjust. If you simply pass a number, it will add points to the customer’s balance. To deduct points, use a negative value (e.g., -100).

string or integer

The unique ID of the customer. Can be integer or string.

Responses

Request samples

Content type
application/json
{
  • "email": "48xxxxxx@gmail.com",
  • "platform_customer_id": "82237040299",
  • "points": 10
}

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Discount

Use these API endpoints to create, update, or delete discount codes in your BayRewards account.

Create and Update Discount codes in BayRewards

You can perform create and update operations on a discount code in BayRewards. If the discount code exists, it will be updated; if not, a new one will be created. Authorization: This endpoint requires a bearer token with the write_discount scope.

Authorizations:
bearerAuth
Request Body schema: application/json
rule_id
required
integer

You can find the Rule ID in the BayRewards application under the Points section. Go to the Redeem option, and on the right side, you’ll see the list of rules created for redemption. Click Edit on the required rule, and on the right-hand side, within the Discount Payload, you’ll find the Rule ID.

rule_type
required
string

You can find the Rule Type in the BayRewards application under the Points section. Go to the Redeem option, and on the right side, you’ll see the list of rules created for redemption. Click Edit on the required rule, and on the right-hand side, within the Discount Payload, you’ll find the Rule Type. The available rule types are: redeem, referral, and vip.

required
Array of objects

The unique discount code and its status in your platform. It can either be active, expired, or used.

Responses

Request samples

Content type
application/json
Example
{
  • "rule_id": 2009,
  • "rule_type": "redeem",
  • "discount_codes": [
    ]
}

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Retrieve discount code information for a specific rule

Retrieves discount code information for a specific rule. Authorization: This endpoint requires a bearer token with the read_discount scope.

Authorizations:
bearerAuth
path Parameters
rule_id
required
integer

The rule ID maintained in BayRewards platform. You can check this under description for the created redemption rule.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Delete the discounts on the rule

Permanently deletes all discount codes associated with the provided rule ID. Authorization: This endpoint requires a bearer token with the write_discount scope.

Authorizations:
bearerAuth
path Parameters
rule_id
required
integer

The unique rule ID whose discount codes need to be deleted.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}

Delete a specific discount code in BayRewards

Permanently deletes a specific discount code from the BayRewards platform using the provided discount code value. Authorization: This endpoint requires a bearer token with the write_discount scope.

Authorizations:
bearerAuth
path Parameters
discount_code
required
string

The discount code you want to delete from BayRewards.

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "locale": "en",
  • "data": {
    }
}