The Shopify store credit API is two Admin GraphQL mutations, storeCreditAccountCredit and storeCreditAccountDebit, plus a storeCreditAccounts connection on each customer. Pass a customer ID and an amount, and Shopify creates the account for that currency if there is none. Neither mutation accepts an idempotency key in version 2026-10, so a retried credit is a second credit.
Any job that issues credit in bulk has to plan for a lost response, whether it is a migration from another platform or a loyalty scheme being converted to store credit. Admin API 2026-10 is the latest stable version in November 2026 and is what the queries here use.
What is in the Shopify store credit API?
A store credit account holds a balance in one currency and has one owner: a Customer, or a CompanyLocation for B2B. A customer can hold several accounts, one per currency.
The storeCreditAccountCredit reference takes an id and a creditInput. The id can be the account’s own ID or the owner’s. Given an owner ID, Shopify “automatically creates an account if one doesn’t exist for the specified currency”, so a first import never creates accounts itself.
In 2026-10 the input has three fields. creditAmount is a MoneyInput, a decimal string with a currency code. expiresAt is optional. notify defaults to false, and for a migration it should stay there unless you want every customer emailed halfway through the import.
Crediting needs the write_store_credit_account_transactions scope. Reading accounts needs read_store_credit_accounts, and reading their transactions needs read_store_credit_account_transactions.
Before issuing anything, ask the shop whether credit can be spent and what the customer already holds:
query StoreCreditCheck($id: ID!) {
storeCreditConfiguration {
storeCreditEnabled
}
customer(id: $id) {
storeCreditAccounts(first: 5) {
nodes {
id
balance {
amount
currencyCode
}
}
}
}
}
storeCreditEnabled reports whether store credit is enabled for customers at checkout. Shopify’s store credit help page puts the switch under Settings > Customer accounts and says it is on by default.
Bad input comes back in userErrors with a code. The codes include OWNER_NOT_FOUND, NEGATIVE_OR_ZERO_AMOUNT, UNSUPPORTED_CURRENCY, EXPIRES_AT_IN_PAST and CREDIT_LIMIT_EXCEEDED. On that last one, the reference says only that the limit “can differ depending on the currency of the account”. The help page gives one figure: $15,000 USD on a single customer account.
Why does a retried credit double the balance?
The Admin API has an @idempotent directive. Send a mutation twice with the same key and the second call returns the first one’s result. It works only on mutations whose description says so, and Shopify’s idempotency guide keeps a list, last updated on 2 February 2026: inventory and location mutations, and refundCreate. The store credit mutations are not on it. Their reference pages for 2026-10 and for the 2027-01 release candidate do not mention the directive either.
So when a request times out, you cannot tell whether the credit landed. Send it again and a customer owed 25.00 may hold 50.00. Without a key, Shopify has no way to recognise the second request as a repeat.
Nor can you tag a credit in 2026-10 so that you can look for it later. The input has no reference field, and the transaction records an amount, a createdAt, an event and the balance afterwards.
The 2027-01 release candidate adds a note to both the input and the transaction: merchant-only, up to 5,000 characters, set when the transaction is created and not editable afterwards. That is the place for an import reference once 2027-01 becomes stable on 1 January 2027. Until then, the only evidence that a credit landed is the account’s transaction list, matched on time and amount.
How do you import balances without crediting twice?
Keep a journal on your side. Record that a credit is about to be sent, send it, then record the transaction ID that came back. If the script dies or times out between those two writes, the journal holds a start time and no ID, and the next run asks Shopify before it sends anything.
This script reads a JSON array of { customerId, amount, currency } rows, where customerId is a gid://shopify/Customer/... ID. It expects one row per customer and currency. As well as the three store credit scopes, the token needs read_customers for the lookup.
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
const { SHOP, SHOPIFY_ADMIN_TOKEN } = process.env;
const ENDPOINT = `https://${SHOP}/admin/api/2026-10/graphql.json`;
const JOURNAL = 'store-credit-journal.json';
const CREDIT = `mutation Credit($id: ID!, $creditInput: StoreCreditAccountCreditInput!) {
storeCreditAccountCredit(id: $id, creditInput: $creditInput) {
storeCreditAccountTransaction { id }
userErrors { code message }
}
}`;
const CREDITS_SINCE = `query CreditsSince($id: ID!, $currency: String!, $since: String!) {
customer(id: $id) {
storeCreditAccounts(first: 1, query: $currency) {
nodes {
transactions(first: 50, query: $since) {
nodes {
amount { amount }
... on StoreCreditAccountCreditTransaction { id }
}
}
}
}
}
}`;
async function admin(query, variables) {
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': SHOPIFY_ADMIN_TOKEN,
},
body: JSON.stringify({ query, variables }),
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { data, errors } = await res.json();
if (errors) throw new Error(JSON.stringify(errors));
return data;
}
const journal = existsSync(JOURNAL) ? JSON.parse(readFileSync(JOURNAL, 'utf8')) : {};
const save = () => writeFileSync(JOURNAL, JSON.stringify(journal, null, 2));
// Did a credit for this row land after the first attempt started?
async function findCredit(row, startedAt) {
// Five minutes of slack for a local clock that runs ahead of Shopify's.
const since = new Date(Date.parse(startedAt) - 5 * 60_000).toISOString();
const data = await admin(CREDITS_SINCE, {
id: row.customerId,
currency: `currency_code:${row.currency}`,
since: `type:credit created_at:>='${since}'`,
});
const account = data.customer?.storeCreditAccounts.nodes[0];
return account?.transactions.nodes.find(
(t) => t.id && Number(t.amount.amount) === Number(row.amount),
)?.id;
}
const rows = JSON.parse(readFileSync(process.argv[2], 'utf8'));
for (const row of rows) {
const entry = (journal[`${row.customerId}|${row.currency}`] ??= {});
if (entry.transactionId || entry.error) continue;
if (entry.startedAt) {
// An earlier run sent this credit and never saw the answer. Ask first.
entry.transactionId = await findCredit(row, entry.startedAt);
if (entry.transactionId) {
save();
continue;
}
} else {
entry.startedAt = new Date().toISOString();
save();
}
const { storeCreditAccountCredit: result } = await admin(CREDIT, {
id: row.customerId,
creditInput: {
creditAmount: { amount: row.amount, currencyCode: row.currency },
notify: false,
},
});
if (result.userErrors.length) entry.error = result.userErrors[0].code;
else entry.transactionId = result.storeCreditAccountTransaction.id;
save();
}
Run it with SHOP and SHOPIFY_ADMIN_TOKEN set: node import-store-credit.mjs balances.json. Any thrown error stops the run, because carrying on past an unknown outcome is how a double gets through. A row that comes back with a userErrors code is journalled and skipped on later runs, since the same input fails the same way until someone fixes the row and deletes its entry.
The lookup uses two documented filters on the account’s transactions connection, type:credit and a created_at bound, then matches on amount because 2026-10 offers nothing better. That is why the input needs one row per customer and currency. Two rows that each credit the same customer 10.00 cannot be told apart afterwards, so add them together first. A member of staff who issues the same amount to the same customer by hand during the run would be mistaken for the import in the same way.
Requests go one at a time. That is slow for a long list, and it keeps every unknown outcome down to a single row.
What does a customer need before they can spend it?
An account they can sign in to. The StoreCreditAccount reference says the balance “is redeemable at checkout only when the owner is authenticated via new customer accounts authentication”, and the help page says store credit is not available for legacy customer accounts. The customer record has to exist before the credit does, under the email address that person will sign in with. Our guide to moving customer records and consent onto Shopify covers that half of the job.
Merge duplicate customer records before crediting any of them, because holding store credit blocks a merge. The CustomerMergeErrorFieldType enum lists the hard blockers that prevent a merge, and STORE_CREDIT (“The customer has store credit”) is one of them.
The credit also has to be in the right currency. According to the help page, a customer with credit in several currencies sees only the balance that matches the checkout currency. Credit issued in GBP does nothing for someone who checks out in EUR, so issue it in the currency that customer pays in.
Tell the merchant two things from the same page before launch. Store credit cannot be applied to a draft order or an edited order from the admin, and it pays towards the first order of a subscription but not the recurring bills.
To show the balance in a theme, Liquid exposes it on the customer:
{% if customer.store_credit_account %}
<p>Store credit: {{ customer.store_credit_account.balance | money }}</p>
{% endif %}
customer.store_credit_account returns the account in the currency of the customer’s current context, or nil when they have none in that currency. A headless storefront reads the balance from the Customer Account API, which has its own StoreCreditAccount object behind the customer_read_store_credit_accounts scope.
How do debits and expiry behave?
storeCreditAccountDebit takes a debitAmount and fails with INSUFFICIENT_FUNDS when the balance is short. It is how you undo an over-credit. It has no idempotency key either, so the same journal applies.
A credit with expiresAt set expires without any further call. The help page says that happens at the end of the day in the store’s timezone, wherever the customer is. Shopify records it as an expiration transaction, which the transactions filter finds with type:expiration, and the reference notes that debits “will always spend the soonest expiring credit first”. If the old platform’s balances carried expiry dates, pass them through and have the lookup compare expiresAt as well as the amount.
What we would do
Run the import before launch, from a list already summed to one row per customer and currency, with notify off. Keep the journal file as the audit trail, check a handful of customers in the admin, and let the merchant send one email of their own saying where the credit now lives. When 2027-01 is the stable version, write the old platform’s reference into note and match on that.
Store credit is the wrong home for balances that do not belong to a person. Vouchers that get forwarded to a friend, or a credit code printed on a receipt, should become gift cards, which are redeemed by code. That route is in our post on migrating gift card codes and balances.
Whoooop moves stores onto Shopify with their products, customers and URLs carried across. Our Shopify development page describes that work.