Customers
Reading and updating a customer, and why the endpoint is not called what it does.
GET /api/v1/customers/me
PATCH /api/v1/customers/me
Requires read_customers and write_customers respectively.
The address says "me". The endpoint does not mean it
Despite the path, this is not scoped to a signed-in shopper, and there is no session here to scope it to. Both calls take a required customer_id and act on whichever customer you name. A token with read_customers can read any customer in that shop, which is what the ability means, but it is not what the path suggests. Write your code against the parameter, not the name.
Reading One
GET /api/v1/customers/me?customer_id=1
Authorization: Bearer YOUR_TOKEN
{
"data": {
"id": 1,
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890",
"addresses": [],
"primary_group": null
}
}
Addresses and the customer's primary group come with the record, so a profile screen does not need a second call.
An id that does not exist answers 404.
Updating One
PATCH /api/v1/customers/me
Content-Type: application/json
{
"customer_id": 1,
"first_name": "John",
"phone": "+1234567890"
}
customer_id is required. first_name, last_name, email and phone are each optional, and only what you send is changed.
{
"message": "Customer updated.",
"data": { "id": 1, "first_name": "John", "...": "..." }
}
Changing an email changes how they sign in
email is the customer's identity on the shop. Writing one that belongs to nobody leaves them unable to sign in with what they knew, and the shop will not warn them. Treat it as an account change rather than a field update, and confirm it with the person before you send it.
What Is Not Here
There is no listing endpoint, no create and no delete. There is no way to search customers by email. If you need to find a customer you do not already have the id of, you need it from somewhere else: the order you are working from carries it.
