Customers & Recipients

Save the people and businesses you ship to, and reuse them on every shipment.

A customer is someone you ship to often. Saving them means you don't re-enter their name, phone and address on every shipment.

Each customer can have:

  • Contacts — the people you deal with. Each contact chooses which channels they receive shipment notifications on: email, SMS or WhatsApp.
  • Addresses — one for shipping, one for billing. You can store several and mark one as default.
Customer  "Ferretería del Norte"
  ├── Contact  María López · [email protected] · WhatsApp on
  ├── Contact  Warehouse · [email protected]
  ├── Address  shipping · Monterrey, NL, 64000   ← default
  └── Address  billing  · Monterrey, NL, 64100

Customers or saved addresses?
Customers are who you ship to — your recipients.
Saved addresses are your own origin and return addresses.
If you are looking for where to store the warehouse you ship from, that is the other one.

When to use this

If your case is…Use
An online store where buyers rarely repeatYou don't need this. Send the address inline on the shipment
B2B, distribution, or recurring shipments to the same placesCustomers & Recipients
You want the recipient to get WhatsApp notificationsCustomers → contacts with notifications.whatsapp

Before you start

  • Base URL: https://queries.envia.com · Sandbox: https://queries.test.envia.com
  • Auth: Authorization: Bearer <your_token> — the same token as the Shipping API. See Authentication.
  • Before saving an address, check Address requirements by country. Required fields change per country: in Mexico some carriers refuse a label without the colonia in district, Brazil needs a CPF or CNPJ in identificationNumber, and Colombia takes the DANE code in city. Saving an incomplete address makes the shipment fail later — once you have already been charged.

Typical flow

API reference → Create customer · Add customer address · Add customer contact

1. Create the customer

curl -X POST https://queries.test.envia.com/customers \
  -H "Authorization: Bearer $ENVIA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ferretería del Norte",
    "customer_type": "business",
    "company_name": "Ferretería del Norte S.A. de C.V.",
    "rfc": "FNO950101AB1",
    "external_ref": "CLI-00421"
  }'

external_ref is yours: store the ID this customer has in your own system. It lets you reconcile without keeping a mapping table.

The response returns the new ID:

{ "id": 4821 }

2. Add the shipping address

curl -X POST https://queries.test.envia.com/customers/4821/addresses \
  -H "Authorization: Bearer $ENVIA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "address_type": "shipping",
    "is_default": true,
    "address": {
      "name": "Ferretería del Norte",
      "street": "Av. Constitución",
      "number": "1450",
      "district": "Centro",
      "city": "Monterrey",
      "state": "NL",
      "country": "MX",
      "postal_code": "64000",
      "phone_code": "52",
      "phone": "8181234567",
      "email": "[email protected]",
      "alias": "Head office"
    }
  }'

3. Add a contact and turn on WhatsApp

curl -X POST https://queries.test.envia.com/customers/4821/contacts \
  -H "Authorization: Bearer $ENVIA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "María López",
    "email": "[email protected]",
    "phone_code": "52",
    "phone": "8189998877",
    "is_default": true,
    "notifications": { "email": true, "whatsapp": true, "sms": false }
  }'

4. Use it on a shipment

Read the customer back with Get customer and pass its shipping_address as the destination of Generate a shipping label.

Shortcut: you can create the customer, its first contact and both addresses in a single POST /customers call by nesting contact, shipping_address and billing_address. Use the step-by-step endpoints when you want finer control.

Rules worth knowing

These are enforced by the API and are not obvious from the endpoint list:

RuleWhy it matters
A customer must keep at least one address. Deleting the last one returns 400Delete the customer instead if that is what you meant
A customer must keep at least one contact. Deleting the last one returns 400Same
PUT /customers/{id} does not touch contacts or addressesUse their own endpoints
On PUT of an address, address_type is always requiredEven when you only change one field inside address
emptyState in the list response is 1 only when you have no customers at allUse it to tell a first-run empty state from a filter that matched nothing
Customers are scoped to your companyA token only ever sees its own. A 404 on an ID that exists means it is not yours

Endpoints

Next steps


Did this page help you?