Create a discount
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.
Authorization
bearerAuth API key authentication: send your Zernio API key in the Authorization header, prefixed with Bearer.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
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": {} }}