Update a gift card

How to update an existing gift card via API

To update an existing gift card, send a PATCH request to the /api/gift_cards/:id endpoint, where id is the ID of the resource that you want to update.

Here below the list of all the possible arguments that you can pass with the request body.

Request

PATCH https://yourdomain.commercelayer.io/api/gift_cards/:id

Arguments

Body ParameterTypeRequired

type

string

Required

id

string

Required

attributes.currency_code

string

Optional

attributes.balance_cents

integer

Optional

attributes.balance_max_cents

string

Optional

attributes.single_use

boolean

Optional

attributes.rechargeable

boolean

Optional

attributes.distribute_discount

boolean

Optional

attributes.image_url

string

Optional

attributes.expires_at

datetime

Optional

attributes.recipient_email

string

Optional

attributes._purchase

boolean

Optional

attributes._activate

boolean

Optional

attributes._deactivate

boolean

Optional

attributes._balance_change_cents

integer

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 updates the gift card identified by the ID "xYZkjABcde":

curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/gift_cards/xYZkjABcde' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "gift_cards",
    "id": "xYZkjABcde",
    "attributes": {
      "balance_max_cents": "100000"
    },
    "relationships": {
      "market": {
        "data": {
          "type": "markets",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'

Last updated