Backend API

The account addresses collection is stored on the account model. It houses a customer's address information and supports several entries which can be used for shipping and billing purposes.

Fields

idobjectId

Unique identifier for the address.

activeboolean

Whether the address is active on the account. Inactive accounts will not be returned in the Storefront API.

address1stringrequired

Primary street address.

address2string

Secondary street address.

citystring

City where the address is located.

countrystring

Country of the residence.

date_createddate

Date of the address creation.

date_updateddate

Date the address was updated.

fingerprintstring

A unique fingerprint hashed from specific address fields that is used to prevent duplicate entries.

first_namestring

First name listed for the address.

last_namestring

Last name listed for the address.

namestring

Combined name listed for the address.

parent_idobjectIdrequired

The corresponding account id for the address.

phonestring

Phone number listed for the address.

statestring

State of the address.

zipstring

Postal code of the address.

The address model
{
  "parent_id": "6296b0ad8f4d1100129e16c3",
  "name": "Adoring Fan",
  "first_name": "Adoring",
  "last_name": "Fan",
  "address1": "The Arena",
  "address2": "Arena District",
  "city": "Imperial City",
  "state": "CA",
  "zip": "94104",
  "country": "US",
  "phone": null,
  "company": null,
  "fingerprint": "92f130033566d9846522759d54cbf5e5",
  "date_created": "2022-06-07T13:35:12.281Z",
  "active": true,
  "id": "62acbbe0d69a3b0012c7eae5"
}

Create a new customer account address.

Arguments

idobjectId

Unique identifier for the address.

activeboolean

Whether the address is active on the account. Inactive accounts will not be returned in the Storefront API.

parent_idobjectIdrequired

The corresponding account id for the address.

address1stringrequired

Primary street address.

address2string

Secondary street address.

citystring

City where the address is located.

countrystring

Country of the residence.

date_createddate

Date of the address creation.

date_updateddate

Date the address was updated.

fingerprintstring

A unique fingerprint hashed from specific address fields that is used to prevent duplicate entries.

first_namestring

First name listed for the address.

last_namestring

Last name listed for the address.

namestring

Combined name listed for the address.

parentAccount
phonestring

Phone number listed for the address.

statestring

State of the address.

zipstring

Postal code of the address.

POST/accounts:addresses
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.post('/accounts:addresses', {
  email: 'adoringfan@azurasstar.com',
  first_name: 'Adoring'
  last_name: 'Fan'
	address1: '123 Breezehome St'
	city: 'Whiterun'
	country: 'US'
});
Response
{
      "parent_id": "621e53a6213eaf013d1fa6b2",
      "name": "Adoring Fan",
      "first_name": "Adoring",
      "last_name": "Fan",
      "address1": "123 Breezehome St",
      "address2": null,
      "city": "Whiterun",
      "state": "NY",
      "zip": null,
      "country": "US",
      "phone": null,
      "company": "Honningbrew Meadery",
      "fingerprint": "1219483071269e91f9528ac1c4237944",
      "date_created": "2022-07-12T17:53:55.762Z",
      "active": true,
      "id": "62cdb5332c0a5f00123c5fd7"
    }

Retrieve an existing account address using the ID that was returned when created.

Arguments

idobjectId

Unique identifier for the address.

address1string

Primary street address.

parent_idobjectId

The corresponding account id for the address.

GET/accounts:addresses/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/accounts:addresses/{id}', {
});
Response
 {
      "parent_id": "621e53a6213eaf013d1fa6b2",
      "name": "Njada Stonearm",
      "first_name": "Njada",
      "last_name": "Stonearm",
      "address1": "123 Breezehome St",
      "address2": null,
      "city": "Whiterun",
      "state": "NY",
      "zip": null,
      "country": "US",
      "phone": null,
      "company": "Honningbrew Meadery",
      "fingerprint": "1219483071269e91f9528ac1c4237944",
      "date_created": "2022-07-12T17:53:55.762Z",
      "active": true,
      "id": "62cdb5332c0a5f00123c5fd7"
    }

Update an existing account address using the ID that was returned when created.

Arguments

idobjectId

Unique identifier for the address.

parent_idobjectIdrequired

The ID of the parent customer.

address1stringrequired
citystring

City where the address is located.

countrystring

Country of the residence.

first_namestring

First name listed for the address.

last_namestring

Last name listed for the address.

namestring

Combined name listed for the address.

statestring

State of the address.

zipstring

Postal code of the address.

PUT/accounts:addresses/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.put('/accounts:addresses/{id}', {
  email: 'sheogorath@shiveringisles.com'
});
Response
{
      "parent_id": "621e53a6213eaf013d1fa6b2",
      "name": "Njada Stonearm",
      "first_name": "Njada",
      "last_name": "Stonearm",
      "address1": "123 Breezehome St",
      "address2": null,
      "city": "Whiterun",
      "state": "NY",
      "zip": null,
      "country": "US",
      "phone": null,
      "company": "Honningbrew Meadery",
      "fingerprint": "1219483071269e91f9528ac1c4237944",
      "date_created": "2022-07-12T17:53:55.762Z",
      "active": true,
      "id": "62cdb5332c0a5f00123c5fd7"
    }

Return a list of customer account addresses.

Arguments

expandstring

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.

fieldsstring

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.
includeobject

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limitint

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

pageint

The page number of results to return given the specified or default limit.

searchstring

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.

sortstring

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.

whereobject

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.

GET/accounts:addresses
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/accounts:addresses/', {
});
Response
{
      "parent_id": "621e53a6213eaf013d1fa6b2",
      "name": "Njada Stonearm",
      "first_name": "Njada",
      "last_name": "Stonearm",
      "address1": "123 Breezehome St",
      "address2": null,
      "city": "Whiterun",
      "state": "NY",
      "zip": null,
      "country": "US",
      "phone": null,
      "company": "Honningbrew Meadery",
      "fingerprint": "1219483071269e91f9528ac1c4237944",
      "date_created": "2022-07-12T17:53:55.762Z",
      "active": true,
      "id": "62cdb5332c0a5f00123c5fd7"
    }

Deleting account addresses with the Swell Backend API.

Arguments

idobjectId

The id of the account address to delete.

DELETE/accounts:addresses/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.delete('/accounts:addresses/{id}', {
  id: '60f1994f9111e7000000000a'
});
The account addresses model
{
  "parent_id": "62e046da033fc8001271fc74",
  "name": "Jzargo Khajiit",
  "first_name": "Jzargo",
  "last_name": "Khajiit",
  "address1": "321 Skyrim Way",
  "address2": null,
  "city": "Winterhold",
  "state": "NY",
  "zip": null,
  "country": "US",
  "phone": null,
  "company": null,
  "fingerprint": "ee9f59a3b941ea09513058efdb108b6d",
  "date_created": "2022-07-26T19:59:38.141Z",
  "active": true,
  "id": "62e047aaff9aae0013394b22"
}