Version: 2024-10
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 giftCardDebit($id: ID!, $debitInput: GiftCardDebitInput!) { giftCardDebit(id: $id, debitInput: $debitInput) { giftCardDebitTransaction { id amount { amount currencyCode } processedAt note giftCard { id balance { amount currencyCode } } } userErrors { message field code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/GiftCard/411106674\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"10\",\n \"currencyCode\": \"USD\"\n },\n \"processedAt\": \"2024-09-09T12:48:33-04:00\",\n \"note\": \"A note.\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation giftCardDebit($id: ID!, $debitInput: GiftCardDebitInput!) {\n giftCardDebit(id: $id, debitInput: $debitInput) {\n giftCardDebitTransaction {\n id\n amount {\n amount\n currencyCode\n }\n processedAt\n note\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/GiftCard/411106674\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"10\",\n \"currencyCode\": \"USD\"\n },\n \"processedAt\": \"2024-09-09T12:48:33-04:00\",\n \"note\": \"A note.\"\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 giftCardDebit($id: ID!, $debitInput: GiftCardDebitInput!) {\n giftCardDebit(id: $id, debitInput: $debitInput) {\n giftCardDebitTransaction {\n id\n amount {\n amount\n currencyCode\n }\n processedAt\n note\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/GiftCard/411106674\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"10\",\n \"currencyCode\": \"USD\"\n },\n \"processedAt\": \"2024-09-09T12:48:33-04:00\",\n \"note\": \"A note.\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation giftCardDebit($id: ID!, $debitInput: GiftCardDebitInput!) {\n giftCardDebit(id: $id, debitInput: $debitInput) {\n giftCardDebitTransaction {\n id\n amount {\n amount\n currencyCode\n }\n processedAt\n note\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/GiftCard/411106674\",\n \"debitInput\" => [\n \"debitAmount\" => [\n \"amount\" => \"10\",\n \"currencyCode\" => \"USD\",\n ],\n \"processedAt\" => \"2024-09-09T12:48:33-04:00\",\n \"note\" => \"A note.\",\n ],\n];\n\n$response = $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 giftCardDebit($id: ID!, $debitInput: GiftCardDebitInput!) {\n giftCardDebit(id: $id, debitInput: $debitInput) {\n giftCardDebitTransaction {\n id\n amount {\n amount\n currencyCode\n }\n processedAt\n note\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/GiftCard/411106674\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"10\",\n \"currencyCode\": \"USD\"\n },\n \"processedAt\": \"2024-09-09T12:48:33-04:00\",\n \"note\": \"A note.\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation giftCardDebit($id: ID!, $debitInput: GiftCardDebitInput!) {\n giftCardDebit(id: $id, debitInput: $debitInput) {\n giftCardDebitTransaction {\n id\n amount {\n amount\n currencyCode\n }\n processedAt\n note\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n}"
input: { "id": "gid://shopify/GiftCard/411106674", "debitInput": { "debitAmount": { "amount": "10", "currencyCode": "USD" }, "processedAt": "2024-09-09T12:48:33-04:00", "note": "A note." } }
response: { "data": { "giftCardDebit": { "giftCardDebitTransaction": { "id": "gid://shopify/GiftCardDebitTransaction/1064273912", "amount": { "amount": "-10.0", "currencyCode": "USD" }, "processedAt": "2024-09-09T16:48:33Z", "note": "A note.", "giftCard": { "id": "gid://shopify/GiftCard/411106674", "balance": { "amount": "15.0", "currencyCode": "USD" } } }, "userErrors": [] } } }