# Create an account card

Source: https://developers.swell.is/backend-api/account-cards/create-an-account-card

Create a new customer account card.

## Arguments

- `id` (objectId, auto): The unique identifier for the card.
- `parent_id` (objectId, required): The ID of the parent account.
- `token` (link, required): Link to the associated payment token.
- `active` (boolean): Indicates whether this card is active and available for use. Default: `true`.
- `address_check` (enum): Indicates results of the address check for the card: `unchecked`, `pass`, or `fail`. Possible values: `"unchecked"`, `"pass"`, `"fail"`.
- `billing` (object): The customer's billing details. Defaults to `account.billing`. Updating billing will also update the corresponding account billing object.
  - `name` (string): Billing full name. If `first_name` or `last_name` are updated, then `name` will be automatically updated as a combination of first/last.
  - `email` (string): Customer's email address.
  - `company` (string): Customer's company, if applicable.
  - `first_name` (string): Billing first name. If `name` is updated, then `first_name` will be automatically updated as the first word of the name.
  - `last_name` (string): Billing last name. If `name` is updated, then `last_name` will be automatically updated as the last word of the name.
  - `phone` (string): Billing phone number.
  - `address1` (string)
  - `address2` (string)
  - `city` (string)
  - `state` (string)
  - `zip` (string)
  - `country` (string)
  - `vat_number` (string)
- `brand` (string): Name of card issuer. E.g., `"visa"`.
- `cvc_check` (enum): Indicates results of the CVC check for the card: `unchecked`, `pass`, or `fail`. Possible values: `"unchecked"`, `"pass"`, `"fail"`.
- `date_created` (date, auto): The date the card entry was created.
- `date_updated` (date, auto): Date the card entry was last updated.
- `exp_month` (int): The expiration month on the card, `1` through `12`.
- `exp_year` (int): Four-digit card expiration year.
- `fingerprint` (string): A hashed fingerprint generated using `client_id`, `brand`, and `last4`.
- `gateway` (string): Name of the payment gateway.
- `last4` (string): The last four digits of the card number.
- `parent` (Account): Link to the parent account.
- `test` (boolean): Indicated the card is for testing purposes.
- `zip_check` (enum): Indicates results of the zip check for the card: `unchecked`, `pass`, or `fail`. Possible values: `"unchecked"`, `"pass"`, `"fail"`.

## Example request

`POST /accounts:cards`

**cURL**

```sh
$ curl https://api.swell.store/accounts:cards \
  -u store-id:secret-key \
  -d first_name="Jarl" \
  -d last_name="Balgruff" \
  -d address1= "543 Castle Way" \
	-d city= "Whiterun" \  
	-d state= "CA" \ 
	-d country= "US" \ 
	-d brand= "Visa" \ 
	-d last4= "1234" \ 
	-d exp_month= 10 \ 
	-d exp_year= 2023 \
```

**Node**

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

await swell.post('/accounts:cards', {
  first_name: 'Jarl',
	last_name: 'Balgruff',
	address1: '543 Castle Way',
	city: 'Whiterun',
	state: 'CA',
	country: 'US',
	brand: 'Visa',
	last4: '1234',
	exp_month: 10,
	exp_year: 2023,
});
```

**PHP**

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

$swell->post('/accounts:cards', [
  'first_name' => 'Jarl',
  'last_name' => 'Balgruff'
  'address1' => '543 Castle Way'
	'city' => 'Whiterun'
	'state' => 'CA'
	'country' => 'US'
	'brand' => 'Visa'
	'last4' => '1234'
	'exp_month' => '10'
	'exp_year' => '2023'
]);
```

## Example response

```json
{
      "parent_id": "621e53a6213eaf013d1fa6b2",
      "billing": {
        "name": "Jarl Balgruff",
        "first_name": "Jarl",
        "last_name": "Balgruff",
        "address1": "543 Castle Way",
        "address2": null,
        "city": "Whiterun",
        "state": "CA",
        "zip": null,
        "country": "US",
        "phone": null,
        "company": null
      },
      "brand": "Visa",
      "last4": "1234",
      "exp_month": 10,
      "exp_year": 2023,
      "token": "card_QD5rOXP3I4bOmUCKlmLo7AzC",
      "address_check": "unchecked",
      "zip_check": "unchecked",
      "cvc_check": "unchecked",
      "fingerprint": "3628a7581fec797682e06740213c08f1",
      "date_created": "2022-07-13T15:52:53.253Z",
      "active": true,
      "id": "64ceea552fa37600132711f4"
    }
```
