Create a gift card

How to create a gift card via API

To create a new gift card, send a POST request to the /api/gift_cards endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/gift_cards

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.code

string

Optional

attributes.currency_code

string

Required, unless inherited by market

attributes.balance_cents

integer

Required

attributes.balance_max_cents

integer

Optional

attributes.single_use

boolean

Optional, default is 'false'

attributes.rechargeable

boolean

Optional, default is 'true'

attributes.distribute_discount

boolean

Optional, default is 'true'

attributes.image_url

string

Optional

attributes.expires_at

datetime

Optional, default is 'null'

attributes.recipient_email

string

Optional

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.market

object

Optional

relationships.gift_card_recipient

object

Optional

relationships.tags

array

Optional

Example

The following request creates a new gift card:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/gift_cards' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "gift_cards",
    "attributes": {
      "currency_code": "EUR",
      "balance_cents": 15000
    }
  }
}'

Last updated