API reference · Callbacks and Webhooks

Customers Webhook Payload

POSTWebhook

Description

This is an example payload for the Customers Webhook, sent when a customer is created or updated on the CWS platform.

The registration comes in data, always with all the fields: what the customer does not have comes empty (empty text, 0, false or null).

A date without a value comes as 0001-01-01T00:00:00Z.

Respond 200, 201 or 202 to confirm the receipt: CWS does not read the response body. On 401, CWS gets a new token and resends the notification once; any other status, 204 included, counts as a delivery failure.

Parameters

Headers

FieldTypeDescription
Authorizationstring

CWS's credential on your endpoint: Bearer <token>, with the token CWS got from your store's authentication endpoint, or Basic <credential>, when your store's integration uses a fixed credential.

Payload

FieldTypeDescription
operationstring

Operation that triggered the notification: INSERT, UPDATE or DELETE.

dataobject

Customer registration.

Fields in data

data
FieldTypeDescription
idinteger

Customer id at CWS.

documentstring

Customer's CPF or CNPJ.

namestring

Name or corporate name.

tradingNamestring

Trading name.

contactNamestring

Contact name.

documentTypestring

pf (individual) or pj (company).

dateCreatedstring

Date and time of the registration.

lastUpdatedstring

Date and time of the registration's last change.

emailstring

Customer's login e-mail.

phonestring

Phone.

optinTrackingboolean

Whether the tracking opt-in is active.

trackingPhonestring

Tracking mobile phone.

stateRegistrationstring

State registration.

genrestring

Sex: MALE or FEMALE.

birthdatestring

Date of birth.

cnaestring

Customer's CNAE.

politicallyExposedPersonboolean

Whether it is a politically exposed person.

federalEmployeestring

Public servant: N not a public servant, SV public servant, SPF federal, SPE state, SPM municipal public servant.

addressarray of object

Customer's addresses.

Fields in data.address[]

priceRuleTagarray of object

Always null in this webhook.

Fields in data.priceRuleTag[]

priceTypeobject

Always with empty id and name in this webhook.

Fields in data.priceType

registrationAddressobject

Registration address.

Fields in data.registrationAddress

customerAttributesarray of object

Custom attributes of the customer's registration.

Fields in data.customerAttributes[]

customerTypeListarray of object

Linked customer types.

Fields in data.customerTypeList[]

customerGroupListarray of object

Linked customer groups.

Fields in data.customerGroupList[]

customerRuralComplementobject
carsarray of object

Customer's Rural Environmental Registries (CAR).

Fields in data.cars[]

unassociatedCarsarray of object

Customer's CARs without an associated address.

Fields in data.unassociatedCars[]

lastUpdatedByobject

Seller who made the change, when it came from a seller; without a seller, the fields come empty.

Fields in data.lastUpdatedBy

data.address[]
FieldTypeDescription
idinteger

Address id.

namestring

Address name.

streetstring

Street.

numberstring

Number.

complementstring

Complement.

quarterstring

Neighborhood.

citystring

City.

statestring

State (UF).

zipcodestring

ZIP code (CEP).

principalboolean

Whether it is the main address.

addressTypestring

RESIDENTIAL or BUSINESS.

farmerStateRegistrationstring

Rural producer's state registration.

howToReachLocationDescriptionstring
addressAttributesarray of object

Always null in this webhook.

Fields in data.address[].addressAttributes[]

addressRuralComplementobject | null
agronomicProfileobject
dateCreatedstring

Date and time the address was registered.

lastUpdatedstring

Date and time of the address's last change.

data.address[].addressAttributes[]
FieldTypeDescription
namestring

Attribute name.

valuestring

Attribute value.

data.address[].addressRuralComplement
FieldTypeDescription
bpCodestring
indeaIdentificationNumberinteger
indeaStatusboolean
isLeasedboolean
lessorCpfstring
lessorPhonestring
lessorNamestring
leasedAreanumber
ieStatusstring
ieIndustrialSectorstring
ieBusinessNamestring
ieCharacterizedAsSocietyboolean
radiusinteger
membersIELinkarray of object
data.address[].addressRuralComplement.membersIELink[]
FieldTypeDescription
idinteger
memberCpfstring
data.address[].agronomicProfile
FieldTypeDescription
consolidatedFarmableAreanumber
consolidatedProductiveAreasarray of object
associatedCarsarray of object
data.address[].agronomicProfile.consolidatedProductiveAreas[]
FieldTypeDescription
commodityobject
cropobject
areaHanumber
originstring
data.address[].agronomicProfile.consolidatedProductiveAreas[].commodity
FieldTypeDescription
idstring
culturestring
data.address[].agronomicProfile.consolidatedProductiveAreas[].crop
FieldTypeDescription
idstring
cropNamestring
data.address[].agronomicProfile.associatedCars[]
FieldTypeDescription
idinteger
namestring
data.priceRuleTag[]
FieldTypeDescription
idstring
namestring
data.priceType
FieldTypeDescription
idstring
namestring
data.registrationAddress
FieldTypeDescription
streetstring

Street.

numberstring

Number.

complementstring

Complement.

quarterstring

Neighborhood.

citystring

City.

statestring

