# Create a gift card

Source: https://developers.swell.is/backend-api/gift-cards/create-a-gift-card

Create a new gift card.

## Arguments

- `account` (Account): Expandable link to an account where the value was redeemed as account credit, if applicable.
- `account_id` (objectId): ID of an account where the value was redeemed as account credit, if applicable.
- `amount` (currency, required): Initial gift card value. Minimum of 0.01.
- `amount_spent` (currency, auto): Amount of the gift card that has been spent on orders.
- `balance` (currency, auto): Remaining balance on the gift card.
- `bulk_description` (string, auto): A brief description of the occasion for generating a batch of gift cards.
- `bundle_item_id` (objectId): ID of the associated bundle item, if applicable.
- `code` (string): Unique code to identify the gift card.
- `code_formatted` (string): Formatted gift card code for display purposes.
- `code_pattern` (string): String pattern used to display the code in a human-friendly format.
- `currency` (string): Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
- `currency_rate` (float): Currency percentage used in calculating the fixed amount.
- `date_bulk_generated` (date, auto): If the gift card was generated in bulk, this will be the date it was generated.
- `date_expired` (date): Date the gift card will expire and can no longer be spent or redeemed. Defaults to the time period defined in gift card settings.
- `debits` (array of Debits): Expandable list of debit transactions created when the gift card is spent.
- `disabled` (boolean): Indicates the gift card is disabled and can't be spent or redeemed further.
- `last4` (string, auto): Last four digits of the gift card code.
- `order` (Order): Expandable link to the order that originated the gift card, if applicable.
- `order_id` (objectId, auto): ID of the order that originated the gift card, if applicable.
- `order_item_id` (objectId, auto): ID of the order item that originated the gift card, if applicable.
- `product_id` (objectId, auto): ID of the product that originated the gift card, if applicable.
- `redeemed` (boolean, auto): Indicates the gift card was fully redeemed for account credit to `account_id`.
- `send_email` (string): Email address of the gift card recipient, if applicable.
- `send_note` (string): Customer note sent to the gift card recipient by email, if applicable.

## Example request

`POST /giftcards`

**cURL**

```bash
$ curl https://api.swell.store/giftcards \
  -u store-id:secret-key \
  -d amount=100
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.post('/giftcards', {
  amount: 100
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->post('/giftcards', [
  'amount' => 100
]);
```

## Example response

```json
{
  "id": "60f199509111e70000000022",
  "amount": 100,
  "amount_spent": 25,
  "balance": 75,
  "code": "C9X9L7D9Q3MAXC3P",
  "code_formatted": "C9X9 L7D9 Q3MA XC3P",
  "code_pattern": "{XXXX} {XXXX} {XXXX} {XXXX}",
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.142Z",
  "date_updated": "2021-07-16T14:36:00.142Z",
  "last4": "XC3P",
  "redeemed": false,
  "send_email": "friend@example.com",
  "send_note": null
}
```
