--- title: giftCardCreate - GraphQL Admin description: Create a gift card. api_version: 2025-10 api_name: admin type: mutation api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/mutations/giftcardcreate md: https://shopify.dev/docs/api/admin-graphql/latest/mutations/giftcardcreate.md --- # gift​Card​Create mutation Requires `write_gift_cards` access scope. Create a gift card. ## Arguments * input [Gift​Card​Create​Input!](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/GiftCardCreateInput) required The input fields to create a gift card. *** ## Gift​Card​Create​Payload returns * gift​Card [Gift​Card](https://shopify.dev/docs/api/admin-graphql/latest/objects/GiftCard) The created gift card. * gift​Card​Code [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The created gift card's code. * user​Errors [\[Gift​Card​User​Error!\]!](https://shopify.dev/docs/api/admin-graphql/latest/objects/GiftCardUserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Create a gift card with a customer and a recipient #### Query ```graphql mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } } ``` #### Variables ```json { "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" } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } }", "variables": { "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" } } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } }`, { variables: { "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" } } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } } QUERY variables = { "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 = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } }`, "variables": { "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 ```json { "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": [] } } ``` * ### Create a non-expiring gift card with a generated code for a customer #### Query ```graphql mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { userErrors { message field } giftCard { id expiresOn note initialValue { amount } customer { id } } giftCardCode } } ``` #### Variables ```json { "input": { "initialValue": "27.84", "customerId": "gid://shopify/Customer/743592264", "note": "Refund for Order #1" } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { userErrors { message field } giftCard { id expiresOn note initialValue { amount } customer { id } } giftCardCode } }", "variables": { "input": { "initialValue": "27.84", "customerId": "gid://shopify/Customer/743592264", "note": "Refund for Order #1" } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { userErrors { message field } giftCard { id expiresOn note initialValue { amount } customer { id } } giftCardCode } }`, { variables: { "input": { "initialValue": "27.84", "customerId": "gid://shopify/Customer/743592264", "note": "Refund for Order #1" } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { userErrors { message field } giftCard { id expiresOn note initialValue { amount } customer { id } } giftCardCode } } QUERY variables = { "input": { "initialValue": "27.84", "customerId": "gid://shopify/Customer/743592264", "note": "Refund for Order #1" } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { userErrors { message field } giftCard { id expiresOn note initialValue { amount } customer { id } } giftCardCode } }`, "variables": { "input": { "initialValue": "27.84", "customerId": "gid://shopify/Customer/743592264", "note": "Refund for Order #1" } }, }, }); ``` #### Response ```json { "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" } } ``` * ### Creates a gift card #### Query ```graphql mutation GiftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id balance { amount currencyCode } } userErrors { field message } } } ``` #### Variables ```json { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560" } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation GiftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id balance { amount currencyCode } } userErrors { field message } } }", "variables": { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560" } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation GiftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id balance { amount currencyCode } } userErrors { field message } } }`, { variables: { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560" } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 GiftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id balance { amount currencyCode } } userErrors { field message } } } QUERY variables = { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560" } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation GiftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id balance { amount currencyCode } } userErrors { field message } } }`, "variables": { "input": { "initialValue": "100.0", "customerId": "gid://shopify/Customer/331283560" } }, }, }); ``` #### Response ```json { "giftCardCreate": { "giftCard": { "id": "gid://shopify/GiftCard/1063936323", "balance": { "amount": "100.0", "currencyCode": "USD" } }, "userErrors": [] } } ``` * ### giftCardCreate reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20giftCardCreate\(%24input%3A%20GiftCardCreateInput!\)%20%7B%0A%20%20giftCardCreate\(input%3A%20%24input\)%20%7B%0A%20%20%20%20giftCard%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20initialValue%20%7B%0A%20%20%20%20%20%20%20%20amount%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20customer%20%7B%0A%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20recipientAttributes%20%7B%0A%20%20%20%20%20%20%20%20recipient%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20message%0A%20%20%20%20%20%20%20%20preferredName%0A%20%20%20%20%20%20%20%20sendNotificationAt%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20userErrors%20%7B%0A%20%20%20%20%20%20message%0A%20%20%20%20%20%20field%0A%20%20%20%20%20%20code%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22input%22%3A%20%7B%0A%20%20%20%20%22initialValue%22%3A%20%22100.0%22%2C%0A%20%20%20%20%22customerId%22%3A%20%22gid%3A%2F%2Fshopify%2FCustomer%2F331283560%22%2C%0A%20%20%20%20%22recipientAttributes%22%3A%20%7B%0A%20%20%20%20%20%20%22id%22%3A%20%22gid%3A%2F%2Fshopify%2FCustomer%2F743592264%22%2C%0A%20%20%20%20%20%20%22message%22%3A%20%22Happy%20Birthday!%22%2C%0A%20%20%20%20%20%20%22preferredName%22%3A%20%22Dad%22%2C%0A%20%20%20%20%20%20%22sendNotificationAt%22%3A%20%222024-10-01T12%3A00%3A00Z%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation giftCardCreate($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { id initialValue { amount } customer { id } recipientAttributes { recipient { id } message preferredName sendNotificationAt } } userErrors { message field code } } }`, { variables: { "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" } } }, }, ); const json = await response.json(); return json.data; } ``` ## Input variables JSON ```json { "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 JSON ```json { "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": [] } } ```