Backend API
The promotion uses collection tracks each use of a promotion to ensure that promotion restrictions such as usage limits are maintained. Each promotion use relates the account and order to the promotion.
Fields
Unique identifier for the promotion use.
ID of the customer's account.
Expandable link to the account that used the promotion.
Date and time the promotion use was created.
Date and time the promotion use was last updated.
Expandable link to the order the promotion was applied to.
ID of the order that used the promotion.
Expandable link to the parent promotion.
ID of the parent promotion.
Expandable link to the subscription that spawned the promotion use, if applicable.
ID of the subscription that spawned the promotion use, if applicable.
The promotion use model
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "628fb3c90f42a10014f04787",
"order_id": "62a09d0317f83f001975b491",
"date_created": "2022-06-08T13:08:10.445Z",
"id": "62a09f3a17f83f001975b4d1"
},Create a new promotion use.
Arguments
Unique identifier of the parent promotion.
ID of the promotion use.
Unique identifier for the order that the promotion use is applied to.
ID of the subscription plan.
ID of the account connected to the promotion use.
Date and time the promotion use was created.
Date and time the promotion use was last updated.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.post('/promotions:uses', {
order_id: '62bf11bb4b738e00141c51d6'
});The promotion use model
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "628fb3c90f42a10014f04787",
"order_id": "62a09d0317f83f001975b491",
"date_created": "2022-06-08T13:08:10.445Z",
"id": "62a09f3a17f83f001975b4d1"
},Retrieve an existing promotion use using the ID that was returned when created.
Arguments
The ID of the promotion use to retrieve.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/promotions:uses/{id}', {
id: '62a09f3a17f83f001975b4d1'
});Response
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "628fb3c90f42a10014f04787",
"order_id": "62a09d0317f83f001975b491",
"date_created": "2022-06-08T13:08:10.445Z",
"id": "62a09f3a17f83f001975b4d1"
}Return a list of promotion uses.
Arguments
Expand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Returns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
Include one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.
The page number of results to return given the specified or default limit.
A text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
Expression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
An object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/promotions:uses', {
where: {
active: true
},
limit: 25,
page: 1
});
The promotion use model
{
"count": 3,
"results": [
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "628fb3c90f42a10014f04787",
"order_id": "62a09d0317f83f001975b491",
"date_created": "2022-06-08T13:08:10.445Z",
"id": "62a09f3a17f83f001975b4d1"
},
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "6296b0ad8f4d1100129e16c3",
"order_id": "6296b2aa50a04b0012bc64c6",
"date_created": "2022-06-01T00:28:26.103Z",
"id": "6296b2aa50a04b0012bc64c7"
},
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "628fb3c90f42a10014f04787",
"order_id": "628fb3e10f42a10014f0478d",
"date_created": "2022-05-26T17:07:45.415Z",
"id": "628fb3e10f42a10014f0478e"
}
]
}Delete a promotion use permanently.
Arguments
The ID of the promotion use to delete.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.delete('/promotions:uses/{id}', {
id: '60f199509111e70000000074'
});
The promotion use model
{
"parent_id": "6285746dd0fc72001a6a2f4e",
"account_id": "628fb3c90f42a10014f04787",
"order_id": "62a09d0317f83f001975b491",
"date_created": "2022-06-08T13:08:10.445Z",
"id": "62a09f3a17f83f001975b4d1"
},