The following methods operate on the Customer data model.
GET
https://api.cratejoy.com/v1/customers/
GET
https://api.cratejoy.com/v1/customers/{customer_id}/
PUT
https://api.cratejoy.com/v1/customers/{customer_id}/
Customer Addresses
Customer address subresource methods operate on the Address data model and provide operations within the context of a Customer
GET
https://api.cratejoy.com/v1/customers/{customer_id}/addresses/
POST
https://api.cratejoy.com/v1/customers/{customer_id}/addresses/
Additional methods for Address objects can be found at the Address Methods page.
List customers
GET
https://api.cratejoy.com/v1/customers/
$.ajax({
url: 'https://api.cratejoy.com/v1/customers/',
method: 'GET'
});
{
"count": 1,
"next": "?page=1",
"prev": null,
"results": [
{
"country": "US",
"email": "[email protected]",
"first_name": "John",
"id": 75561862,
"last_name": "Smith",
"location": "TX, US",
"name": "John Smith",
"num_orders": 20,
"num_subscriptions": 20,
"subscription_status": "active",
"total_revenue": 25188,
"type": "customer",
"url": "/v1/customers/75561862/"
}
]
}
See Customer documentation for a complete list of filters and relationships.
Get customer
GET
https://api.cratejoy.com/v1/customers/{customer_id}/
$.ajax({
url: 'https://api.cratejoy.com/v1/customers/75561862/',
method: 'GET'
});
Update customer
PUT
https://api.cratejoy.com/v1/customers/{customer_id}/
Updates a customer with a given ID. For a complete list of settable properties see the Customer documentation.
$.ajax({
url: 'https://api.cratejoy.com/v1/customers/75561862/',
method: 'PUT',
data: {
first_name: "Jane",
last_name: "Smith",
email: "[email protected]",
note: "This text will be added to the beginning of the existing note, with a linebreak following it, rather than replacing the existing text."
}
});
List customer's addresses
GET
https://api.cratejoy.com/v1/customers/{customer_id}/addresses/
$.ajax({
url: 'https://api.cratejoy.com/v1/customers/755342234/addresses/',
method: 'GET'
});
$.get('https://api.cratejoy.com/v1/customers/75562245/addresses/',{
"zip_code__like": "787%"
});
{
"count": 1,
"next": null,
"prev": "?page=1",
"results": [
{
"city": "Austin",
"company": "",
"country": "US",
"icon": "United-States.png",
"id": 75562247,
"phone_number": "",
"state": "TX",
"status": 0,
"status_message": null,
"street": "101 Main St",
"to": "James Taylor",
"type": "address",
"unit": "",
"url": "/v1/addresses/75562247",
"zip_code": "78701"
}
]
}
Create new customer address
POST
https://api.cratejoy.com/v1/customers/{ID}/addresses/
Create an address for a customer. Provide any of the non-readonly properties to create a new address.
$.ajax({
url: 'https://api.cratejoy.com/v1/customers/755342234/addresses/',
method: 'POST',
data: {
to: "John Smith",
street: "2012 Northridge Dr",
city: "Austin",
state: "TX",
zip_code: "78723",
country: "US"
},
});
{
"city": "Austin",
"company": "",
"country": "US",
"icon": "",
"id": 755622499,
"phone_number": "",
"state": "TX",
"status": 0,
"status_message": null,
"street": "2012 Northridge Dr",
"to": "Clayton Nash",
"type": "address",
"unit": "",
"zip_code": "78723"
}
Customer Metadata
These endpoints operate on the Customer Metadata subresource.
GET
https://api.cratejoy.com/v1/customers/{customer_id}/metadata/
POST
https://api.cratejoy.com/v1/customers/{customer_id}/metadata/
DELETE
https://api.cratejoy.com/v1/customers/{customer_id}/metadata/
Customer Note
DELETE
https://api.cratejoy.com/v1/customers/{customer_id}/note/