Customer Management/
Addresses API/
Update an Address

Update an Address

PUT Update by ID

https://api.moltin.com/v2/customers/:customerId/addresses/:addressId

OR

https://api.moltin.com/v2/accounts/:accountId/addresses/:addressId

Parameters

Path parameters

NameRequiredTypeDescription
customerIdRequired (for customer addresses)stringThe ID for the customer that you are updating address for.
accountIdRequired (for account addresses)stringThe ID for the account that you are updating address for.
addressIdRequiredstringThe ID for the address you are updating.

Headers

NameRequiredTypeDescription
X-Moltin-Customer-TokenOptionalstringA customer token used to access customer addresses implicitly.
EP-Account-Management-Authentication-TokenOptionalstringAn account management authentication token that identifies the authenticated account member.
AuthorizationRequiredstringThe Bearer token required to get access to the API.

Body

NameRequiredTypeDescription
idRequiredstringThe ID for the address you are updating. Expected to match addressId in Path Parameters
typeRequiredstringRepresents the type of object being returned.
first_nameRequiredstringThe first name of the recipient on this address.
last_nameRequiredstringThe last name of the recipient on this address.
nameOptionalstringThe name under which this address is saved. You can display this name to the customer when you ask them to select from their saved addresses.
phone_numberOptionalstringA phone number for this address.
instructionsOptionalstringAny delivery instructions for this address.
company_nameOptionalstringThe company name at this address.
line_1RequiredstringThe first portion of the address, usually the street address.
line_2OptionalstringThe second portion of the address, usually an apartment or unit number.
cityOptionalstringThe city for this address.
countyRequiredstringThe county for this address.
regionRequiredstringThe state, province, or region for this address.
postcodeRequiredstringThe ZIP Code, Postcode, or other postal reference string for this delivery address.
countryRequiredstringA two digit code for the country this address is in, expressed as per the ISO 3166-2 standard.

Request Examples Update Customer Address

Curl

curl -X PUT https://api.moltin.com/v2/customers/:customerId/addresses \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
       "data": {
         "name": "Home",
         "first_name": "Ron",
         "last_name": "Swanson",
         "company_name": "",
         "phone_number": "(555) 555-1234",
         "line_1": "1 Sunny Street",
         "line_2": "Sunny Place",
         "city": "Sunny Town",
         "postcode": "SU33 1YY",
         "county": "Sunnyville",
         "region": "Peterborough",
         "country": "GB",
         "instructions": "Leave in the shed"
       }
     }'

JavaScript SDK

const MoltinGateway = require("@moltin/sdk").gateway;
const Moltin = MoltinGateway({
    client_id: "X",
    client_secret: "X", // Required if customer token not present
});
const customer = "XXXX";
const addressId = "XXXX";
const address = {
    name: "Home sweet home",
};
const token = "XXXX";
Moltin.CustomerAddresses.Update({
    customer,
    address: addressId,
    body: address,
    token, // optional
}).then((address) => {
    // Do something
});

Request Examples Update Account Address

Curl

curl -X PUT https://api.moltin.com/v2/accounts/:accountId/addresses \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
       "data": {
         "name": "Home",
         "first_name": "Ron",
         "last_name": "Swanson",
         "company_name": "",
         "phone_number": "(555) 555-1234",
         "line_1": "1 Sunny Street",
         "line_2": "Sunny Place",
         "city": "Sunny Town",
         "postcode": "SU33 1YY",
         "county": "Sunnyville",
         "region": "Peterborough",
         "country": "GB",
         "instructions": "Leave in the shed"
       }
     }'

JavaScript SDK

const MoltinGateway = require("@moltin/sdk").gateway;
const Moltin = MoltinGateway({
    client_id: "X",
    client_secret: "X", // Required if customer token not present
});
const account = "XXXX";
const addressId = "XXXX";
const address = {
    name: "Home sweet home",
};
const token = "XXXX";
Moltin.AccountAddresses.Update({
    account,
    address: addressId,
    body: address,
    token, // optional
}).then((address) => {
    // Do something
});

Response Example

200 OK

{
    "id": "5f8da740-6680-463e-b31c-190b2db4bf9d",
    "type": "address",
    "name": "Home",
    "first_name": "Ron",
    "last_name": "Swanson",
    "company_name": "",
    "phone_number": "(555) 555-1234",
    "line_1": "1 Sunny Street",
    "line_2": "Sunny Place",
    "city": "Sunny Town",
    "postcode": "SU33 1YY",
    "county": "Sunnyville",
    "region": "Peterborough",
    "country": "GB",
    "instructions": "Leave in the shed",
    "links": {
        "self": "https://api.moltin.com/v2/addresses/5f8da740-6680-463e-b31c-190b2db4bf9d"
    },
    "meta": {
        "timestamps": {
            "created_at": "2018-05-04T15:20:09.734Z",
            "updated_at": "2018-05-04T15:20:09.734Z"
        }
    }
}

Was this helpful?

Previous
Create an Address

Learn

Docs