Skip to content

Customers ​

zr.customers manages individual customers and their addresses. A parcel's customer.customerId must reference a real customer, so this is often the first namespace you touch before creating parcels.

ts
const page = await zr.customers.search({
  pageSize: 20,
  keyword: 'amine',
  includeAllAddresses: true,
});

Returns a PagedList<CustomerResponse>. Iterate with zr.customers.searchAll(body).

Get one ​

ts
const customer = await zr.customers.get(id); // GET /customers/{id}, with addresses

Create an individual customer ​

ts
const created = await zr.customers.createIndividual({
  name: 'Amine B.',
  phone: { number1: '+213600000000' },   // PhoneDto: number1/number2/number3
  addresses: [
    {
      street: '12 Rue des Frères',
      cityTerritoryId: wilayaId,
      districtTerritoryId: communeId,
      isPrimary: true,
    },
  ],
});

Never retried.

Update & delete ​

ts
await zr.customers.updateIndividual(id, { /* UpdateIndividualCustomerRequest */ });
await zr.customers.delete(id); // DELETE /customers/{id}

Addresses ​

ts
await zr.customers.addAddress(customerId, { /* CreateCustomerAddressRequest */ });
await zr.customers.updateAddress(customerId, addressId, { /* … */ });
await zr.customers.deleteAddress(customerId, addressId);

Excel import ​

ts
const result = await zr.customers.importIndividual({ file: excelBlob, fileName: 'customers.xlsx' });
const template = await zr.customers.downloadImportTemplate(); // ArrayBuffer

Full types in the API Reference.

Released under the MIT License. Not affiliated with ZR Express.