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 giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } }\",\n \"variables\": {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\",\n \"recipientAttributes\": {\n \"id\": \"gid://shopify/Customer/743592264\",\n \"message\": \"Happy Birthday!\",\n \"preferredName\": \"Dad\",\n \"sendNotificationAt\": \"2024-10-01T12:00:00Z\"\n }\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 initialValue {\n amount\n }\n customer {\n id\n }\n recipientAttributes {\n recipient {\n id\n }\n message\n preferredName\n sendNotificationAt\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\",\n \"recipientAttributes\": {\n \"id\": \"gid://shopify/Customer/743592264\",\n \"message\": \"Happy Birthday!\",\n \"preferredName\": \"Dad\",\n \"sendNotificationAt\": \"2024-10-01T12:00:00Z\"\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 giftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n giftCard {\n id\n initialValue {\n amount\n }\n customer {\n id\n }\n recipientAttributes {\n recipient {\n id\n }\n message\n preferredName\n sendNotificationAt\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\",\n \"recipientAttributes\": {\n \"id\": \"gid://shopify/Customer/743592264\",\n \"message\": \"Happy Birthday!\",\n \"preferredName\": \"Dad\",\n \"sendNotificationAt\": \"2024-10-01T12:00:00Z\"\n }\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 giftCardCreate($input: GiftCardCreateInput!) {\n giftCardCreate(input: $input) {\n giftCard {\n id\n initialValue {\n amount\n }\n customer {\n id\n }\n recipientAttributes {\n recipient {\n id\n }\n message\n preferredName\n sendNotificationAt\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"initialValue\" => \"100.0\",\n \"customerId\" => \"gid://shopify/Customer/331283560\",\n \"recipientAttributes\" => [\n \"id\" => \"gid://shopify/Customer/743592264\",\n \"message\" => \"Happy Birthday!\",\n \"preferredName\" => \"Dad\",\n \"sendNotificationAt\" => \"2024-10-01T12:00:00Z\",\n ],\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 initialValue {\n amount\n }\n customer {\n id\n }\n recipientAttributes {\n recipient {\n id\n }\n message\n preferredName\n sendNotificationAt\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"initialValue\": \"100.0\",\n \"customerId\": \"gid://shopify/Customer/331283560\",\n \"recipientAttributes\": {\n \"id\": \"gid://shopify/Customer/743592264\",\n \"message\": \"Happy Birthday!\",\n \"preferredName\": \"Dad\",\n \"sendNotificationAt\": \"2024-10-01T12:00:00Z\"\n }\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 initialValue {\n amount\n }\n customer {\n id\n }\n recipientAttributes {\n recipient {\n id\n }\n message\n preferredName\n sendNotificationAt\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n}"
input: { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560", "recipientAttributes": { "id": "gid://shopify/Customer/743592264", "message": "Happy Birthday!", "preferredName": "Dad", "sendNotificationAt": "2024-10-01T12:00:00Z" } } }
response: { "data": { "giftCardCreate": { "giftCard": { "id": "gid://shopify/GiftCard/1063936324", "initialValue": { "amount": "100.0" }, "customer": { "id": "gid://shopify/Customer/331283560" }, "recipientAttributes": { "recipient": { "id": "gid://shopify/Customer/743592264" }, "message": "Happy Birthday!", "preferredName": "Dad", "sendNotificationAt": "2024-10-01T12:00:00Z" } }, "userErrors": [] } } }
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 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 = <<<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\n$variables = [\n \"input\" => [\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-10/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 = <<<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\n$variables = [\n \"input\" => [\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": [] } } }