For the complete documentation index, see llms.txt. This page is also available as Markdown.

Merchant API: keys & endpoints

This article's section starts at 1:39 in the video.

The Merchant API lets your own backend read your cashback configuration, trigger rewards (birthdays collected in your mobile app, social follows verified by your own system, fully custom rewards), and move credit directly with no program behind it. This article covers key management, authentication, and all seven endpoints.

Prerequisites

  • A DollarBack plan that includes API access. On other plans, Developer API shows "Developer API is available on a higher plan" with an Upgrade plan button, and you can't generate or rotate a key. See Plans, usage & overage billing.

  • A server-side environment to call the API from. The key must never ship in client or browser code.

  • For the birthday, social, and custom endpoints: a matching cashback config of that type, enabled (see Custom rewards via API).

  • The credit and debit endpoints need no config: they move credit directly.

Manage your API key

The key lives on the REST API page, two steps in:

  1. Open DollarBack admin β†’ Settings β†’ Developer API and click Manage.

  2. You land on Developer API, a hub with two cards: REST API β€” everything in this article β€” and Storefront API, which needs no key (Storefront window API). Open REST API.

  3. Click Generate API key. The key appears straight away, masked: use the eye button to Show key / Hide key, and Copy to put it on your clipboard.

The Developer API page with two cards, REST API marked "API key active" and Storefront API marked "No API key required", each with a View docs link.
Developer API has two parts: the REST API for your server and the Storefront API for your theme.

Once a key exists, that page leads with it, then documents Authentication and Endpoints below. Two fields sit alongside the key:

Field
What it tells you

Created

When the current key was issued. Rotating resets it.

Last used

When a request last authenticated with it. Never means no call has ever got through β€” the quickest way to tell a silent integration from a working one.

The REST API key card with a "Server-side only" warning, a masked key, Show and Copy buttons, Created and Last used dates, and a Rotate key row.
The REST API page shows your key, when it was created and last used, and the Rotate control.

This key is not a show-once secret. It stays readable on the page, so Show key recovers it whenever you need it and you never have to keep a copy anywhere but your server's environment variables.

Rotating a key

Rotate issues a new key and invalidates the old one the moment you click it. There is no confirmation dialog and no overlap window where both keys work, so any server still sending the old key starts getting 401 unauthorized immediately. Have the new value ready to deploy before you rotate, not after.

Authentication

Every request needs two headers:

A missing or wrong key returns 401 {"error": "unauthorized"}. Unexpected server errors return 500 {"error": "internal"}.

A dark code block with the base URL and the X-DollarBack-Shop, Authorization and Content-Type headers, and a list of seven GET and POST endpoints with Copy buttons.
The base URL, the two required headers and all seven endpoints are listed on the REST API page.

GET /api/v1/merchant/config

Returns your enabled cashback configurations and tier setup. Use it to discover config IDs for the POST endpoints and to render program details in your own UI. The DollarBack admin doesn't display config IDs, so this endpoint is where you find them.

Success (200):

Only enabled programs are listed. Each entry in configurations is the program's saved settings. The fields you'll use most:

Field
Notes

id

The config ID to send as configId on the POST endpoints.

configType

purchase, birthday, social, custom, and so on.

title

The program name.

enabled

Always true here.

cashbackType, cashbackValue

percentage, fixed or orderGoal, and the amount.

rewardKind

store_credit or discount_code.

expiresAfter

Days until issued credit expires.

startDate, endDate

The program's dates, when set.

birthdayTrigger, birthdayLimit, birthdayCooldownDays

Birthday programs only.

socialLabel, socialUrl

Social programs only.

Each entry in tiers.tiers has id, name, isEnabled, priority, configIds (the programs linked to that tier) and multiplier.

The response is cached for about a minute, so a program you have just enabled or edited can take up to a minute to appear.

The endpoint URLs (with your app host filled in) are listed with Copy buttons in the Endpoints section of the REST API page.

POST /api/v1/merchant/birthday

Submits a customer's birthday and schedules the birthday credit, the API equivalent of the widget's birthday form.

Body field
Type
Notes

customerId

string or number

The Shopify customer ID.

birthday

object

{ "day": 14, "month": 3, "year": 1992 }

configId

string

The birthday config's ID (from GET /config).

currency

string

Required. Currency to credit in, e.g. "USD".

Success (200):

Errors: 400 {"error": "missing_fields: ..."} (including a missing currency), {"error": "invalid_json"} or {"error": "invalid_birthday"}, 404 {"error": "Birthday config not found"}.

