Backend API
The account cards collection houses a customer's card information used for payments and transactions—allowing for storing multiple cards on a customer account.
Fields
The unique identifier for the card.
The ID of the parent account.
Link to the associated payment token.
Indicated whether this card is active and available for use.
Indicates results of the address check for the card: unchecked, pass, or fail.
The customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
Billing full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
Customer's email address.
Customer's company, if applicable.
Billing first name. If name is updated, then first_name will be automatically updated as the first word of the name.
Billing last name. If name is updated, then last_name will be automatically updated as the last word of the name.
Billing phone number.
Billing address line 1: street address/PO box/company name.
Billing address line 2: apartment/suite/unit/building.
Billing city/district/suburb/town/village.
Billing state/county/province/region.
Billing zip/postal code.
Two-letter ISO country code.
VAT number for tax purposes, if applicable.
Name of card issuer. E.g., "visa".
Brand of the card displayed to the customer, if different from the underlying brand (for example, co-branded cards).
Indicates results of the CVC check for the card: unchecked, pass, or fail.
The date the card entry was created.
Date the card entry was last updated.
The expiration month on the card, 1 through 12.
Four-digit card expiration year.
A hashed fingerprint generated using client_id, brand, and last4.
Name of the payment gateway.
The last four digits of the card number.
Link to the parent account.
Indicated the card is for testing purposes.
Indicates results of the zip check for the card: unchecked, pass, or fail.
The account card model
{
"parent_id": "627308bc32db26001276f091",
"billing": {
"name": "Glarthir",
"first_name": "Glarthir",
"last_name": null,
"address1": "Glarthir's House",
"address2": null,
"city": "Skingrad",
"state": "CA",
"zip": "95051",
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "4242",
"exp_month": 2,
"exp_year": 2024,
"token": "card_mgLMIJrqdFKjapNnKQXzbGSg",
"address_check": "pass",
"zip_check": "pass",
"cvc_check": "pass",
"fingerprint": "011778e5080632a4701cb5628266007d",
"date_created": "2022-05-19T17:17:31.167Z",
"active": true,
"id": "62867bab67e544001a6a3218"
},
Create a new customer account card.
Arguments
The unique identifier for the card.
The ID of the parent account.
Link to the associated payment token.
Indicates whether this card is active and available for use.
Indicates results of the address check for the card: unchecked, pass, or fail.
Possible enum values:
The customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
Billing full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
Customer's email address.
Customer's company, if applicable.
Billing first name. If name is updated, then first_name will be automatically updated as the first word of the name.
Billing last name. If name is updated, then last_name will be automatically updated as the last word of the name.
Billing phone number.
Name of card issuer. E.g., "visa".
Indicates results of the CVC check for the card: unchecked, pass, or fail.
Possible enum values:
The date the card entry was created.
Date the card entry was last updated.
The expiration month on the card, 1 through 12.
Four-digit card expiration year.
A hashed fingerprint generated using client_id, brand, and last4.
Name of the payment gateway.
The last four digits of the card number.
Link to the parent account.
Indicated the card is for testing purposes.
Indicates results of the zip check for the card: unchecked, pass, or fail.
Possible enum values:
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,
});Response
{
"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"
}Retrieve an existing account card using the ID that was returned when created.
Arguments
ID of the customer account card to retrieve.
Expanding link fields and child collections is performed using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit,
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Return only the specified fields in the result. For example fields=name,slug would return only the fields name and slug in the response. Supports nested object and array fields using dot-notation, for example items.product_id. The customer account card id is always returned.
Include one or more arbitrary queries in the response, possibly related to the main query.
See including for more details.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/accounts:cards/{id}', {
id: '64ceea552fa37600131711f3'
});Response
{
"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_QD5rOXP3I4bOmUCKlmLo7BzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3628a7581fec797682e06740213c08f1",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"id": "64ceea552fa37600131711f3"
}Update an existing account card using the ID that was returned when created.
Arguments
Unique identifier for the account card.
Full name of the customer. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
Customer's first name. If name is updated, then first_name will be automatically updated as the first word of the name.
If name is updated, then last_name will be automatically updated as the last words of the name.
Billing address line 1: street address/PO box/company name.
Billing address line 2: apartment/suite/unit/building.
Billing city/district/suburb/town/village.
Billing state/county/province/region.
Billing zip/postal code.
Two-letter ISO country code.
Credit card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
Two-digit number representing the credit card expiration month.
Four-digit number representing the credit card expiration year.
Last four digits of the card number.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.put('/accounts:cards/{id}', {
id: '62ceea552fa37600132911f6',
exp_month: 11,
exp_year: 2025
});Response
{
"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": 11,
"exp_year": 2025,
"token": "card_QD4rOXP3I5bOmUCKlmLo8AzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3618a9581fec797682e06740212c08f3",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"date_updated": "2022-07-18T20:00:49.662Z",
"id": "62ceea552fa37600132911f6"
}Return a list of customer account cards.
Arguments
Expand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Returns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
Include one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.
The page number of results to return given the specified or default limit.
A text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
Expression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
An object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/accounts:cards', {
where: {
order_count: {
$gt: 1
}
},
limit: 25,
page: 1
});Response
{
"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_QD5rOXP3I4bOmUCKlmLo7BzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3628a7581fec797682e06740213c08f1",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"id": "64ceea552fa37600131711f3"
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}Delete a customer account card.
Arguments
The ID of the account card to delete.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.delete('/accounts:cards/{id}', {
id: '62ceea552fa37600132911f6'
});The account card model
{
"parent_id": "627308bc32db26001276f091",
"billing": {
"name": "Glarthir",
"first_name": "Glarthir",
"last_name": null,
"address1": "Glarthir's House",
"address2": null,
"city": "Skingrad",
"state": "CA",
"zip": "95051",
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "4242",
"exp_month": 2,
"exp_year": 2024,
"token": "card_mgLMIJrqdFKjapNnKQXzbGSg",
"address_check": "pass",
"zip_check": "pass",
"cvc_check": "pass",
"fingerprint": "011778e5080632a4701cb5628266007d",
"date_created": "2022-05-19T17:17:31.167Z",
"active": true,
"id": "62867bab67e544001a6a3218"
},