Discount API not creating a Discount Code

Topic summary

A developer is experiencing issues creating discount codes via Shopify’s API. POST requests to the discount codes endpoint return HTTP 200 but fail to create any codes.

Technical Details:

  • Endpoint: /admin/api/2023-10/price_rules/[ID]/discount_codes.json
  • Authentication: X-Shopify-Access-Token header included
  • Request body follows documented format with discount code object
  • Using a custom private app created in shop settings

Troubleshooting Attempts:

  • Manually created price rule and attempted to add codes via API
  • Tried creating price rule via API with same results
  • GET requests to same endpoint return 400 errors

Current Status:
A support representative (SBD) is investigating by requesting multiple request IDs from failed attempts. The developer has provided several request IDs for log analysis. Discussion remains open with the developer following up on whether any findings have been identified. Note: Some text appears reversed/encoded in the original posts.

Summarized with AI on November 14. AI used: claude-sonnet-4-5-20250929.

Hello,

I want to use the API to create custom discount codes. When sending a POST request to “/admin/api/2023-10/price_rules/1660066169167/discount_codes.json” it always returns a 200 and creates nothing. In request header I send the “X-Shopify-Access-Token” Parameter and my body looks like the following:

{
    "discount_code": {
        "code": "TEST1782387162387127"
    }
}

I created the price rule simply with creating a discount code manually and deactivating it. I tried this because creating a price rule via API has the same result. Even when trying the example code, nothing happens.

I am using a custom private app which I created directly in my shop settings.

What am I doing wrong? Any help would be really appreciated.

Thank you in advance.

Best regards,

Alex

Hey @ets_shop

Are you able to capture the request ID from the response headers? I can check out the logs to see what’s going on.

Hey @SBD ,

thank you for your fast reply. I have the following Request ID in header field “X-Request-ID”: d704bc6f-d7be-47fe-86c4-190e80b3efcb

Thank you in advance.

Hey @ets_shop

Thanks for the request ID - That looks like a GET request. Are you able to capture a request ID of the failing POST/creation?

Hey @SBD , thanks for the reply. I am pretty sure that it was the POST request. Here is another request ID: 8bf84edb-74ea-4d34-9336-2cc6f937acb4. A GET request to the same URL results in an Error 400.

Thank you very much.

Hey @ets_shop

Thanks for your patience. Can you please provide another ID? Our logs only retain a few days. Thanks

Hi @SBD , no problem. Here is another ID: ddefe3a0-389a-42a7-aec1-a71977e7935d

Thank you for your help.

Best,

Alex

Hi @SBD , did you already find out something?

Thank you in advance.

Best regards,

Alex