Create an Address

Last updated 3 months ago

post
Create a Customer Address

https://api.moltin.com
/v2/customers/:customerId/addresses
Request
Response
Path Parameters
customerId
required
string
The ID for the customer you are adding an address for
Headers
X-Moltin-Customer-Token
optional
string
A customer token used to access customer addresses implicitly
Authorization
required
string
The Bearer token to grant access to the API
Body Parameters
type
required
string
Represents the type of object being returned
first_name
required
string
The first name of the recipient on this address
last_name
required
string
The last name of the recipient on this address
name
optional
string
The 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_number
optional
string
A phone number for this address
instructions
optional
string
Any delivery instructions for this address
company_name
optional
string
The company name at this address
line_1
required
string
The first portion of the address, usually the street address
line_2
optional
string
The second portion of the address, usually an apartment or unit number
city
optional
string
The city for this address
county
required
string
The county for this address
postcode
required
string
The ZIP Code, Postcode, or other postal reference string for this delivery address
country
required
string
A two digit code for the country this address is in, expressed as per the ISO 3166-2 standard
201: Created
{
"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",
"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"
}
}
}
cURL
JavaScript SDK
curl -X POST 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",
"country": "GB",
"instructions": "Leave in the shed"
}
}'
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 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",
country: "GB",
instructions: "Leave in the shed"
}
const token = 'XXXX'
Moltin.Addresses.Create({
customer,
body: address,
token // optional
}).then(address => {
// Do something
})