API reference · Customers

Create New Customer

POSThttps://api.sandbox.cws.digital/v1/customer

Description

Registers a customer in your store, with the address and, optionally, the type, group and price tag links.

The created customer can already access the store with the username and password provided.

Request body

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
documentTypestringYes

cpf or pf for an individual; cnpj or pj for a company. No other value is accepted.

documentstringYes

CPF or CNPJ, valid and consistent with the documentType. Alphanumeric CNPJ is accepted.

usernamestringYes

Customer's access e-mail. It must be a valid e-mail.

phonestringYes

Customer's phone.

passwordstringYes

Customer's access password.

customerRegistrationAddressobjectConditional

Customer's registration address. See the rule below.

Fields in customerRegistrationAddress

addressListarray of objectConditional

Customer's delivery addresses. See the rule below.

Fields in addressList[]

namestringNo

Name or corporate name.

tradingNamestringNo

Trade name.

contactNamestringNo

Contact name.

stateRegistrationstringNo

State registration.

cnaestringNo

Customer's CNAE.

paysIcmsbooleanNo

Whether the customer is an ICMS taxpayer.

politicallyExposedPersonbooleanNo

Whether the customer is a politically exposed person.

federalEmployeestringNo

Civil servant: N not a civil servant, SV civil servant, SPF federal civil servant, SPE state civil servant, SPM municipal civil servant.

Allowed values:NSVSPFSPESPM
optinTrackingbooleanNo

Acceptance of tracking by message.

trackingPhonestringNo

Tracking phone.

forceChangePasswordbooleanNo

Requires a password change on the first access.

passwordExpiredbooleanNo

Marks the password as expired. Absent means false.

sendEmailNewCustomerbooleanNo

true sends the first-access e-mail to the customer. The password you sent is never included in that e-mail.

ssoConfigIdintegerNo

SSO configuration. Validated against your store.

priceRuleTagsarray of objectNo

Price tags, by name.

customerTypeListarray of objectNo

Customer types, by name or external_id.

customerGroupListarray of objectNo

Customer groups, by name or external_id.

customerRegistrationAddress
FieldTypeRequiredDescriptionValue
zipcodestringYes

Address ZIP code. It is what resolves street and district — see the Correios rule.

numberstringYes

Number.

complementstringNo

Address complement.

streetstringConditional

Street. See the Correios rule.

quarterstringConditional

District. See the Correios rule.

citystringNo

City.

statestringNo

State (UF).

addressTypestringNo

RESIDENTIAL or BUSINESS. Case-insensitive.

farmerStateRegistrationstringNo

Rural producer state registration.

principalbooleanNo

Marks the address as the principal one.

namestringNo

Address name.

latnumberNo

Coordinates. Accepted only if your store has the latitude/longitude feature enabled.

lngnumberNo

Coordinates. Accepted only if your store has the latitude/longitude feature enabled.

Items of addressList[]
addressList[]
FieldTypeRequiredDescriptionValue
zipcodestringYes

Address ZIP code. It is what resolves street and district — see the Correios rule.

numberstringYes

Number.

complementstringNo

Address complement.

streetstringConditional

Street. See the Correios rule.

quarterstringConditional

District. See the Correios rule.

citystringNo

City.

statestringNo

State (UF).

addressTypestringNo

RESIDENTIAL or BUSINESS. Case-insensitive.

farmerStateRegistrationstringNo

Rural producer state registration.

principalbooleanNo

Marks the address as the principal one.

namestringNo

Address name.

latnumberNo

Coordinates. Accepted only if your store has the latitude/longitude feature enabled.

lngnumberNo

Coordinates. Accepted only if your store has the latitude/longitude feature enabled.

Business rules

customerRegistrationAddress and addressList store different things

Both are addresses, but they go to different places and sending only one of them has different effects:

What you sendWhat the customer gets
Only customerRegistrationAddressRegistration address filled in, and no delivery address — the list stays empty.
Only addressList, with one item principal: trueThe delivery addresses of the list, and the registration address copied from the principal item.
BothThe delivery addresses of the list and the registration address you provided.
Only addressList without any principal: trueRejected — there is no registration address to determine.
NeitherRejected.

The ZIP code rules the address

The address is resolved by Correios from the zipcode: what Correios returns replaces what you sent in street, quarter, city and state.

Of what you send, number and complement are always kept, because Correios does not have this data.

The fields you send work as a fallback: each one is used only when Correios does not bring that data for the ZIP code.

After this combination, street and quarter cannot be empty: if they are, the creation is rejected.

A ZIP code that is not found is also rejected, unless your store has ZIP code validation disabled.

An addressType outside the list becomes RESIDENTIAL

A value other than RESIDENTIAL/BUSINESS is stored as RESIDENTIAL.

Responses

  • 401

    Missing, malformed or expired token.

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request POST \
  --url 'https://api.sandbox.cws.digital/v1/customer' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "documentType": "cpf",
  "document": "46693537308",
  "username": "ana.ribeiro@exemplo.com.br",
  "name": "Ana Paula Ribeiro",
  "contactName": "Ana Paula Ribeiro",
  "phone": "11987654321",
  "password": "sua-senha",
  "optinTracking": true,
  "trackingPhone": "11987654321",
  "customerRegistrationAddress": {
    "zipcode": "01310-100",
    "street": "Avenida Paulista",
    "number": "1578",
    "complement": "Conjunto 42",
    "quarter": "Bela Vista",
    "city": "São Paulo",
    "state": "SP",
    "addressType": "RESIDENTIAL",
    "principal": true
  }
}'

Response

Click Try it to see the real response here, or pick a documented example: