Browse the API docs

Discounts

Discount codes customers type at checkout, and automatic discounts that apply by themselves when the cart qualifies.

Endpoints#

Paths are relative to https://store.weftgrid.com/api/admin/2026-10. The examples read the token from $STORELOOM_TOKEN and ids from variables like $ORDER_ID.

The discount object#

What the endpoints below return for one discount, and the payload of the discounts/create, discounts/update webhooks.

discount
{
  "id": "cm2disc0001",
  "title": "WELCOME10",
  "code": "WELCOME10",
  "automatic": false,
  "value_type": "percentage",
  "value": "10",
  "applies_to": "all",
  "product_ids": [],
  "collection_ids": [],
  "minimum_subtotal": "30.00",
  "minimum_quantity": 0,
  "usage_limit": null,
  "usage_count": 14,
  "once_per_customer": true,
  "starts_at": null,
  "ends_at": null,
  "active": true,
  "volume": null,
  "bundle": null,
  "buy_x_get_y": null,
  "created_at": "2026-09-20T10:00:00.000Z",
  "updated_at": "2026-10-23T09:30:00.000Z"
}

List discounts#

GET/discounts.jsonread_discounts
Query parameters
ParameterDescription
limit, page_info, since_id, ids, fieldsPagination and selection.
automatictrue for automatic discounts, false for codes.
activetrue or false (the on/off switch; dates and usage limits aren't taken into account).
codeExact code, in any case.
created_at_min / created_at_max, updated_at_min / updated_at_maxISO 8601 bounds.
Request
curl "https://store.weftgrid.com/api/admin/2026-10/discounts.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN"
Example responseShow
{
  "discounts": [
    {
      "id": "cm2disc0001",
      "title": "WELCOME10",
      "code": "WELCOME10",
      "automatic": false,
      "value_type": "percentage",
      "value": "10",
      "applies_to": "all",
      "product_ids": [],
      "collection_ids": [],
      "minimum_subtotal": "30.00",
      "minimum_quantity": 0,
      "usage_limit": null,
      "usage_count": 14,
      "once_per_customer": true,
      "starts_at": null,
      "ends_at": null,
      "active": true,
      "volume": null,
      "bundle": null,
      "buy_x_get_y": null,
      "created_at": "2026-09-20T10:00:00.000Z",
      "updated_at": "2026-10-23T09:30:00.000Z"
    }
  ]
}

Count discounts#

GET/discounts/count.jsonread_discounts
Query parameters
ParameterDescription
automatic, active, code, ids, created_at_*, updated_at_*Same filters as the list.
Request
curl "https://store.weftgrid.com/api/admin/2026-10/discounts/count.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN"
Example responseShow
{
  "count": 5
}

Look up a code#

GET/discounts/lookup.jsonread_discounts

Finds the discount for a code as a customer would type it (any case, spaces ignored). 404 when there's none.

Query parameters
ParameterDescription
codeThe code, e.g. welcome10.
Request
curl "https://store.weftgrid.com/api/admin/2026-10/discounts/lookup.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN"
Example responseShow
{
  "discount": {
    "id": "cm2disc0001",
    "title": "WELCOME10",
    "code": "WELCOME10",
    "automatic": false,
    "value_type": "percentage",
    "value": "10",
    "applies_to": "all",
    "product_ids": [],
    "collection_ids": [],
    "minimum_subtotal": "30.00",
    "minimum_quantity": 0,
    "usage_limit": null,
    "usage_count": 14,
    "once_per_customer": true,
    "starts_at": null,
    "ends_at": null,
    "active": true,
    "volume": null,
    "bundle": null,
    "buy_x_get_y": null,
    "created_at": "2026-09-20T10:00:00.000Z",
    "updated_at": "2026-10-23T09:30:00.000Z"
  }
}

Get a discount#

GET/discounts/{id}.jsonread_discounts
Request
curl "https://store.weftgrid.com/api/admin/2026-10/discounts/$DISCOUNT_ID.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN"
Example responseShow
{
  "discount": {
    "id": "cm2disc0001",
    "title": "WELCOME10",
    "code": "WELCOME10",
    "automatic": false,
    "value_type": "percentage",
    "value": "10",
    "applies_to": "all",
    "product_ids": [],
    "collection_ids": [],
    "minimum_subtotal": "30.00",
    "minimum_quantity": 0,
    "usage_limit": null,
    "usage_count": 14,
    "once_per_customer": true,
    "starts_at": null,
    "ends_at": null,
    "active": true,
    "volume": null,
    "bundle": null,
    "buy_x_get_y": null,
    "created_at": "2026-09-20T10:00:00.000Z",
    "updated_at": "2026-10-23T09:30:00.000Z"
  }
}

Create a discount#

POST/discounts.jsonwrite_discounts

value_type is percentage (value is a whole percent, 1–100), fixed_amount (value is an amount like "5.00") or free_shipping (no value).

Volume, bundle and buy X get Y discounts have no value; their settings are an object. volume takes volume: { basis: "quantity" | "amount", reward: "percentage" | "fixed_amount", tiers: [{ minimum_quantity | minimum_amount, value }] } (up to 5 tiers, each needing more than the one before and giving more off; the highest tier reached applies). bundle_price takes bundle: { quantity, price, pick: "dearest" | "cheapest" }: any quantity eligible items for price, once per full set. buy_x_get_y takes buy_x_get_y: { buys: { quantity } | { amount }, gets: { quantity, percentage (100: free), applies_to: "same" | "products" | "collections", product_ids, collection_ids }, uses_per_order }; what customers buy is the discount's own applies_to. Sending the object replaces the old settings.

Code discounts need a code: up to 64 letters, numbers, hyphens or underscores, stored upper-case (customers can type any case). Automatic discounts (automatic: true) need a title, which buyers see in the cart.

applies_to is all, products (with product_ids) or collections (with collection_ids). Optional: minimum_subtotal (an amount) or minimum_quantity, usage_limit (total uses), once_per_customer, starts_at and ends_at (ISO 8601) and active.

Fires discounts/create.

Request body
{
  "discount": {
    "code": "HOME20",
    "value_type": "percentage",
    "value": "20",
    "applies_to": "collections",
    "collection_ids": [
      "cm2coll0001"
    ],
    "minimum_subtotal": "50.00",
    "usage_limit": 200,
    "ends_at": "2026-12-31T23:59:59Z"
  }
}
Request with curl
curl -X POST "https://store.weftgrid.com/api/admin/2026-10/discounts.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "discount": {
    "code": "HOME20",
    "value_type": "percentage",
    "value": "20",
    "applies_to": "collections",
    "collection_ids": [
      "cm2coll0001"
    ],
    "minimum_subtotal": "50.00",
    "usage_limit": 200,
    "ends_at": "2026-12-31T23:59:59Z"
  }
}'
Example responseShow
{
  "discount": {
    "id": "cm2disc0001",
    "title": "HOME20",
    "code": "HOME20",
    "automatic": false,
    "value_type": "percentage",
    "value": "20",
    "applies_to": "collections",
    "product_ids": [],
    "collection_ids": [
      "cm2coll0001"
    ],
    "minimum_subtotal": "50.00",
    "minimum_quantity": 0,
    "usage_limit": 200,
    "usage_count": 0,
    "once_per_customer": false,
    "starts_at": null,
    "ends_at": "2026-12-31T23:59:59.000Z",
    "active": true,
    "volume": null,
    "bundle": null,
    "buy_x_get_y": null,
    "created_at": "2026-09-20T10:00:00.000Z",
    "updated_at": "2026-10-23T09:30:00.000Z"
  }
}

