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_created_gmtdate-timeThe date the customer was created, as GMT. READ-ONLY
date_modifieddate-timeThe date the customer was last modified, in the site's timezone. READ-ONLY
date_modified_gmtdate-timeThe date the customer was last modified, as GMT. READ-ONLY
emailstringThe email address for the customer. MANDATORY
first_namestringCustomer first name.
last_namestringCustomer last name.
rolestringCustomer role. READ-ONLY
usernamestringCustomer login name.
passwordstringCustomer password. WRITE-ONLY
billingobjectList of billing address data. See Customer - Billing properties
shippingobjectList of shipping address data. See Customer - Shipping properties
is_paying_customerboolIs the customer a paying customer? READ-ONLY
avatar_urlstringAvatar URL. READ-ONLY
meta_dataarrayMeta data. See Customer - Meta data properties

Customer - Billing 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.

Customer - Shipping 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.

Customer - Meta data properties

AttributeTypeDescription
idintegerMeta ID. READ-ONLY
keystringMeta key.
valuestringMeta value.

Create a customer

This API helps you to create a new customer.

POST /wp-json/wc/v3/customers
curl -X POST https://example.com/wp-json/wc/v3/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/v3/customers/<id>
curl https://example.com/wp-json/wc/v3/customers/25 \
-u consumer_key:consumer_secret

List all customers

This API helps you to view all the customers.

GET /wp-json/wc/v3/customers
curl https://example.com/wp-json/wc/v3/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. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to those matching a string.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific IDs.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is asc.
orderbystringSort collection by object attribute. Options: id, include, name and registered_date. Default is name.
emailstringLimit result set to resources with a specific email.
rolestringLimit result set to resources with a specific role. Options: all, administrator, editor, author, contributor, subscriber, customer and shop_manager. Default is customer.

Update a customer

This API lets you make changes to a customer.

PUT /wp-json/wc/v3/customers/<id>
curl -X PUT https://example.com/wp-json/wc/v3/customers/25 \
-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/v3/customers/<id>
curl -X DELETE https://example.com/wp-json/wc/v3/customers/25?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringRequired to be true, as resource does not support trashing.
reassignintegerUser ID to reassign posts to.

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/v3/customers/batch
curl -X POST https://example.com/wp-json/wc/v3/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": 26,
"billing": {
"phone": "(11) 1111-1111"
}
}
],
"delete": [
25
]
}'

Retrieve customer downloads

This API lets you retrieve customer downloads permissions.

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

Customer downloads properties

AttributeTypeDescription
download_idstringDownload ID (MD5). READ-ONLY
download_urlstringDownload file URL. READ-ONLY
product_idintegerDownloadable product ID. READ-ONLY
product_namestringProduct name. READ-ONLY
download_namestringDownloadable file name. READ-ONLY
order_idintegerOrder ID. READ-ONLY
order_keystringOrder key. READ-ONLY
downloads_remainingstringNumber of downloads remaining. READ-ONLY
access_expiresstringThe date when download access expires, in the site's timezone. READ-ONLY
access_expires_gmtstringThe date when download access expires, as GMT. READ-ONLY
fileobjectFile details. READ-ONLY See Customers downloads - File properties

Customer downloads - File properties

AttributeTypeDescription
namestringFile name. READ-ONLY
filestringFile URL. READ-ONLY