Create Gift Card

🔒

Requires price_rules access scope. More access scope

The Create Gift Card API creates a new gift card for a specific customer or store, including details such as initial value, expiration date, and custom templates.

This API is especially useful for:

  1. Managing gift cards for customers.
  2. Issuing new gift cards with predefined values and conditions.
  3. Integrating gift card creation into e-commerce workflows.

Request Parameters

Public Request Parameters

📘

Public Request Parameters

Body Parameters

NameTypeDescriptionExample
gift_cardobjectGift card information.{...}
gift_card.codestringThe gift card code, which is a string of alphanumeric characters. Must be between 8 and 20 characters.ABCD1234
gift_card.initial_valuestringThe initial value of the gift card when it was created.200.00
gift_card.expires_onstringThe expiration date of the gift card in ISO-8601 format.2022-11-01T00:00:00Z
gift_card.notestringAn optional note that a merchant can attach to the gift card that isn't visible to customers.This is a note.
gift_card.customer_idstringThe ID of the customer associated with this gift card.2dd957e3-2051-4cdf-8584-9c0046b4d1ae
gift_card.template_suffixstringThe suffix of the Liquid template that's used to render the gift card online.template1
gift_card.send_emailbooleanSend notification email to customer, true is default.true

Response Explanation

Public Response Parameters

📘

Public Response Parameters

Success Response

NameTypeDescriptionExample
gift_card.idstringUnique identifier for the gift card.377026890382183978
gift_card.last_charactersstringThe last characters of the gift card code.218p
gift_card.balancestringCurrent balance of the gift card.100.00
gift_card.initial_valuestringThe initial value of the gift card when created.100.00
gift_card.notestringNote attached to the gift card.note
gift_card.expires_onstringExpiration date of the gift card in ISO-8601 format, if applicable.null
gift_card.disabled_atstringTimestamp when the gift card was disabled, if applicable.null
gift_card.enabledbooleanWhether the gift card is currently enabled.true
gift_card.created_atstringTimestamp of when the gift card was created.2024-05-06T10:12:05Z
gift_card.updated_atstringTimestamp of when the gift card was last updated.2024-05-06T10:12:05Z
gift_card.statusstringCurrent status of the gift card (enable or disable).enable
gift_card.currencystringCurrency in which the gift card is denominated.USD
gift_card.line_item_idstringID of the line item associated with the gift card, if applicable.null
gift_card.order_idstringID of the order associated with the gift card, if applicable.null
gift_card.user_idstringUser ID of the creator or owner of the gift card.cba51e16-ac53-43d8-a7a3-161c5b1ecd8e
gift_card.template_suffixstringSuffix of the template used to render the gift card online.null
gift_card.customer_idstringCustomer ID associated with the gift card.2dd957e3-2051-4cdf-8584-9c0046b4d1ae

Error Response

Error responses in the API can be represented using two different fields: errors and error. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.

FieldTypeExampleDescription
errorsArray[ "invalid line_item id"]A list of errors encountered during the request processing.
FieldTypeExampleDescription
errorString "store is not active"Indicates an error encountered during the process

Error Detail

Status CodeMessagePossible ReasonExample Response
400Bad RequestInvalid input format or request structure (e.g., missing required fields or incorrect data types).Bad Request
UnauthorizedThe request is missing valid authentication credentials or the credentials provided are invalid.Unauthorized
422"InitialValue is required”Empty initial_value"InitialValue is required”
"Code is required"Empty code"Code is required"
cannot parseinvalid expires_oncannot parse

API Structure Overview

Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!