← Back to blog

The Shopify Discount Code API: Generate, Track and Recycle Codes From Your Own Stack

Pixoo Team

Pixoo Team

E-commerce Tips & Multi-Currency Strategies

The Shopify Discount Code API: Generate, Track and Recycle Codes From Your Own Stack

The Shopify Discount Code API: Generate, Track and Recycle Codes From Your Own Stack

Key takeaways

  • The Pixoo API lets you generate, track and recycle Shopify discount codes from your own backend, not just from the admin
  • Mint a unique code synchronously and get it back in the same response, so a new signup can receive its code in one request
  • Recycle redeemed codes automatically so a rotating discount never hits Shopify's per-discount ceiling
  • Subscribe to webhooks (code redeemed, batch completed, gift redeemed) and react in real time
  • Codes stay multi-currency: every code carries the right value in every market you sell to
  • Available on the Enterprise plan, with full documentation at pixoo.app/developers

The problem: your discount codes are trapped in the admin

Discount codes are one of the most useful things a Shopify store owns, and one of the hardest to automate. You can create them by hand in the admin, export a CSV, maybe paste a list into an email tool. But the moment you want a code to appear somewhere else, in your CRM, your loyalty app, your helpdesk, a landing page, the trail goes cold. Automation stops at the edge of the admin.

That is the gap the Pixoo API closes. Anything you already do with Pixoo discounts, you can now do from your own code, on your own schedule, triggered by your own events.

What the Pixoo API actually does

A quick tour of the surface, so you can see where it fits:

  • Generate unique codes on demand. Ask for 1 to 10 codes and get them back in the response, synchronously. No polling, no waiting.
  • Generate in bulk. Queue up to 100,000 codes on a single discount and poll the batch until it is ready.
  • Recycle codes. Delete redeemed codes so the discount never fills up (more on this below, it is the quiet hero).
  • Create discounts. Spin up any of the four Pixoo discount types (product, order, shipping, buy X get Y) straight from an API call.
  • Find a discount by title. Look one up by name, the same way your team thinks about it, then act on it.
  • React to events. Subscribe to webhooks and get a signed payload the instant a code is redeemed or a batch finishes.

You do all of it with a single API key, over plain HTTPS. If you can send a POST request, you can use it.

The flagship: a unique code, minted the moment you need it

Here is the request most teams reach for first. A shopper joins your list, your backend calls one endpoint, and a fresh code comes straight back:

curl -X POST "https://api.pixoo.app/api/v1/discounts/1234567890/codes" \
  -H "Authorization: Bearer pixoo_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "quantity": 1, "prefix": "WELCOME-" }'
{ "codes": ["WELCOME-3WFQS8P6N0CO"] }

Because it is synchronous, the code is in your hands in the same request. Your welcome email can carry a genuinely unique code, not a shared one that leaks across the internet by lunchtime. One shopper, one code, issued the second they earn it.

Five things teams automate with it

  1. Welcome codes for new subscribers. New email or SMS signup, unique code, first message. No shared code to screenshot and share.
  2. Loyalty rewards. A shopper hits their fifth order, your backend mints a thank-you code and sends it.
  3. Per-partner codes. Give every influencer or affiliate their own code from a signup form, and track each one on its own.
  4. Make-good codes from support. Your helpdesk resolves a ticket and hands the customer a one-time code, without an agent ever touching the Shopify admin.
  5. Automatic cleanup. Recycle redeemed codes on a schedule so a long-running campaign stays healthy.

Never hit the code ceiling again

Bulk discounts have a limit on how many codes they can hold. On a rotating campaign that mints new codes every day, that ceiling creeps closer with every redemption, because used codes keep taking up space.

The API turns that from a problem into a background task. Listen for the code.redeemed webhook, collect the codes that have been used, and delete them:

curl -X POST "https://api.pixoo.app/api/v1/discounts/1234567890/code-deletions" \
  -H "Authorization: Bearer pixoo_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "codes": ["WELCOME-3WFQS8P6N0CO"] }'

The discount frees up capacity as fast as it is used, and your campaign runs forever without anyone watching a counter.

Built for real time: webhooks

Polling is fine, but reacting is better. Subscribe to the three events Pixoo emits:

  • code.redeemed when a shopper uses one of your codes
  • code_batch.completed when a bulk generation finishes
  • gift.redeemed when a buy X get Y gift is claimed

Each delivery is signed, so you can verify it really came from Pixoo. Point it at your own endpoint and wire the redemption straight into whatever comes next, a thank-you flow, a fraud check, a loyalty tally. If your receiver ever goes down, a pollable events feed lets you catch up on anything you missed.

Still multi-currency, all the way through

This is the part other tools miss. A Pixoo code is not a flat number, it carries the right value in every market you sell to. A code worth ten euros in France is worth the amount you set for pounds in the UK, automatically. The API keeps that intact: the codes you generate over the API behave exactly like the ones you build in the admin, currency by currency. You get automation without giving up the reason you chose Pixoo in the first place.

How it works, in sixty seconds

  • Auth. One key, sent as Authorization: Bearer pixoo_live_.... Call GET /whoami to check a key is wired correctly.
  • Rate limits. Generous, with clear headers so you always know where you stand.
  • Idempotency. Send an Idempotency-Key on writes and a retry can never create a duplicate discount or a second batch.
  • Honest errors. Every error comes back as clean JSON with a code you can branch on.

The full reference, with copy-paste examples in curl, JavaScript and Python, lives at pixoo.app/developers.

Getting started

The API ships with the Enterprise plan. Once you are on it:

  1. Open Integrations, then API in your Pixoo admin.
  2. Create a key (read-only or read and write, your call).
  3. Head to the developer docs and make your first call.

Your discount codes have been sitting in the admin waiting for this. Go wire them into everything else.