Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { userErrors { message field } giftCard { id expiresOn note initialValue { amount } customer { id } } giftCardCode } }\",\n \"variables\": {\n \"input\": {\n \"initialValue\": \"27.84\",\n \"customerId\": \"gid://shopify/Customer/743592264\",\n \"note\": \"Refund for Order #1\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation giftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n note\n initialValue {\n amount\n }\n customer {\n id\n }\n }\n giftCardCode\n }\n }`,\n \"variables\": {\n \"input\": {\n \"initialValue\": \"27.84\",\n \"customerId\": \"gid://shopify/Customer/743592264\",\n \"note\": \"Refund for Order #1\"\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 giftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n note\n initialValue {\n amount\n }\n customer {\n id\n }\n }\n giftCardCode\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"initialValue\": \"27.84\",\n \"customerId\": \"gid://shopify/Customer/743592264\",\n \"note\": \"Refund for Order #1\"\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 = <<[\n \"initialValue\" => \"27.84\",\n \"customerId\" => \"gid://shopify/Customer/743592264\",\n \"note\" => \"Refund for Order #1\",\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 giftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n note\n initialValue {\n amount\n }\n customer {\n id\n }\n }\n giftCardCode\n }\n }`,\n {\n variables: {\n \"input\": {\n \"initialValue\": \"27.84\",\n \"customerId\": \"gid://shopify/Customer/743592264\",\n \"note\": \"Refund for Order #1\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation giftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n note\n initialValue {\n amount\n }\n customer {\n id\n }\n }\n giftCardCode\n }\n}"
input: { "input": { "initialValue": "27.84", "customerId": "gid://shopify/Customer/743592264", "note": "Refund for Order #1" } }
response: { "data": { "giftCardCreate": { "userErrors": [], "giftCard": { "id": "gid://shopify/GiftCard/1063936322", "expiresOn": null, "note": "Refund for Order #1", "initialValue": { "amount": "27.84" }, "customer": { "id": "gid://shopify/Customer/743592264" } }, "giftCardCode": "a5bhbh645b32934f" } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation GiftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id balance { amount currencyCode } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation GiftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\"\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 GiftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\"\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 = <<[\n \"initialValue\" => \"100.0\",\n \"customerId\" => \"gid://shopify/Customer/331283560\",\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 GiftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation GiftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n giftCard {\n id\n balance {\n amount\n currencyCode\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560" } }
response: { "data": { "giftCardCreate": { "giftCard": { "id": "gid://shopify/GiftCard/1063936323", "balance": { "amount": "100.0", "currencyCode": "USD" } }, "userErrors": [] } } }