State (UF).

zipcodestring

ZIP code (CEP).

addressTypestring

RESIDENTIAL or BUSINESS.

howToReachLocationDescriptionstring
farmerStateRegistrationstring

Rural producer's state registration.

data.customerAttributes[]
FieldTypeDescription
namestring

Attribute name.

valuestring

Attribute value.

data.customerTypeList[]
FieldTypeDescription
idinteger

Customer type id.

namestring

Customer type name.

data.customerGroupList[]
FieldTypeDescription
idinteger

Customer group id.

namestring

Customer group name.

externalIdstring

Customer group's external id.

typestring

Name of the group type.

codeTypeinteger

Id of the group type.

data.customerRuralComplement
FieldTypeDescription
cndIdentificationNumberinteger
cndInstitutionAuthNumberstring
cndValidFromstring
cndValidUntilstring
billingContactstring
documentRegistrationStatusstring
data.cars[]
FieldTypeDescription
idinteger
namestring
totalAreaHanumber
farmableAreaHanumber
citystring
statestring
isThirdPartyLeaseboolean

Always false in this webhook.

isCustomerLeaseboolean

Always false in this webhook.

isOwnLeaseboolean

Always false in this webhook.

originstring
agriculturalAreanumber
cornProductionAreanumber
soybeanProductionAreanumber
socioEnvironmentalAnalysisstring
statusstring
productiveAreasarray of object
dateCreatedstring
lastUpdatedstring
data.cars[].productiveAreas[]
FieldTypeDescription
commodityobject
cropobject
areaHanumber
data.cars[].productiveAreas[].commodity
FieldTypeDescription
idstring
culturestring
data.cars[].productiveAreas[].crop
FieldTypeDescription
idstring
cropNamestring
data.unassociatedCars[]
FieldTypeDescription
idinteger
namestring
data.lastUpdatedBy
FieldTypeDescription
agentTypestring

Seller type (attendant for the seller type).

emailstring

Seller's login e-mail.

documentstring

Seller's document.

agentCodestring

Seller code.

agentPartnersarray of object

Seller's partners.

Fields in data.lastUpdatedBy.agentPartners[]

data.lastUpdatedBy.agentPartners[]
FieldTypeDescription
partnerIdinteger

Partner id at CWS.

companyNamestring

Partner's corporate name.

documentstring

Partner's document.

defaultPartnerboolean

Whether it is the seller's default partner.

Business customer with registration address
{
  "operation": "UPDATE",
  "data": {
    "id": 547322,
    "document": "57.578.030/0001-05",
    "name": "Comercial Aurora Ltda",
    "tradingName": "Aurora Distribuidora",
    "contactName": "Marcos Aurélio",
    "documentType": "pj",
    "dateCreated": "2023-01-25T19:59:58Z",
    "lastUpdated": "2023-01-25T19:59:58Z",
    "email": "compras@auroradistribuidora.com.br",
    "phone": "(11) 98765-4321",
    "optinTracking": true,
    "trackingPhone": "(11) 98765-4321",
    "stateRegistration": "123456789",
    "genre": "",
    "birthdate": "",
    "cnae": "4530703",
    "politicallyExposedPerson": false,
    "federalEmployee": "N",
    "address": [
      {
        "id": 1060461,
        "name": "Endereço de cadastro",
        "street": "Avenida Paulista",
        "number": "1578",
        "complement": "Conjunto 42",
        "quarter": "Bela Vista",
        "city": "São Paulo",
        "state": "SP",
        "zipcode": "01310-100",
        "principal": true,
        "addressType": "BUSINESS",
        "farmerStateRegistration": "",
        "howToReachLocationDescription": "",
        "addressAttributes": [],
        "addressRuralComplement": null,
        "agronomicProfile": {
          "consolidatedFarmableArea": 0,
          "consolidatedProductiveAreas": [],
          "associatedCars": []
        },
        "dateCreated": "2023-01-25T19:59:58Z",
        "lastUpdated": "2023-01-25T19:59:58Z"
      }
    ],
    "priceRuleTag": [],
    "priceType": {
      "id": "",
      "name": ""
    },
    "registrationAddress": {
      "street": "Avenida Paulista",
      "number": "1578",
      "complement": "Conjunto 42",
      "quarter": "Bela Vista",
      "city": "São Paulo",
      "state": "SP",
      "zipcode": "01310-100",
      "addressType": "BUSINESS",
      "howToReachLocationDescription": "",
      "farmerStateRegistration": ""
    },
    "customerAttributes": [],
    "customerTypeList": [],
    "customerGroupList": [],
    "customerRuralComplement": {
      "cndIdentificationNumber": 0,
      "cndInstitutionAuthNumber": "",
      "cndValidFrom": "0001-01-01T00:00:00Z",
      "cndValidUntil": "0001-01-01T00:00:00Z",
      "billingContact": "",
      "documentRegistrationStatus": ""
    },
    "cars": [],
    "unassociatedCars": [],
    "lastUpdatedBy": {
      "agentType": "",
      "email": "",
      "document": "",
      "agentCode": "",
      "agentPartners": []
    }
  }
}

Expected response

  • 200

    Confirm with 200, 201 or 202.