The birthday endpoint only schedules the gift: the credit itself lands on nextCreditDate.

POST /api/v1/merchant/social

Claims a social-follow reward for a customer. Use it when your own system verifies the follow.

Body field
Type
Notes

customerId

string or number

The Shopify customer ID.

socialUrl

string

The social link the customer followed.

configId

string

The social config's ID.

currency

string

Required. Currency to credit in, e.g. "USD".

The response waits for the outcome, so a 200 means the reward has landed. For a store credit reward:

A program that pays a discount code answers {"success": true, "rewardKind": "discount_code", "code": "...", "creditAmount": ..., "currency": "USD"}. Each customer is rewarded once per social URL: a repeat claim for the same socialUrl answers duplicate: true and moves nothing.

If a discount-code program issues no code, the claim is skipped and the URL stays claimable: {"success": true, "skipped": true, "reason": "issuance_cap_reached"} when the customer already holds as many codes from that program as it allows, or "reason": "rule_unavailable" when the reward-marketplace rule behind it is off, deleted, or not available for cashback.

Errors: 400 {"error": "missing_fields: ..."} (including a missing currency) or {"error": "invalid_json"}, 400 {"error": "invalid_config", "reason": "no_matching_config"} when the config ID doesn't match an enabled social program, 400 {"error": "operation_failed", "message": "..."} when Shopify refuses the credit, 502 {"error": "...", "message": "..."} when the reward run ends in a failure that isn't one of the above, and 503 {"error": "unavailable", "runId": "..."} (see below).

POST /api/v1/merchant/custom

Dispatches a custom (API-only) reward, the endpoint behind Custom rewards via API. Credit any behavior you can detect: reviews, referral milestones, offline events.

Body field
Type
Notes

configId

string

Must be a custom-type config that is enabled.

customerId

string or number

The Shopify customer ID.

currency

string

Required. Currency to credit in, e.g. "USD".

idempotencyKey

string

Optional. A retry with the same key joins the first grant instead of granting twice.

The response waits for the outcome. For a store credit reward:

A discount-code program answers {"success": true, "requestId": "...", "rewardKind": "discount_code", "code": "..."}. If the customer has reached the program's per-customer limit, nothing moves and you get {"success": true, "requestId": "...", "skipped": true, "reason": "frequency_limit", "count": 3, "limit": 3}. A discount-code program that issues no code answers {"success": true, "requestId": "...", "skipped": true, "reason": "issuance_cap_reached" | "rule_unavailable"}, with the same meanings as on /social. Full example and walkthrough: Custom rewards via API.

Errors: 400 {"error": "missing_fields: ..."} (including a missing currency), {"error": "invalid_json"}, {"error": "invalid_config", "reason": "not_found" | "not_custom" | "disabled" | "not_scheduled"}, {"error": "operation_failed", "message": "..."} when Shopify refuses the credit, 502 {"error": "...", "message": "..."} when the reward run ends in any other failure, and 503 {"error": "unavailable", "runId": "..."} (see below). The invalid_config reason tells you whether the config ID is wrong, isn't a custom config, is turned off, or is outside its start and end dates.

503 unavailable on /social, /custom, /credit or /debit means the request didn't finish within about 25 seconds. It may still complete. Retry the same request: for /custom, send the same idempotencyKey, so the retry joins the first grant (duplicate: true) instead of granting twice. A repeated social claim is safe on its own, because a customer is rewarded only once per socialUrl. For /credit and /debit, retry with the same idempotencyKey: the retry waits for the first run and answers its result.

POST /api/v1/merchant/credit

Credits a customer directly, with no cashback program involved. Use it for goodwill gestures, support resolutions, or any credit your own system decides on. Like /social and /custom, it is synchronous: the response tells you whether the money actually moved, and hands back the transaction ID and the new balance.

Body field
Type
Required
Notes

customerId

string or number

Yes

The numeric Shopify customer ID.

amount

number

Yes

Greater than 0, expressed in currency. Anything above 1,000,000 is rejected.

currency

string

Yes

The currency amount is in, e.g. "USD". Converted to your shop currency for the credit log.

reason

string

No

Shown in the credit log and in the customer's email.

expiryInDays

number

No

Whole days until the credit expires. Default 0 β€” the credit never expires.

expiresAt

string

No

