Create a gift card with a customer and a recipient
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560",
"recipientAttributes": {
"id": "gid://shopify/Customer/743592264",
"message": "Happy Birthday!",
"preferredName": "Dad",
"sendNotificationAt": "2024-10-01T12:00:00Z"
}
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560",
"recipientAttributes": {
"id": "gid://shopify/Customer/743592264",
"message": "Happy Birthday!",
"preferredName": "Dad",
"sendNotificationAt": "2024-10-01T12:00:00Z"
}
}
}
}'
React Router
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"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
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"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
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560",
"recipientAttributes": {
"id": "gid://shopify/Customer/743592264",
"message": "Happy Birthday!",
"preferredName": "Dad",
"sendNotificationAt": "2024-10-01T12:00:00Z"
}
}
},
},
});
Shopify CLI
shopify app execute \
--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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560",
"recipientAttributes": {
"id": "gid://shopify/Customer/743592264",
"message": "Happy Birthday!",
"preferredName": "Dad",
"sendNotificationAt": "2024-10-01T12:00:00Z"
}
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-10/graphql.json', {
method: 'POST',
body: JSON.stringify({
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560",
"recipientAttributes": {
"id": "gid://shopify/Customer/743592264",
"message": "Happy Birthday!",
"preferredName": "Dad",
"sendNotificationAt": "2024-10-01T12:00:00Z"
}
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"giftCardCreate": {
"giftCard": {
"id": "gid://shopify/GiftCard/1063936350",
"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
mutation giftCardCreate($input: GiftCardCreateInput!) {
giftCardCreate(input: $input) {
userErrors {
message
field
}
giftCard {
id
expiresOn
note
initialValue {
amount
}
customer {
id
}
}
giftCardCode
}
}
Variables
{
"input": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-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": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
}
}'
React Router
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": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
},
},
);
const json = await response.json();
return json.data;
}
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": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
}
response = client.query(query: query, variables: variables)
Node.js
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": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation giftCardCreate($input: GiftCardCreateInput!) {
giftCardCreate(input: $input) {
userErrors {
message
field
}
giftCard {
id
expiresOn
note
initialValue {
amount
}
customer {
id
}
}
giftCardCode
}
}' \
--variables \
'{
"input": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-10/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation giftCardCreate($input: GiftCardCreateInput!) {
giftCardCreate(input: $input) {
userErrors {
message
field
}
giftCard {
id
expiresOn
note
initialValue {
amount
}
customer {
id
}
}
giftCardCode
}
}
`,
variables: {
"input": {
"initialAmount": {
"amount": "27.84",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/967488952",
"note": "Refund for Order #1"
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"giftCardCreate": {
"userErrors": [],
"giftCard": {
"id": "gid://shopify/GiftCard/1063936349",
"expiresOn": null,
"note": "Refund for Order #1",
"initialValue": {
"amount": "27.84"
},
"customer": {
"id": "gid://shopify/Customer/967488952"
}
},
"giftCardCode": "dfae9egghhcg893a"
}
}
Creates a gift card
Query
mutation GiftCardCreate($input: GiftCardCreateInput!) {
giftCardCreate(input: $input) {
giftCard {
id
balance {
amount
currencyCode
}
}
userErrors {
field
message
}
}
}
Variables
{
"input": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
}
}'
React Router
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
},
},
);
const json = await response.json();
return json.data;
}
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
}
response = client.query(query: query, variables: variables)
Node.js
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": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation GiftCardCreate($input: GiftCardCreateInput!) {
giftCardCreate(input: $input) {
giftCard {
id
balance {
amount
currencyCode
}
}
userErrors {
field
message
}
}
}' \
--variables \
'{
"input": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-10/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation GiftCardCreate($input: GiftCardCreateInput!) {
giftCardCreate(input: $input) {
giftCard {
id
balance {
amount
currencyCode
}
}
userErrors {
field
message
}
}
}
`,
variables: {
"input": {
"initialAmount": {
"amount": "100.0",
"currencyCode": "USD"
},
"customerId": "gid://shopify/Customer/331283560"
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"giftCardCreate": {
"giftCard": {
"id": "gid://shopify/GiftCard/1063936351",
"balance": {
"amount": "100.0",
"currencyCode": "USD"
}
},
"userErrors": []
}
}