Public API v2: Discount Code
B2B discount codes with conditions, a minimum purchase, usage limits and a shareable link.
| Scopes | discount-code:read, discount-code:write |
| Plan | Every plan with Public API; otherwise 403 |
| Takes effect | Works at checkout as soon as it is saved; the code box updates at the next upload. |
Every response has the same envelope (success, status, data, meta; see Responses). Returns below describes data. The examples are real calls; the rules were created disabled.
Good to know
Section titled “Good to know”codeis unique in the store, any case; a share-linkpathis unique among enabled links.- A code works at checkout as soon as it is saved; the code box and the share page update at the next upload.
- Deleting a code is permanent and removes its usage report.
Discount Code API endpoints
- GET/api/v2/discount-code/rules# List rules
- POST/api/v2/discount-code/rules# Create a rule
- GET/api/v2/discount-code/rules/{id}# Get a rule
- PUT/api/v2/discount-code/rules/{id}# Replace a rule
- DEL/api/v2/discount-code/rules/{id}# Delete a rule
- POST/api/v2/discount-code/rules/bulk-upsert# Create or replace rules in bulk
- POST/api/v2/discount-code/rules/bulk-delete# Delete rules in bulk
- POST/api/v2/discount-code/rules/upload# Upload rules to the storefront
The rule object
Section titled “The rule object”What every read returns. Lists come back as [] when empty, never null.
idstringread-only
Rule id.
namestring
Rule name.
statusenum
disabled rules are kept but not applied. One of disabled, enabled.
codestring
case_sensitiveboolean
value_typeenum
One of fixed, percentage.
discount_valuestring
discount_scopeenum
One of product, order, free_shipping.
CustomersCommon object
Who gets the rule.
Show fields
apply_toenum
all everyone, logged in or not · logged_in any logged-in customer · non_logged_in visitors who are not logged in · customer_ids the listed customers · customer_tags customers with any of the tags · company_location the listed B2B company locations. Accepted here: all, logged_in, non_logged_in, customer_ids, customer_tags.
customer_ids[string]
Used when apply_to is customer_ids; required and not empty then.
customer_tags[string]
Used when apply_to is customer_tags; required and not empty then.
exclude_fromenum
none (default) · customer_tags · customer_ids · company_location. Excluded customers stay out even when apply_to includes them. Accepted here: none, customer_tags, customer_ids.
exc_customer_tags[string]
Used when exclude_from is customer_tags.
exc_customers[string]
Used when exclude_from is customer_ids.
ProductsCommon object
Which products the rule covers.
Show fields
product_condition_typeenum
all every product · by_ids · by_collections · by_tags · by_variants. Accepted here: all, by_ids, by_collections, by_tags.
product_ids[string]
Used when the type is by_ids; required and not empty then.
product_collections[string]
Used when the type is by_collections; required and not empty then.
product_tags[string]
Used when the type is by_tags; required and not empty then.
minimum_purchaseobject
Show fields
typeenum
One of none, amount, quantity.
valuestring or null
usage_limitobject
Show fields
totalinteger or null
per_customerinteger or null
show_remainingboolean
total_usedintegerread-only
Orders that used the code. Read-only.
total_remaininginteger or nullread-only
Uses left under usage_limit.total, null without one. Read-only: every save resets it.
share_linkobject
Show fields
enabledboolean
pathstring or null
redirect_urlstring or null
ScheduleCommon object
When the rule applies.
Show fields
start_atstring
UTC date and time ending in Z; null or left out: starts at once.
end_atstring
After start_at; null or left out: never ends.
created_atstring or nullread-only
UTC, ending in Z.
updated_atstring or nullread-only
UTC, ending in Z.
{ "id": "15", "name": "VIP 10%", "status": "disabled", "code": "VIP10", "case_sensitive": false, "value_type": "percentage", "discount_value": "10.00", "discount_scope": "product", "apply_to": "customer_tags", "customer_ids": [], "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customer_tags": [], "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_ids": [], "product_collections": [ "3001" ], "product_tags": [], "minimum_purchase": { "type": "amount", "value": "100.50" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "total_used": 0, "total_remaining": 100, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00.000Z", "end_at": "2026-12-01T00:00:00.000Z", "created_at": "2026-10-21T09:35:14.000Z", "updated_at": "2026-10-21T09:35:14.000Z"}List rules
GET/api/v2/discount-code/rules
List discount codes, newest first.
Query parameters
Section titled “Query parameters”limitinteger
1–250, default 50. See Paging.
cursorstring
next_cursor or prev_cursor of the last page; leave out for the first page. Keep the same filters on every page.
filter_statusenum
One of disabled, enabled.
filter_namestring
Part of the name, any case. 1–200 characters.
filter_codestring
Part of the code, any case. 1–100 characters.
Returns
Section titled “Returns”data[Rule]
The rules of this page; [] when there are none.
meta.paginationobject
limit, next_cursor, prev_cursor and links to the next and previous pages.
curl -X GET "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules?limit=2&filter_name=VIP" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com"{ "success": true, "status": "success", "data": [ { "id": "15", "name": "VIP 10%", "status": "disabled", "code": "VIP10", "case_sensitive": false, "value_type": "percentage", "discount_value": "10.00", "discount_scope": "product", "apply_to": "customer_tags", "customer_ids": [], "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customer_tags": [], "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_ids": [], "product_collections": [ "3001" ], "product_tags": [], "minimum_purchase": { "type": "amount", "value": "100.50" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "total_used": 0, "total_remaining": 100, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00.000Z", "end_at": "2026-12-01T00:00:00.000Z", "created_at": "2026-10-21T09:35:14.000Z", "updated_at": "2026-10-21T09:35:14.000Z" } ], "meta": { "timestamp": "2026-10-21T09:35:16.764Z", "version": "v2", "request_id": "4f26739a-97fc-4296-a81c-fe1648a3f55d", "rate_limit": { "cost": 10, "limit": 600, "remaining": 590, "restore_rate": 10 }, "pagination": { "limit": 2, "next_cursor": null, "prev_cursor": null, "links": { "self": "/api/v2/discount-code/rules?limit=2&filter_name=VIP", "next": null, "prev": null } } }}Create a rule
POST/api/v2/discount-code/rules
Create a discount code.
The body of POST /rules, PUT /rules/{id} and each element of bulk-upsert (add id to replace a rule). PUT replaces the whole rule: optional fields left out go back to their defaults. Fields not listed here are refused with 422.
Arguments
Section titled “Arguments”namestringrequired
Rule name. 1–200 characters.
statusenumrequired
disabled rules are kept but not applied. One of disabled, enabled.
codestringrequired
Unique in the shop, in any case. Changing it drops its per-customer usage. 1–100 characters.
case_sensitiveboolean
Default false.
value_typeenumrequired
fixed: A fixed amount off.percentage: A percentage off (at most 100).
discount_valuestring
A percentage (0–100) or an amount. Not used, and optional, with free_shipping. Decimal string, up to 2 decimals.
discount_scopeenumrequired
product: The discount goes to the matching products.order: The discount goes to the whole order.free_shipping: Free shipping; nodiscount_valueneeded.
CustomersCommon objectrequired
Who gets the rule.
Show fields
apply_toenum
all everyone, logged in or not · logged_in any logged-in customer · non_logged_in visitors who are not logged in · customer_ids the listed customers · customer_tags customers with any of the tags · company_location the listed B2B company locations. Accepted here: all, logged_in, non_logged_in, customer_ids, customer_tags.
customer_ids[string]
Used when apply_to is customer_ids; required and not empty then.
customer_tags[string]
Used when apply_to is customer_tags; required and not empty then.
exclude_fromenum
none (default) · customer_tags · customer_ids · company_location. Excluded customers stay out even when apply_to includes them. Accepted here: none, customer_tags, customer_ids.
exc_customer_tags[string]
Used when exclude_from is customer_tags.
exc_customers[string]
Used when exclude_from is customer_ids.
ProductsCommon objectrequired
Which products the rule covers.
Show fields
product_condition_typeenum
all every product · by_ids · by_collections · by_tags · by_variants. Accepted here: all, by_ids, by_collections, by_tags.
product_ids[string]
Used when the type is by_ids; required and not empty then.
product_collections[string]
Used when the type is by_collections; required and not empty then.
product_tags[string]
Used when the type is by_tags; required and not empty then.
minimum_purchaseobject
Left out: none.
Show fields
typeenumrequired
One of none, amount, quantity.
valuestring
An amount in the shop currency, or a quantity. Required unless type is none. Decimal string, up to 2 decimals.
usage_limitobject
Left out: no limit.
Show fields
totalinteger
Uses of the code in all; null or left out: no limit. 0–2,147,483,647.
per_customerinteger
Uses per logged-in customer; null or left out: no limit. 0–2,147,483,647.
show_remainingboolean
Tell the customer how many uses are left. Default false.
share_linkobject
Left out: no share link.
Show fields
enabledbooleanrequired
pathstring
Required when enabled. Must be unique among the active links.
redirect_urlstring
Where the link lands. Required when enabled.
ScheduleCommon object
When the rule applies.
Show fields
start_atstring
UTC date and time ending in Z; null or left out: starts at once.
end_atstring
After start_at; null or left out: never ends.
Returns
Section titled “Returns”dataRule
The new rule.
curl -X POST "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com" \ -H "Content-Type: application/json" \ -d '{ "name": "VIP 10%", "status": "disabled", "code": "VIP10", "value_type": "percentage", "discount_value": "10", "discount_scope": "product", "apply_to": "customer_tags", "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_collections": [ "3001" ], "minimum_purchase": { "type": "amount", "value": "100.5" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00Z", "end_at": "2026-12-01T00:00:00Z"}'{ "success": true, "status": "success", "data": { "id": "15", "name": "VIP 10%", "status": "disabled", "code": "VIP10", "case_sensitive": false, "value_type": "percentage", "discount_value": "10.00", "discount_scope": "product", "apply_to": "customer_tags", "customer_ids": [], "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customer_tags": [], "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_ids": [], "product_collections": [ "3001" ], "product_tags": [], "minimum_purchase": { "type": "amount", "value": "100.50" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "total_used": 0, "total_remaining": 100, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00.000Z", "end_at": "2026-12-01T00:00:00.000Z", "created_at": "2026-10-21T09:35:14.000Z", "updated_at": "2026-10-21T09:35:14.000Z" }, "meta": { "timestamp": "2026-10-21T09:35:14.148Z", "version": "v2", "request_id": "0038a590-a6d8-4b31-94e7-c9ceb2344a5f", "rate_limit": { "cost": 11, "limit": 600, "remaining": 589, "restore_rate": 10 } }}Get a rule
GET/api/v2/discount-code/rules/{id}
Get a discount code.
Path parameters
Section titled “Path parameters”idstringrequired
Rule id.
Returns
Section titled “Returns”dataRule
The rule. An id that does not exist answers 404 RESOURCE_NOT_FOUND.
curl -X GET "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules/15" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com"{ "success": true, "status": "success", "data": { "id": "15", "name": "VIP 10%", "status": "disabled", "code": "VIP10", "case_sensitive": false, "value_type": "percentage", "discount_value": "10.00", "discount_scope": "product", "apply_to": "customer_tags", "customer_ids": [], "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customer_tags": [], "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_ids": [], "product_collections": [ "3001" ], "product_tags": [], "minimum_purchase": { "type": "amount", "value": "100.50" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "total_used": 0, "total_remaining": 100, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00.000Z", "end_at": "2026-12-01T00:00:00.000Z", "created_at": "2026-10-21T09:35:14.000Z", "updated_at": "2026-10-21T09:35:14.000Z" }, "meta": { "timestamp": "2026-10-21T09:35:15.456Z", "version": "v2", "request_id": "0f9c3bec-c0ca-459c-83f0-09ede8c81547", "rate_limit": { "cost": 10, "limit": 600, "remaining": 590, "restore_rate": 10 } }}Replace a rule
PUT/api/v2/discount-code/rules/{id}
Replace a discount code; optional fields left out go back to their defaults.
Path parameters
Section titled “Path parameters”idstringrequired
Rule id.
Arguments
Section titled “Arguments”The same fields as Create a rule.
Returns
Section titled “Returns”dataRule
The rule after the change.
curl -X PUT "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules/15" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com" \ -H "Content-Type: application/json" \ -d '{ "name": "VIP 10% (updated)", "status": "disabled", "code": "VIP10", "value_type": "percentage", "discount_value": "10", "discount_scope": "product", "apply_to": "customer_tags", "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_collections": [ "3001" ], "minimum_purchase": { "type": "amount", "value": "100.5" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00Z", "end_at": "2026-12-01T00:00:00Z"}'{ "success": true, "status": "success", "data": { "id": "15", "name": "VIP 10% (updated)", "status": "disabled", "code": "VIP10", "case_sensitive": false, "value_type": "percentage", "discount_value": "10.00", "discount_scope": "product", "apply_to": "customer_tags", "customer_ids": [], "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customer_tags": [], "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_ids": [], "product_collections": [ "3001" ], "product_tags": [], "minimum_purchase": { "type": "amount", "value": "100.50" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "total_used": 0, "total_remaining": 100, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00.000Z", "end_at": "2026-12-01T00:00:00.000Z", "created_at": "2026-10-21T09:35:14.000Z", "updated_at": "2026-10-21T09:35:18.000Z" }, "meta": { "timestamp": "2026-10-21T09:35:18.101Z", "version": "v2", "request_id": "3278f9ff-5847-42c4-9d5f-f24680b10f76", "rate_limit": { "cost": 11, "limit": 600, "remaining": 589, "restore_rate": 10 } }}Delete a rule
DEL/api/v2/discount-code/rules/{id}
Delete a discount code and its usage report.
Path parameters
Section titled “Path parameters”idstringrequired
Rule id.
Returns
Section titled “Returns”data.idstring
Id of the deleted rule.
data.deletedboolean
true.
curl -X DELETE "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules/15" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com"{ "success": true, "status": "success", "data": { "id": "15", "deleted": true }, "meta": { "timestamp": "2026-10-21T09:35:22.036Z", "version": "v2", "request_id": "a24ed8d0-b5fd-40d5-a9bd-d929ae492c58", "rate_limit": { "cost": 11, "limit": 600, "remaining": 589, "restore_rate": 10 } }}Create or replace rules in bulk
POST/api/v2/discount-code/rules/bulk-upsert
Create or replace up to 250 discount codes; each one succeeds or fails on its own.
See Bulk & idempotency.
Arguments
Section titled “Arguments”rules[object]required
1–250 rules, each with the fields of Create a rule.
Show fields
idstring
Set it to replace that rule, as Replace a rule does; leave it out to create one.
Returns
Section titled “Returns”data.results[object]
One entry per rule, in the order sent.
Show fields
indexinteger
Position of the rule in rules.
idstring
Rule id.
resultenum
created, updated or error.
errorobject
code and message, only when result is error.
data.summaryobject
total, succeeded, failed.
curl -X POST "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules/bulk-upsert" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com" \ -H "Content-Type: application/json" \ -d '{ "rules": [ { "name": "VIP 10% B", "status": "disabled", "code": "VIP10", "value_type": "percentage", "discount_value": "10", "discount_scope": "product", "apply_to": "customer_tags", "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_collections": [ "3001" ], "minimum_purchase": { "type": "amount", "value": "100.5" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00Z", "end_at": "2026-12-01T00:00:00Z" }, { "name": "VIP 10% (bulk)", "status": "disabled", "code": "VIP10", "value_type": "percentage", "discount_value": "10", "discount_scope": "product", "apply_to": "customer_tags", "customer_tags": [ "vip" ], "exclude_from": "customer_ids", "exc_customers": [ "7001" ], "product_condition_type": "by_collections", "product_collections": [ "3001" ], "minimum_purchase": { "type": "amount", "value": "100.5" }, "usage_limit": { "total": 100, "per_customer": 2, "show_remaining": true }, "share_link": { "enabled": true, "path": "b2b-discount/vip", "redirect_url": "owner.myshopify.com/cart" }, "start_at": "2026-11-01T00:00:00Z", "end_at": "2026-12-01T00:00:00Z", "id": "15" } ]}'{ "success": true, "status": "success", "data": { "results": [ { "index": 0, "id": null, "result": "error", "error": { "code": "VALIDATION_ERROR", "message": "Validation failed", "details": [ { "field": "code", "message": "Another discount code of the shop already uses it, in any case" } ] } }, { "index": 1, "id": "15", "result": "updated" } ], "summary": { "total": 2, "succeeded": 1, "failed": 1 } }, "meta": { "timestamp": "2026-10-21T09:35:19.419Z", "version": "v2", "request_id": "6461b3cd-9fbb-4eec-8d38-e8cc97272da7", "rate_limit": { "cost": 11, "limit": 600, "remaining": 589, "restore_rate": 10 } }}Delete rules in bulk
POST/api/v2/discount-code/rules/bulk-delete
Delete up to 250 discount codes; an unknown id fails on its own.
See Bulk & idempotency.
Arguments
Section titled “Arguments”ids[string]required
1–250 rule ids.
Returns
Section titled “Returns”data.results[object]
One entry per id: index, id, result (deleted or error) and error (code, message) when it failed.
data.summaryobject
total, succeeded, failed.
curl -X POST "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules/bulk-delete" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com" \ -H "Content-Type: application/json" \ -d '{ "ids": [ "999999999" ]}'{ "success": true, "status": "success", "data": { "results": [ { "index": 0, "id": "999999999", "result": "error", "error": { "code": "RESOURCE_NOT_FOUND", "message": "Resource not found" } } ], "summary": { "total": 1, "succeeded": 0, "failed": 1 } }, "meta": { "timestamp": "2026-10-21T09:35:20.728Z", "version": "v2", "request_id": "8d2d7dca-245b-4ff1-951b-555b63b3cc6b", "rate_limit": { "cost": 11, "limit": 600, "remaining": 589, "restore_rate": 10 } }}Upload rules to the storefront
POST/api/v2/discount-code/rules/upload
Upload the rules to the storefront, as the app does.
The body is empty. See Upload.
Returns
Section titled “Returns”data.statusenum
uploaded, or partial_success when some rules did not reach the storefront.
data.skippedobject
capacity_exceeded, write_failed and rule_id_range; see Upload.
curl -X POST "https://solution-public-api.bss-b2b.solutions/api/v2/discount-code/rules/upload" \ -H "X-API-Key: $B2B_API_KEY" \ -H "X-Shop-Domain: your-store.myshopify.com"Answer of the Net Terms upload; every module answers in this shape.
{ "success": true, "status": "success", "data": { "status": "uploaded", "skipped": { "capacity_exceeded": 0, "write_failed": 0, "rule_id_range": null } }, "meta": { "timestamp": "2026-10-21T09:34:46.663Z", "version": "v2", "request_id": "db2079e7-e134-412e-9943-e2c2b29a9e8c", "rate_limit": { "cost": 20, "limit": 600, "remaining": 580, "restore_rate": 10 } }}- Public API v2: Authentication & keysCreate Public API v2 keys with per-module permissions, send them with every request, and keep them safe.
- Public API v2: Auto TagRules that tag customers and orders, add notes or mark a customer tax exempt when an event happens.
- Public API v2: Buy X Get YBuy X Get Y offers: what the customer buys, what they get, and the discount on it.
- Public API v2: Bulk & idempotencyCreate, replace or delete up to 250 rules in one Public API v2 request, and retry POST requests safely.