# storeCreditAccountDebit - admin-graphql - MUTATION Version: 2024-10 ## Description Creates a debit transaction that decreases the store credit account balance by the given amount. ### Access Scopes `write_store_credit_account_transactions` access scope. ## Arguments * [debitInput](/docs/api/admin-graphql/2024-10/input-objects/StoreCreditAccountDebitInput): StoreCreditAccountDebitInput! - The input fields for a store credit account debit transaction. * [id](/docs/api/admin-graphql/2024-10/scalars/ID): ID! - The ID of the store credit account or the ID of the account owner. ## Returns * [storeCreditAccountTransaction](/docs/api/admin-graphql/2024-10/objects/StoreCreditAccountDebitTransaction): StoreCreditAccountDebitTransaction The store credit account transaction that was created. * [userErrors](/docs/api/admin-graphql/2024-10/objects/StoreCreditAccountDebitUserError): StoreCreditAccountDebitUserError! The list of errors that occurred from executing the mutation. ## Examples ### Debit a store credit account by account ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) { storeCreditAccountDebit(id: $id, debitInput: $debitInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/StoreCreditAccount/316863792", "debitInput": { "debitAmount": { "amount": "9.99", "currencyCode": "USD" } } } #### Graphql Response { "data": { "storeCreditAccountDebit": { "storeCreditAccountTransaction": { "amount": { "amount": "-9.99", "currencyCode": "USD" }, "account": { "id": "gid://shopify/StoreCreditAccount/316863792", "balance": { "amount": "1.12", "currencyCode": "USD" } } }, "userErrors": [] } } } ### Debit a store credit account by customer ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) { storeCreditAccountDebit(id: $id, debitInput: $debitInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Customer/544365967", "debitInput": { "debitAmount": { "amount": "9.99", "currencyCode": "USD" } } } #### Graphql Response { "data": { "storeCreditAccountDebit": { "storeCreditAccountTransaction": { "amount": { "amount": "-9.99", "currencyCode": "USD" }, "account": { "id": "gid://shopify/StoreCreditAccount/316863792", "balance": { "amount": "1.12", "currencyCode": "USD" } } }, "userErrors": [] } } } ### Debiting an amount that exceeds the account balance returns an error Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) { storeCreditAccountDebit(id: $id, debitInput: $debitInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/StoreCreditAccount/316863792", "debitInput": { "debitAmount": { "amount": "100.00", "currencyCode": "USD" } } } #### Graphql Response { "data": { "storeCreditAccountDebit": { "storeCreditAccountTransaction": null, "userErrors": [ { "message": "The store credit account does not have sufficient funds to satisfy the request", "field": [ "debitInput", "debitAmount", "amount" ] } ] } } }