> For the complete documentation index, see [llms.txt](https://help.recart.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.recart.com/developers/public-api/discount/publish-a-discount-draft.md).

# Publish a discount draft

**Not yet enabled for merchant accounts.** Returns `403` `ERR_WRITE_NOT_ALLOWED` until enabled for your account.

Creates the discount on Shopify from a draft made with `POST /discounts`, with the draft's effective settings. The request has no body. Only the API key that made the draft can publish it. The discount keeps the draft's id. A code pool's codes are uploaded to Shopify over the next minutes, until fillStatus is full.

Publishing again is safe: a published draft returns the discount with `200`, and no second discount is created. When the response is lost or is a `5XX`, call again with the same id.

```json
{"openapi":"3.1.0","info":{"title":"Recart API","version":"2023-12"},"tags":[{"name":"Discount","description":"Discounts"}],"servers":[{"url":"https://api.recart.com/app-integrations/2023-12","description":"Production"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-Recart-API-Key","description":"It can be obtained in Recart account after contacting Support"}},"schemas":{"DiscountDetail":{"type":["object"],"required":["type","attributes"],"properties":{"type":{"type":"string","enum":["discounts"]},"attributes":{"allOf":[{"$ref":"#/components/schemas/DiscountAttributes"},{"type":"object","required":["usage","statistics"],"properties":{"usage":{"type":"object","description":"Where the discount is configured — configuration references, not code consumption","required":["flows","campaigns","optinTools"],"properties":{"flows":{"type":"array","description":"Automated flows; a campaign's own flow is listed under campaigns only","items":{"$ref":"#/components/schemas/UsageReference"}},"campaigns":{"type":"array","items":{"$ref":"#/components/schemas/UsageReference"}},"optinTools":{"type":"array","items":{"$ref":"#/components/schemas/UsageReference"}}}},"statistics":{"$ref":"#/components/schemas/DiscountStatistics"}}}]}}},"DiscountAttributes":{"type":"object","required":["id","name","status","customizationType","type","discountClasses","shopifyDiscountId","createdAt","updatedAt"],"properties":{"id":{"type":"string","description":"ID of the discount"},"name":{"type":"string","description":"Name of the discount"},"status":{"type":"string","description":"Computed from startsAt / endsAt; expired also after deactivation","enum":["active","scheduled","expired"]},"customizationType":{"type":"string","description":"unique = each customer gets a different code; general = one shared code","enum":["unique","general"]},"expiryType":{"type":"string","description":"unique only. fixed = a code pool whose codes expire at the end\ndate set when the discount was created. relative = an expiring\ncode created on demand; its expiration timer starts the moment\nthe customer receives the code via popup or SMS.\n","enum":["fixed","relative"]},"type":{"type":"string","description":"Shopify discount type; with discountClasses it is the\ndashboard's type (basic + product = Amount off product,\nbasic + order = Amount off order)\n","enum":["basic","bxgy","free-shipping","app"]},"discountClasses":{"type":"array","description":"Shopify discount classes of the discount. Together with the\nprice rule's combination settings they define which other\ndiscounts it can be combined with in one checkout, see\nhttps://help.shopify.com/en/manual/discounts/discount-combinations\n","items":{"type":"string","enum":["product","order","shipping"]}},"amount":{"type":"number","description":"Not on app discounts"},"valueType":{"type":"string","description":"Not on app discounts","enum":["PERCENTAGE","FIXED_AMOUNT","FREE_SHIPPING","UNKNOWN"]},"summary":{"type":"string","description":"Shopify's one-line description of value, target and conditions; not on app discounts"},"appTitle":{"type":"string","description":"App discounts only — the Shopify app that owns the discount"},"code":{"type":"string","description":"general only"},"discountCodePattern":{"type":"string","description":"unique only — the code prefix followed by `{RAND}`, the placeholder for the random part of each code"},"mode":{"type":"string","description":"code pools only — refilling pools serve flows and popups, non-refilling pools serve campaigns","enum":["refilling","non-refilling"]},"targetCount":{"type":"integer","description":"code pools only"},"availableCount":{"type":"integer","description":"code pools only — codes not yet issued"},"fillStatus":{"type":"string","description":"code pools only — filling = codes still uploading to Shopify","enum":["needFilling","filling","full"]},"durationSeconds":{"type":"integer","description":"expiring only — validity from the moment the code is issued"},"template":{"type":"object","additionalProperties":true,"description":"expiring only — the Shopify discount input each issued code's\nprice rule is created from, as stored\n(type, title, appliesOncePerCustomer, usageLimit,\ncombinesWith, customerSelection, customerGets,\nminimumRequirement, destinationSelection for free shipping)\n"},"startsAt":{"type":"string","format":"date-time","description":"Not on expiring discounts"},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"null = no end date; not on expiring discounts"},"shopifyDiscountId":{"type":"string","description":"The Shopify discount (price rule) id"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"UsageReference":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string","description":"Empty when the referenced entity no longer exists"}}},"DiscountStatistics":{"type":"object","description":"Lifetime counters of one discount, no date range. Which fields are\npresent depends on the discount shape and on omitShopifyData:\n- sent — code pools and expiring discounts (customizationType\n  unique), whatever omitShopifyData is; never on general discounts\n  (a shared static code has no issuance record). Recart's count of\n  codes issued to subscribers by a message or popup, not deliveries.\n- used, sales, codesCount — only with omitShopifyData=false, and\n  only on general discounts and code pools; never on expiring\n  discounts (each issued code is its own Shopify price rule, the\n  stored one is never redeemed). Shopify's own counters, refreshed\n  asynchronously — they can lag recent orders by minutes.\nPer shape: general → {} by default, used + sales + codesCount with\nomitShopifyData=false; code pool → sent by default, all four with\nomitShopifyData=false; expiring → sent, whatever the flag.\n","properties":{"sent":{"type":"integer","description":"Codes issued to subscribers from the pool or created on demand. Present on code pools and expiring discounts whatever omitShopifyData is; absent on general discounts"},"used":{"type":"integer","description":"Orders that redeemed the discount (Shopify asyncUsageCount). Present only with omitShopifyData=false, on general discounts and code pools; absent on expiring discounts"},"sales":{"type":"object","additionalProperties":{"type":"number"},"description":"Shopify total sales keyed by currency code — the store currency only, no conversion. Same availability as used"},"codesCount":{"type":"integer","description":"Codes Shopify holds for the discount, 1 for general. Same availability as used"}}},"HttpErrorBody":{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","items":{"type":"object","required":["id","code","title","detail"],"properties":{"id":{"type":"string"},"code":{"type":"string"},"title":{"type":"string"},"detail":{"type":"string"}}}}}}},"responses":{"HttpError":{"description":"HTTP Error response","content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}}}},"paths":{"/discounts/{id}/publish":{"post":{"summary":"Publish a discount draft","tags":["Discount"],"operationId":"publishDiscountDraft","description":"**Not yet enabled for merchant accounts.** Returns `403`\n`ERR_WRITE_NOT_ALLOWED` until enabled for your account.\n\nCreates the discount on Shopify from a draft made with\n`POST /discounts`, with the draft's effective settings. The request\nhas no body. Only the API key that made the draft can publish it.\nThe discount keeps the draft's id. A code pool's codes are uploaded\nto Shopify over the next minutes, until fillStatus is full.\n\nPublishing again is safe: a published draft returns the discount\nwith `200`, and no second discount is created. When the response is\nlost or is a `5XX`, call again with the same id.\n","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the draft","schema":{"type":"string"}}],"responses":{"200":{"description":"The draft was already published; the body is the discount, as with `201`","content":{"application/vnd.api+json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/DiscountDetail"}}}}}},"201":{"description":"The discount was created on Shopify","content":{"application/vnd.api+json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/DiscountDetail"}}}}}},"400":{"description":"`ERR_CODE_TAKEN` — another discount took the code after the draft\nwas made.\n\n`ERR_BAD_REQUEST` — Shopify rejected the draft's settings.\n`detail` is Shopify's message.\n\nAfter either error the draft cannot be published, and calling\nagain returns the same error. Correct the settings and create a\nnew draft.\n","content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}},"401":{"description":"`ERR_UNAUTHORIZED` — the API key is missing.","content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}},"403":{"description":"`ERR_FORBIDDEN` — the API key is unknown or has been revoked.\n\n`ERR_WRITE_NOT_ALLOWED` — creating discounts is not enabled for\nthis account. Do not retry.\n\n`ERR_SHOPIFY_ACCESS_DENIED` — Shopify denied access to the\nstore's discounts. Publishing cannot work until the store's\nShopify connection is fixed. Do not retry.\n","content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}},"404":{"description":"`ERR_NOT_FOUND` — this API key made no draft with this id, or\nthe draft expired. If an earlier publish of this id returned\n`409`, `5XX`, or no response, the discount may already exist on\nShopify. Check there before creating a new draft.\n","content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}},"409":{"description":"`ERR_CONFLICT` — a publish of this draft has started and not\nfinished. Call again in a few seconds with the same id; once the\npublish finishes, the call returns the discount. If it keeps\nreturning `409`, the publish stopped partway and cannot finish.\nThe discount may already exist on Shopify, so check there before\ncreating a new draft.\n","content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}},"429":{"description":"`ERR_SHOPIFY_THROTTLED` — Shopify throttled the request. Nothing\nwas created. Call again in a minute with the same id. After three\nthrottled publishes the draft cannot be published, and calling\nagain returns the same error. Create a new draft.\n\n`ERR_LIMIT_REACHED` — the publish limit of the site is reached.\n`detail` names the limit and when it resets. Call again after the\nreset with the same id, or create a new draft if the draft\nexpires before then.\n","headers":{"Retry-After":{"description":"Seconds until the limit resets; sent with `ERR_LIMIT_REACHED`","schema":{"type":"integer"}}},"content":{"application/vnd.api+json":{"schema":{"$ref":"#/components/schemas/HttpErrorBody"}}}},"4XX":{"$ref":"#/components/responses/HttpError"},"5XX":{"$ref":"#/components/responses/HttpError"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.recart.com/developers/public-api/discount/publish-a-discount-draft.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