Update a discount#

PUT/discounts/{id}.jsonwrite_discounts

Fields you leave out keep their values; send null to clear usage_limit, starts_at or ends_at. usage_count is read-only. Fires discounts/update.

value_type is percentage (value is a whole percent, 1–100), fixed_amount (value is an amount like "5.00") or free_shipping (no value).

Volume, bundle and buy X get Y discounts have no value; their settings are an object. volume takes volume: { basis: "quantity" | "amount", reward: "percentage" | "fixed_amount", tiers: [{ minimum_quantity | minimum_amount, value }] } (up to 5 tiers, each needing more than the one before and giving more off; the highest tier reached applies). bundle_price takes bundle: { quantity, price, pick: "dearest" | "cheapest" }: any quantity eligible items for price, once per full set. buy_x_get_y takes buy_x_get_y: { buys: { quantity } | { amount }, gets: { quantity, percentage (100: free), applies_to: "same" | "products" | "collections", product_ids, collection_ids }, uses_per_order }; what customers buy is the discount's own applies_to. Sending the object replaces the old settings.

Code discounts need a code: up to 64 letters, numbers, hyphens or underscores, stored upper-case (customers can type any case). Automatic discounts (automatic: true) need a title, which buyers see in the cart.

applies_to is all, products (with product_ids) or collections (with collection_ids). Optional: minimum_subtotal (an amount) or minimum_quantity, usage_limit (total uses), once_per_customer, starts_at and ends_at (ISO 8601) and active.

Request body
{
  "discount": {
    "active": false
  }
}
Request with curl
curl -X PUT "https://store.weftgrid.com/api/admin/2026-10/discounts/$DISCOUNT_ID.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "discount": {
    "active": false
  }
}'
Example responseShow
{
  "discount": {
    "id": "cm2disc0001",
    "title": "WELCOME10",
    "code": "WELCOME10",
    "automatic": false,
    "value_type": "percentage",
    "value": "10",
    "applies_to": "all",
    "product_ids": [],
    "collection_ids": [],
    "minimum_subtotal": "30.00",
    "minimum_quantity": 0,
    "usage_limit": null,
    "usage_count": 14,
    "once_per_customer": true,
    "starts_at": null,
    "ends_at": null,
    "active": false,
    "volume": null,
    "bundle": null,
    "buy_x_get_y": null,
    "created_at": "2026-09-20T10:00:00.000Z",
    "updated_at": "2026-10-23T09:30:00.000Z"
  }
}

Delete a discount#

DELETE/discounts/{id}.jsonwrite_discounts

Orders that used it keep the code and amount. Fires discounts/delete.

Request
curl -X DELETE "https://store.weftgrid.com/api/admin/2026-10/discounts/$DISCOUNT_ID.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN"
Example responseShow
{}