# Update a gift card

To [update](https://docs.commercelayer.io/core/updating-resources) 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 Parameter                          | Type       | Required |
| --------------------------------------- | ---------- | -------- |
| **type**                                | `string`   | Required |
| **id**                                  | `string`   | Required |
| attributes.**currency\_code**           | `string`   | Optional |
| attributes.**balance\_cents**           | `integer`  | Optional |
| attributes.**balance\_max\_cents**      | `integer`  | 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.**\_add\_tags**              | `string`   | Optional |
| attributes.**\_remove\_tags**           | `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

{% tabs %}
{% tab title="Request" %}
The following request updates the gift card identified by the ID "XAyRWNUzyN":

```shell
curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN' \
  -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"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `200 OK` status code, returning the updated resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "gift_cards",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN"
    },
    "attributes": {
      "status": "draft",
      "code": "32db311a-75d9-4c17-9e34-2be220137ad6",
      "currency_code": "EUR",
      "initial_balance_cents": 15000,
      "initial_balance_float": 150.0,
      "formatted_initial_balance": "€150,00",
      "balance_cents": 15000,
      "balance_float": 150.0,
      "formatted_balance": "€150,00",
      "balance_max_cents": 100000,
      "balance_max_float": 1000.0,
      "formatted_balance_max": "€1000,00",
      "balance_log": [
        {
          "datetime": "2019-12-23T12:00:00.000Z",
          "balance_change_cents": -10000
        },
        {
          "datetime": "2020-02-01T12:00:00.000Z",
          "balance_change_cents": 5000
        }
      ],
      "usage_log": {
        "eNoKkhmbNp": [
          {
            "action": "use",
            "amount_cents": -1000,
            "balance_cents": 4000,
            "order_number": "11111",
            "datetime": "2020-02-01T12:00:00.000Z"
          }
        ]
      },
      "single_use": false,
      "rechargeable": true,
      "distribute_discount": true,
      "image_url": "https://img.yourdomain.com/gift_cards/32db311a.png",
      "expires_at": "2018-01-01T12:00:00.000Z",
      "recipient_email": "john@example.com",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "market": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/market",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/market"
        }
      },
      "gift_card_recipient": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/gift_card_recipient",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/gift_card_recipient"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/attachments"
        }
      },
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/events"
        }
      },
      "tags": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/tags",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/tags"
        }
      },
      "versions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/versions",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/versions"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/gift_cards/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  }
}
```

{% endtab %}
{% endtabs %}
