Skip to main content

Customers

The customer API allows you to create, view, update, and delete individual, or a batch, of customers.

Customer properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
date_createddate-timeThe date the customer was created, in the site's timezone. READ-ONLY
date_modifieddate-timeThe date the customer was last modified, in the site's timezone. READ-ONLY
emailstringThe email address for the customer. MANDATORY
first_namestringCustomer first name.
last_namestringCustomer last name.
usernamestringCustomer login name. Can be generated automatically from the customer's email address if the option woocommerce_registration_generate_username is equal to yes CANNOT BE CHANGED MAYBE MANDATORY
passwordstringCustomer password. Can be generated automatically with wp_generate_password() if the "Automatically generate customer password" option is enabled, check the index meta for generate_password WRITE-ONLY MAYBE MANDATORY
last_orderarrayLast order data. See Customer Last Order properties. READ-ONLY
orders_countintegerQuantity of orders made by the customer. READ-ONLY
total_spentstringTotal amount spent. READ-ONLY
avatar_urlstringAvatar URL.
billingarrayList of billing address data. See Billing Address properties.
shippingarrayList of shipping address data. See Shipping Address properties.

Customer last order properties

AttributeTypeDescription
idintegerLast order ID. READ-ONLY
datedate-timeUTC DateTime of the customer last order. READ-ONLY

Billing address properties

AttributeTypeDescription
first_namestringFirst name.
last_namestringLast name.
companystringCompany name.
address_1stringAddress line 1.
address_2stringAddress line 2.
citystringCity name.
statestringISO code or name of the state, province or district.
postcodestringPostal code.
countrystringISO code of the country.
emailstringEmail address.
phonestringPhone number.

Shipping address properties

AttributeTypeDescription
first_namestringFirst name.
last_namestringLast name.
companystringCompany name.
address_1stringAddress line 1.
address_2stringAddress line 2.
citystringCity name.
statestringISO code or name of the state, province or district.
postcodestringPostal code.
countrystringISO code of the country.

Create a customer

This API helps you to create a new customer.

POST /wp-json/wc/v1/customers
curl -X POST https://example.com/wp-json/wc/v1/customers \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
}
}'

Retrieve a customer

This API lets you retrieve and view a specific customer by ID.

GET /wp-json/wc/v1/customers/<id>
curl https://example.com/wp-json/wc/v1/customers/2 \
-u consumer_key:consumer_secret

List all customers

This API helps you to view all the customers.

GET /wp-json/wc/v1/customers
curl https://example.com/wp-json/wc/v1/customers \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit.
pageintegerCurrent page of the collection.
per_pageintegerMaximum number of items to be returned in result set.
searchstringLimit results to those matching a string.
excludestringEnsure result set excludes specific ids.
includestringLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Default is asc, Options: asc and desc.
orderbystringSort collection by object attribute. Default is name. Options: id, include, name and registered_date.
emailstringLimit result set to resources with a specific email.
rolestringLimit result set to resources with a specific role. Default: customer. Options (some plugins can add more user roles): all, administrator, editor, author, contributor, subscriber, customer and shop_manager

Update a customer

This API lets you make changes to a customer.

PUT /wp-json/wc/v1/customers/<id>
curl -X PUT https://example.com/wp-json/wc/v1/customers/2 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"first_name": "James",
"billing": {
"first_name": "James"
},
"shipping": {
"first_name": "James"
}
}'

Delete a customer

This API helps you delete a customer.

DELETE /wp-json/wc/v1/customers/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/customers/2?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringRequired to be true, as resource does not support trashing.

Batch update customers

This API helps you to batch create, update and delete multiple customers.

note

Note: By default it's limited to up to 100 objects to be created, updated or deleted.

POST /wp-json/wc/v1/customers/batch
curl -X POST https://example.com/wp-json/wc/v1/customers/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"email": "john.doe2@example.com",
"first_name": "John",
"last_name": "Doe",
"username": "john.doe2",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
}
},
{
"email": "joao.silva2@example.com",
"first_name": "João",
"last_name": "Silva",
"username": "joao.silva2",
"billing": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR",
"email": "joao.silva@example.com",
"phone": "(55) 5555-5555"
},
"shipping": {
"first_name": "João",
"last_name": "Silva",
"company": "",
"address_1": "Av. Brasil, 432",
"address_2": "",
"city": "Rio de Janeiro",
"state": "RJ",
"postcode": "12345-000",
"country": "BR"
}
}
],
"update": [
{
"id": 5,
"billing": {
"phone": "(11) 1111-1111"
}
}
],
"delete": [
2
]
}'

Retrieve customer downloads

This API lets you retrieve customer downloads permissions.

GET /wp-json/wc/v1/customers/<id>/downloads
curl https://example.com/wp-json/wc/v1/customers/2/downloads \
-u consumer_key:consumer_secret

Customer downloads properties

AttributeTypeDescription
download_urlstringDownload file URL. READ-ONLY
download_idstringDownload ID (MD5). READ-ONLY
product_idintegerDownloadable product ID. READ-ONLY
download_namestringDownloadable file name. READ-ONLY
order_idintegerOrder ID. READ-ONLY
order_keystringOrder key. READ-ONLY
downloads_remainingstringAmount of downloads remaining. READ-ONLY
access_expiresstringThe date when the download access expires, in the site's timezone. READ-ONLY
filearrayFile details with name (file name) and file (file URL) attributes. READ-ONLY