An exact expiry instead of expiryInDays, in ISO 8601: "2027-02-28" (the end of that day), "2027-02-28T18:00" (that time in your store's time zone) or "2027-02-28T18:00:00Z" (that exact moment). It must be at least an hour in the future. Send either expiryInDays or expiresAt, not both; otherwise the call returns 400 with invalid_expiry.

notify

boolean

No

Default true β€” send the customer the Store Credit Credited email (Store Credit Debited on /debit), if that template is enabled.

sendToIntegrations

boolean

No

Default true β€” forward the event to Klaviyo, Omnisend, Mailchimp, and Flow.

idempotencyKey

string

No

A retry with the same key never moves money twice.

Success (200):

Errors: 400 {"error": "missing_fields: ..."}, {"error": "invalid_amount: ..."}, {"error": "invalid_expiry", "message": "..."}, {"error": "invalid_json"}, or {"error": "operation_failed", "message": "..."} when Shopify itself refuses the movement, and 503 {"error": "unavailable", "message": "...", "runId": "..."} when the request didn't finish in time (see the hint above).

Send an idempotencyKey on every call β€” something stable from your own system, like a support ticket or refund ID. If a request times out and you retry it, DollarBack recognises the key, answers duplicate: true and credits nothing. Nothing moves on a duplicate. The response repeats the original transactionId, and balance is the customer's current balance in currency, read live at the time of the retry. Keys are scoped to your shop, so they only need to be unique within your own store.

POST /api/v1/merchant/debit

Removes store credit from a customer. Body, headers, and response are identical to /credit, except expiryInDays and expiresAt are ignored.

Success (200):

Debiting more than the customer holds fails rather than pushing the balance negative: you get 400 {"error": "operation_failed", "message": "..."} carrying Shopify's own message, and nothing moves. If you need to take "up to" whatever someone has, read GET /balance first and debit what it reports.

GET /api/v1/merchant/balance

Reads a customer's current store credit. Use it before a debit, to show a balance in your own app or portal, or to reconcile against your records.

Shopify keeps one store credit account per currency, so a customer who has earned in more than one currency has more than one balance. The endpoint returns all of them and is never cached.

Query parameter
Required
Notes

customerId

Yes

The numeric Shopify customer ID. A gid:// prefix is rejected.

currency

No

Narrow the response to a single account, e.g. USD. Case-insensitive.

Success (200):

A customer who holds no store credit returns "balances": [] with a 200, not an error. Treat an empty array as a zero balance.

Errors: 400 {"error": "missing_fields: customerId is required"}, 400 {"error": "invalid_customer_id"} when the ID isn't numeric, and 404 {"error": "customer_not_found"} when no such customer exists in your store.

Read the currency, don't assume it. balances is an array in no guaranteed order, so pick the entry whose currency matches the one you care about rather than taking the first. formatted is a convenience for display only β€” do arithmetic on amount.

Verify it works

Call GET /config or GET /balance first: a 200 confirms your key and headers, and neither one writes anything. Then fire one POST for a test customer and check DollarBack admin β†’ Analytics β†’ Activity for the credit. /social, /custom, /credit and /debit are synchronous: a 200 with duplicate: false means the reward has already landed, and the response shows it. /birthday only schedules the gift for the customer's next birthday date.

Common issues

  • 401 unauthorized: wrong or rotated key, or a missing X-DollarBack-Shop header.

  • 400 missing_fields: currency is required: the birthday, social, and custom endpoints need currency. Older examples used customerCurrency, which is not read.

  • invalid_config on /custom: the config ID isn't a custom config, or the config is disabled or outside its dates.

  • skipped: true with reason: "frequency_limit" on /custom: the customer has reached the program's limit. Nothing moved.

  • 503 unavailable: the request didn't finish in time. Retry the same request (same idempotencyKey on /custom, /credit and /debit).

  • 502 on /social or /custom: the reward run failed for a reason other than a bad config or a Shopify refusal. The error and message fields say why.

  • You can't generate a key, or Developer API asks you to upgrade: your plan doesn't include API access.

  • A birthday was submitted but no credit appears: the gift is scheduled for nextCreditDate; check Activity: credit logs & scheduled rewards.

  • operation_failed on /debit: the customer's balance is smaller than amount. Nothing moved; call GET /balance and debit what they actually hold.

  • balances: [] from /balance: the customer exists but has never held store credit on your store. That's a zero balance, not a failure β€” a missing customer returns 404 customer_not_found instead.

  • duplicate: true in the response: an earlier call with the same idempotencyKey already succeeded. That's the retry working as intended, not an error.

Last updated