API ReferenceCommerce

Discounts

Discount codes: the codes a shopper types to apply a discount made in the admin.

Prefix /cdna-api/discounts ReferenceCode model ReferenceDiscount model
Discounts in Postman

About discounts

A discount, with its rules (the conditions it needs and the actions it takes on the cart, its products or shipping), is made in the admin; the API has no routes for discounts or rules. Its codes are what the API manages: each applies its discount when a shopper enters it in the cart or the checkout, or follows its link.

Discounts Admin only

Discounts and their rules are made in the admin; only their codes have API routes.

Quotes and B2B
Uses Optional limit

maxUses caps a code; left out, it can be used without limit.

The cart

List discount codes#

GET /cdna-api/discounts/codes

Lists discount codes; add a discount id to the path, /discounts/codes/{id}, for one discount’s. This site has none, as the example shows.

Access
Admin users and integrations, with an OAuth access token or an API key.
Model
Code, in the Reference

Parameters

propertiesquery
selector
The fields and relations to return, such as {id,code,maxUses,discount{id,name}}.
filtersquery
name=value
Any stored field, or a relation with a dot, such as parent.id=12. Prefix the name with !, >, <, % or |. Use stored field names exactly as in the model, and compare totalCount with the unfiltered list's to confirm a filter applied.
orderByquery
string
field:ASC or field:DESC, comma-separated. Stored fields only.
limitquery
integer
Records per response. There is no default.
offsetquery
integer
Records to skip.

Example

List discount codes
GET /cdna-api/discounts/codes?limit=2&properties={id,code,maxUses,discount{id,name}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "totalCount": 0,
  "data": []
}
Open in Postman docs Real response from this documentation site

Show a discount code#

GET /cdna-api/discounts/code/{id}

Reads one discount code by its id.

Access
Admin users and integrations, with an OAuth access token or an API key.
Model
Code, in the Reference

Parameters

idpathrequired
integer
The discount code id.
propertiesquery
selector
The fields and relations to return, such as {id,code,maxUses,discount{id,name}}.

Example

Show a discount code
GET /cdna-api/discounts/code/5 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json

Create a discount code#

POST /cdna-api/discounts/code

Creates a discount code.

Access
Admin users and integrations, with an OAuth access token or an API key.
Returns
The new code under data.code, and a message.

Parameters

discountbodyrequired
integer
The discount it applies, made in the admin.
codebodyrequired
string
The code. Unique.
maxUsesbody
integer
How many times it may be used, more than 0; left out, without limit.
codeUrlbody
object
A link that applies the code.

Example

Create a discount code
POST /cdna-api/discounts/code HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "discount": 3,
  "code": "SAVE10",
  "maxUses": 100
}

Edit a discount code#

PUT /cdna-api/discounts/code/{id}

Changes a discount code. Fields left out keep their values.

Access
Admin users and integrations, with an OAuth access token or an API key.
Returns
The saved code under data.code, and a message.

Parameters

idpathrequired
integer
The discount code id.
codeUrlbody
object
A link that applies the code, as {"customUrl": {"url": "/pro-code"}}.

Example

Edit a discount code
PUT /cdna-api/discounts/code/5 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "codeUrl": {
    "customUrl": {
      "url": "/pro-code"
    }
  }
}

Delete a discount code#

DELETE /cdna-api/discounts/code/{id}

Deletes a discount code.

Access
Admin users and integrations, with an OAuth access token or an API key.

Parameters

idpathrequired
integer
The discount code id.

Example

Delete a discount code
DELETE /cdna-api/discounts/code/5 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json