storeCreditAccountCredit
Requires access scope.
Creates a credit transaction that increases the store credit account balance by the given amount. This operation will create an account if one does not already exist. A store credit account owner can hold multiple accounts each with a different currency. Use the most appropriate currency for the given store credit account owner.
Arguments
- Anchor to creditInputcredit•
Input StoreCredit requiredAccount Credit Input! The input fields for a store credit account credit transaction.
- •ID!required
The ID of the store credit account or the ID of the account owner.
Anchor to StoreCreditAccountCreditPayload returnsStoreCreditAccountCreditPayload returns
- Anchor to storeCreditAccountTransactionstore•
Credit Account Transaction The store credit account transaction that was created.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
- Credit an amount to a store credit account by customer ID
- Credit an expiring amount to a store credit account by account ID
- Crediting a negative amount returns an error
- Crediting an amount that exceeds the account limit returns an error
- storeCreditAccountCredit reference
Examples
mutation storeCreditAccountCredit($id: ID!, $creditInput: StoreCreditAccountCreditInput!) {
storeCreditAccountCredit(id: $id, creditInput: $creditInput) {
storeCreditAccountTransaction {
amount {
amount
currencyCode
}
account {
id
balance {
amount
currencyCode
}
}
}
userErrors {
message
field
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation storeCreditAccountCredit($id: ID!, $creditInput: StoreCreditAccountCreditInput!) { storeCreditAccountCredit(id: $id, creditInput: $creditInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }",
"variables": {
"id": "gid://shopify/Customer/544365967",
"creditInput": {
"creditAmount": {
"amount": "49.99",
"currencyCode": "USD"
}
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation storeCreditAccountCredit($id: ID!, $creditInput: StoreCreditAccountCreditInput!) {
storeCreditAccountCredit(id: $id, creditInput: $creditInput) {
storeCreditAccountTransaction {
amount {
amount
currencyCode
}
account {
id
balance {
amount
currencyCode
}
}
}
userErrors {
message
field
}
}
}`,
{
variables: {
"id": "gid://shopify/Customer/544365967",
"creditInput": {
"creditAmount": {
"amount": "49.99",
"currencyCode": "USD"
}
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation storeCreditAccountCredit($id: ID!, $creditInput: StoreCreditAccountCreditInput!) {
storeCreditAccountCredit(id: $id, creditInput: $creditInput) {
storeCreditAccountTransaction {
amount {
amount
currencyCode
}
account {
id
balance {
amount
currencyCode
}
}
}
userErrors {
message
field
}
}
}`,
"variables": {
"id": "gid://shopify/Customer/544365967",
"creditInput": {
"creditAmount": {
"amount": "49.99",
"currencyCode": "USD"
}
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation storeCreditAccountCredit($id: ID!, $creditInput: StoreCreditAccountCreditInput!) {
storeCreditAccountCredit(id: $id, creditInput: $creditInput) {
storeCreditAccountTransaction {
amount {
amount
currencyCode
}
account {
id
balance {
amount
currencyCode
}
}
}
userErrors {
message
field
}
}
}
QUERY
variables = {
"id": "gid://shopify/Customer/544365967",
"creditInput": {
"creditAmount": {
"amount": "49.99",
"currencyCode": "USD"
}
}
}
response = client.query(query: query, variables: variables)