Create a coupon
Creates the discount in the store’s platform and starts making codes: a personal coupon keeps some ready as emails go out; a bulk coupon makes `quantity` at once. 422 `invalid_quantity` when a bulk coupon has none (or a personal one has one). 409 `coupons_unsupported` for a store without a supported platform; 409 `store_permission_missing` when the store hasn’t allowed Postforge to manage discounts yet; 409 `store_unreachable` when it must be reconnected; 422 `coupon_refused` with the platform’s reason.
Creates the discount in the store’s platform and starts making codes: a personal coupon keeps some ready as emails go out; a bulk coupon makes quantity at once. 422 invalid_quantity when a bulk coupon has none (or a personal one has one). 409 coupons_unsupported for a store without a supported platform; 409 store_permission_missing when the store hasn’t allowed Postforge to manage discounts yet; 409 store_unreachable when it must be reconnected; 422 coupon_refused with the platform’s reason.
apiKey writeAuthorizationBearer <token>A workspace API key (pf_…), created under Developers → API keys.
Scope: write
idempotency-key?stringRun this write once: a retry with the same key gets the first answer (24 hours).
1 <= length <= 255application/json- body
name*string1 <= length <= 100valueType*string"percentage""amount"value*integer1 <= valueminimumSubtotal*|1 <= valuevalidity*||combinesWith*|nullreissue*string"after_use_or_expiry""every_email"storeId*stringuuidkind*string"personal""bulk"quantity*|1 <= value <= 500000prefix*|^[A-Z0-9][A-Z0-9-]{0,19}$OK
application/json- response
id*stringuuidstore*name*stringsource*string"platform""import"kind*string"personal""bulk"quantity*integer|nullprefix*string|nullvalueType*|"percentage""amount"nullvalue*integer|nullminimumSubtotal*validity*||combinesWith*|nullreissue*string"after_use_or_expiry""every_email"status*string"active""ended""archived"externalId*string|nulladminUrl*|uriimportSkipped*integer|nullcodes*createdAt*stringdate-timearchivedAt*|date-timecurl -X POST 'https://api.postforge.dev/v1/coupons' \ -H 'Content-Type: application/json' \ -d '{ "name": "string", "valueType": "percentage", "value": 1, "minimumSubtotal": 1, "validity": { "type": "days", "days": 1 }, "combinesWith": { "orderDiscounts": true, "productDiscounts": true, "shippingDiscounts": true }, "reissue": "after_use_or_expiry", "storeId": "b8adcdc8-9238-4168-90f8-77b2d14c211c", "kind": "personal", "quantity": 1, "prefix": "string"}'{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "store": { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "platform": "string", "currency": "string" }, "name": "string", "source": "platform", "kind": "personal", "quantity": 0, "prefix": "string", "valueType": "percentage", "value": 0, "minimumSubtotal": { "amount": 0, "currency": "str" }, "validity": { "type": "days", "days": 1 }, "combinesWith": { "orderDiscounts": true, "productDiscounts": true, "shippingDiscounts": true }, "reissue": "after_use_or_expiry", "status": "active", "externalId": "string", "adminUrl": "http://example.com", "importSkipped": 0, "codes": { "available": 0, "assigned": 0, "used": 0, "expired": 0, "pending": 0, "failed": 0 }, "createdAt": "2019-08-24T14:15:22Z", "archivedAt": "2019-08-24T14:15:22Z"}