Store Hugs Developers

Addresses

The signed-in shopper's address book, the same one checkout offers them.

Reach it through shopper.customer.addresses. It needs a client with the shopper's access token (see sign-in).

List addresses

shopper.customer.addresses.list(): Promise<CustomerAddress[]>

The address book, the default first. Not paginated.

Returns

A list of CustomerAddress, each:

FieldTypeDescription
[].idinteger
[].labelstring or null
[].namestring
[].phonestring
[].countryCodestring
[].statestring or null
[].stateIdinteger or null
[].citystring or null
[].cityIdinteger or null
[].neighbourhoodstring or null
[].neighbourhoodIdinteger or null
[].addressLine1string
[].addressLine2string or null
[].postalCodestring or null
[].isDefaultboolean

Errors

StatusWhen
401invalid_api_key, or invalid_customer_token: the shopper's token is missing or not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404Not found, or the shop's plan has no Integration API.
429Rate limited.

Example

const addresses = await shopper.customer.addresses.list();

Add an address

shopper.customer.addresses.create(input: CustomerAddressInput): Promise<CustomerAddress>

A new address. The first address, or one sent with isDefault, becomes the default. Limited like cart writes.

Parameters

Parameter Type
input CustomerAddressInput The address's fields, below.

Request fields

FieldTypeDescription
labelstring or nullAt most 50 characters.
name requiredstringAt most 255 characters.
phone requiredstringAt most 50 characters.
countryCode requiredstringISO 3166-1 alpha-3, one the shop ships to. At most 3 characters.
city requiredstringAt most 100 characters.
statestring or nullAt most 100 characters.
addressLine1 requiredstringAt most 500 characters.
addressLine2string or nullAt most 500 characters.
postalCodestring or nullAt most 20 characters.
isDefaultboolean
shippingStateIdinteger or null
shippingCityIdinteger or null
shippingNeighbourhoodIdinteger or null
shippingLocationUnlistedboolean or null

Returns

The new CustomerAddress:

FieldTypeDescription
idinteger
labelstring or null
namestring
phonestring
countryCodestring
statestring or null
stateIdinteger or null
citystring or null
cityIdinteger or null
neighbourhoodstring or null
neighbourhoodIdinteger or null
addressLine1string
addressLine2string or null
postalCodestring or null
isDefaultboolean

Errors

StatusWhen
401invalid_api_key, or invalid_customer_token: the shopper's token is missing or not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404Not found, or the shop's plan has no Integration API.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

const address = await shopper.customer.addresses.create({
    name: 'Sara Ali',
    phone: '+966500000000',
    countryCode: 'SAU',
    city: 'Riyadh',
    addressLine1: '12 King Fahd Road',
    isDefault: true,
});

Edit an address

shopper.customer.addresses.update(id: number, changes: Partial<CustomerAddressInput>): Promise<CustomerAddress>

Changes one of the shopper's addresses. It is validated with the same rules as a new address, so send every required field.

Parameters

Parameter Type
id number The address's id.
changes object The address's fields, below.

Request fields

FieldTypeDescription
labelstring or nullAt most 50 characters.
name requiredstringAt most 255 characters.
phone requiredstringAt most 50 characters.
countryCode requiredstringISO 3166-1 alpha-3, one the shop ships to. At most 3 characters.
city requiredstringAt most 100 characters.
statestring or nullAt most 100 characters.
addressLine1 requiredstringAt most 500 characters.
addressLine2string or nullAt most 500 characters.
postalCodestring or nullAt most 20 characters.
isDefaultboolean
shippingStateIdinteger or null
shippingCityIdinteger or null
shippingNeighbourhoodIdinteger or null
shippingLocationUnlistedboolean or null

Returns

The changed CustomerAddress:

FieldTypeDescription
idinteger
labelstring or null
namestring
phonestring
countryCodestring
statestring or null
stateIdinteger or null
citystring or null
cityIdinteger or null
neighbourhoodstring or null
neighbourhoodIdinteger or null
addressLine1string
addressLine2string or null
postalCodestring or null
isDefaultboolean

Errors

StatusWhen
401invalid_api_key, or invalid_customer_token: the shopper's token is missing or not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404address_not_found, or the plan has no Integration API.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

await shopper.customer.addresses.update(7, {
    name: 'Sara Ali',
    phone: '+966500000000',
    countryCode: 'SAU',
    city: 'Jeddah',
    addressLine1: '4 Tahlia Street',
});

Delete an address

shopper.customer.addresses.delete(id: number): Promise<void>

Deletes one of the shopper's addresses. Deleting the default makes the next address the default.

Parameters

Parameter Type
id number The address's id.

Returns

Nothing.

Errors

StatusWhen
401invalid_api_key, or invalid_customer_token: the shopper's token is missing or not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404address_not_found, or the plan has no Integration API.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Make an address the default

shopper.customer.addresses.makeDefault(id: number): Promise<CustomerAddress>

Makes one of the shopper's addresses their default.

Parameters

Parameter Type
id number The address's id.

Returns

The CustomerAddress:

FieldTypeDescription
idinteger
labelstring or null
namestring
phonestring
countryCodestring
statestring or null
stateIdinteger or null
citystring or null
cityIdinteger or null
neighbourhoodstring or null
neighbourhoodIdinteger or null
addressLine1string
addressLine2string or null
postalCodestring or null
isDefaultboolean

Errors

StatusWhen
401invalid_api_key, or invalid_customer_token: the shopper's token is missing or not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404address_not_found, or the plan has no Integration API.
409idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

await shopper.customer.addresses.makeDefault(7);