OverviewPlatformsAPI ReferenceResources
Commerce

Create a discount

POSThttps://zernio.com/api/v1/commerce/discounts

Creates a code discount (buyers enter a code) or an automatic one (applied at checkout), as a percentage, a fixed amount or free shipping. It applies to every product unless productIds or collectionIds narrow it, and to every buyer.

PlatformsShopify

Authentication

AuthorizationBearer tokenRequired

API key authentication: send your Zernio API key in the Authorization header, prefixed with Bearer.

Body

application/json

What every request needs

accountIdstringRequired
titlestringRequired
methodstringRequiredOne of code | automatic
typestringRequiredOne of percentage | fixed_amount | free_shipping
Optional parameters12 fields
codestring

Required for method code.

percentagenumber

For type percentage, e.g. 15 for 15%.

amountstring

For type fixed_amount, a decimal in the store currency.

appliesOnEachItemboolean

fixed_amount only: take the amount off each item instead of once per order.

minimumSubtotalstring or null

Minimum order subtotal, a decimal in the store currency.

minimumQuantityinteger or null
usageLimitinteger or null

Code discounts only: total uses allowed.

oncePerCustomerboolean

Code discounts only.

startsAtstring (date-time)

Defaults to now.

endsAtstring or null (date-time)
productIdsarray of strings
collectionIdsarray of strings

Responses

Success· the request worked

Errors· the request failed

POST/v1/commerce/discounts
import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.commerce.createCommerceDiscount({  body: {    accountId: 'account_abc123',    title: 'Example',    method: 'code',    type: 'percentage',  },});console.log(data);
{  "discount": {    "id": "string",    "accountId": "string",    "platform": "shopify",    "title": "string",    "method": "code",    "type": "percentage",    "codes": [      "string"    ],    "codeCount": 0,    "value": {      "type": "percentage",      "percentage": 0    },    "appliesTo": {      "type": "all",      "productIds": [        "string"      ],      "variantIds": [        "string"      ],      "collectionIds": [        "string"      ]    },    "minimum": {      "type": "subtotal",      "amount": {        "amount": "string",        "currency": "string"      },      "quantity": 0    },    "usageLimit": 0,    "oncePerCustomer": true,    "usageCount": 0,    "startsAt": "2019-08-24T14:15:22Z",    "endsAt": "2019-08-24T14:15:22Z",    "status": "active",    "platformStatus": "string",    "summary": "string",    "platformData": {}  }}
OpenAPI specification
Was this page helpful?