# giftCardCreate - admin-graphql - MUTATION
Version: 2024-04

## Description
Create a gift card.

### Access Scopes
`write_gift_cards` access scope.


## Arguments
* [input](/docs/api/admin-graphql/2024-04/input-objects/GiftCardCreateInput): GiftCardCreateInput! - The input fields to create a gift card.


## Returns
* [giftCard](/docs/api/admin-graphql/2024-04/objects/GiftCard): GiftCard The created gift card.
* [giftCardCode](/docs/api/admin-graphql/2024-04/scalars/String): String The created gift card's code.
* [userErrors](/docs/api/admin-graphql/2024-04/objects/GiftCardUserError): GiftCardUserError! The list of errors that occurred from executing the mutation.


## Examples
### Create a non-expiring gift card with a generated code for a customer
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" 
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}"
#### Graphql Input
{
  "input": {
    "initialValue": "27.84",
    "customerId": "gid://shopify/Customer/743592264",
    "note": "Refund for Order #1"
  }
}
#### Graphql 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"
    }
  }
}

### Creates a gift card
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" 
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}"
#### Graphql Input
{
  "input": {
    "initialValue": "100.0",
    "customerId": "gid://shopify/Customer/331283560"
  }
}
#### Graphql Response
{
  "data": {
    "giftCardCreate": {
      "giftCard": {
        "id": "gid://shopify/GiftCard/1063936323",
        "balance": {
          "amount": "100.0",
          "currencyCode": "USD"
        }
      },
      "userErrors": []
    }
  }
}