Customers


Customer Model

Properties

  • Name
    id
    Type
    string,null
    Description

    The unique identifier for the customer.

  • Name
    first_name
    Type
    string,null
    Restrictions
    Description
  • Name
    last_name
    Type
    string,null
    Restrictions
    Description
  • Name
    primary_email
    Type
    string,null(idn-email)
    Restrictions
    Description

    The primary email address of the customer. This email must be valid and able to receive email or the request will fail.

  • Name
    primary_phone_number
    Type
    string,null
    Restrictions
    Description

    The primary phone number of the customer in E.164 format.

  • Name
    marketplaces
    Type
    object,null
    Restrictions
    Description

    An object containing the mappings for the given customer to it's counterpart on an external marketplace. All external customer IDs should be passed as strings, regardless of original type.

  • Name
    » ^[a-zA-Z0-9_]{0,50}$
    Type
    array
    Restrictions
    Description
  • Name
    » **additionalProperties**
    Type
    string
    Restrictions
    Description
  • Name
    email_addresses
    Type
    array,null
    Restrictions
    Description

    An array containing the email records associated with the customer.

  • Name
    phone_numbers
    Type
    array,null
    Restrictions
    Description

    An array containing the phone number records associated with the customer.

  • Name
    addresses
    Type
    array,null
    Restrictions
    Description

    An array containing the addresses associated with the customer.

  • Name
    created_at
    Type
    string,null(date-time)
    Description
  • Name
    updated_at
    Type
    string,null(date-time)
    Description
{
  "first_name": "Francesca",
  "last_name": "Brady",
  "primary_email": "[email protected]",
  "primary_phone_number": "+4478 6085 0915",
  "marketplaces": {
    "shopify": [
      "gid://shopify/Customer/12673496781"
    ],
    "magento2": [
      "35167221"
    ]
  }
}

Customer Email Address Model

Properties

  • Name
    id
    Type
    string
    Description

    The unique ID of the email address record

  • Name
    address_text
    Type
    string(idn-email)
    Restrictions
    Description

    The ASCII representation of the email address.

  • Name
    is_primary
    Type
    boolean
    Restrictions
    Description

    Whether the email address is the primary email linked to the customer.

  • Name
    type
    Type
    string,null
    Restrictions
    Description

    The type of the email, as a freeform string. Eg. Work, Personal

{
  "id": "eml_28ciP0UvjhtT6JYgwm3YAAD2F2w",
  "address_text": "[email protected]",
  "is_primary": true,
  "type": "Work"
}

Customer Phone Number Model

Properties

  • Name
    id
    Type
    string
    Description

    The unique ID of the phone number record

  • Name
    phone_number_text
    Type
    string
    Restrictions
    Description

    The E.164 representation of the phone number.

  • Name
    is_primary
    Type
    boolean
    Restrictions
    Description

    Whether the phone number is the primary phone number linked to the customer.

  • Name
    type
    Type
    string,null
    Restrictions
    Description

    The type of the phone number, as a freeform string. Eg. Work, Personal

{
  "id": "phne_28ciMELzpW48jQt4O88QItGtuxX",
  "phone_number_text": "+447023732369",
  "is_primary": true,
  "type": "Work"
}

Address Model

Properties

  • Name
    id
    Type
    string,null
    Description

    The unique identifier for the address.

  • Name
    address
    Type
    object
    Restrictions
    Description
  • Name
    » line_1
    Type
    string
    Restrictions
    Description
  • Name
    » line_2
    Type
    string,null
    Restrictions
    Description
  • Name
    » line_3
    Type
    string,null
    Restrictions
    Description
  • Name
    » city
    Type
    string
    Restrictions
    Description
  • Name
    » province
    Type
    string,null
    Restrictions
    Description
  • Name
    » post_code
    Type
    string
    Restrictions
    Description
  • Name
    » country_code
    Type
    string
    Restrictions
    Description
  • Name
    contact
    Type
    object
    Restrictions
    Description
  • Name
    » name
    Type
    string,null
    Restrictions
    Description
  • Name
    » company
    Type
    string,null
    Restrictions
    Description
  • Name
    » email_address
    Type
    string,null(idn-email)
    Restrictions
    Description

    The email associated with the given address if available.

  • Name
    » phone_number
    Type
    string,null
    Restrictions
    Description

    The phone number associated with the given address if available.

  • Name
    display_name
    Type
    string,null
    Restrictions
    Description
  • Name
    metadata
    Type
    object,null
    Restrictions
    Description

    An object containing a series of key/value pairs of metadata that will be attached to the address. A maximum of 50 pairs is allowed. Keys and values must both be strings containing alphanumeric characters.

  • Name
    » ^[a-zA-Z0-9_]{0,50}$
    Type
    string
    Restrictions
    Description
  • Name
    marketplaces
    Type
    object,null
    Restrictions
    Description

    An object containing the mappings for the given address to it's counterpart on an external marketplace. All external address IDs should be passed as strings, regardless of original type.

  • Name
    » ^[a-zA-Z0-9_]{0,50}$
    Type
    string
    Restrictions
    Description
  • Name
    location_id
    Type
    string,null
    Restrictions
    Description

    Present in certain requests where there is an option to use the address associated with a given location ID.

  • Name
    coordinates
    Type
    [Coordinates](#schemacoordinates)
    Restrictions
    Description

    A set of latitude/longitude coordinates, which may optionally contain a confidence score from 0.0 - 1.0 if the coordinates are the result of geocoding.

{
  "address": {
    "line_1": "29 Holgate Rd",
    "line_2": "Segwick Street",
    "line_3": "Kelvedon",
    "city": "RACKWICK",
    "province": "Cambershire",
    "post_code": "KW16 2PE",
    "country_code": "GB"
  },
  "contact": {
    "name": "Francesca Brady",
    "company": "Malvinex Corp"
  },
  "display_name": "Work",
  "metadata": {
    "contact_email": "[email protected]"
  },
  "marketplaces": {
    "shopify": "657847832011"
  },
  "coordinates": {
    "latitude": 51.5134297,
    "longitude": -0.103145,
    "confidence": 1
  }
}

Coordinates Model

Properties

  • Name
    Coordinates
    Type
    object,null
    Restrictions
    Description

    A set of latitude/longitude coordinates, which may optionally contain a confidence score from 0.0 - 1.0 if the coordinates are the result of geocoding.

  • Name
    latitude
    Type
    number(double)
    Restrictions
    Description
  • Name
    longitude
    Type
    number(double)
    Restrictions
    Description
  • Name
    confidence
    Type
    number,null(float)
    Restrictions
    Description

    A confidence score associated with the cordinates, indicating how accurately they represent the address.

    For manually set coordinates, set the confidence score to 1 to indicate that the location has been manually specified/verified.

{
  "latitude": 51.7864239,
  "longitude": -0.9725901,
  "confidence": 0.9201
}

GET/customers

Get Customers

Retrieve a list of customers associated with an organisation. Also allows for searching by email or phone number.

Query Parameters

  • Name
    phone_number
    Type
    string
    Restrictions
    Description

    A phone number associated with the customer. Must be E.164 formatted.

  • Name
    email_address
    Type
    string(idn-email)
    Restrictions
    Description

    An email address associated with the customer.

  • Name
    marketplace
    Type
    string
    Restrictions
    Description

    If searching by marketplace ID(s), this parameter is required and must specify the marketplace to search.

  • Name
    marketplace_id
    Type
    array
    Restrictions
    Description

    One or more customer marketplace IDs to search for. Requires the marketplace parameter to also be specified.

  • Name
    id
    Type
    array
    Restrictions
    Description

    One or more customer IDs to retrieve.

  • Name
    cursor
    Type
    string
    Restrictions
    Description

    A pagination pointer supplied in a previous request.

  • Name
    results
    Type
    integer
    Restrictions
    Description

    A number representing the maximum number of results that the request should return. A value with a minimum of 10 and a maximum of 100 is allowed. Any request for results outside this range will return the nearest bound.

Request

GET
/customers
curl --request GET \
--url https://api.envoy.one/customers \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{
  "data": [
    {
      "addresses": [
        {
          "address": {
            "city": "RACKWICK",
            "country_code": "GB",
            "line_1": "29 Holgate Rd",
            "line_2": null,
            "line_3": null,
            "post_code": "KW16 2PE",
            "province": null
          },
          "contact": {
            "company": null,
            "name": "Francesca Brady"
          },
          "display_name": "Work",
          "id": "addr_28cieh8cInlz85cQZiRzjSYJssI",
          "marketplaces": {},
          "metadata": {
            "contact_email": "[email protected]"
          }
        }
      ],
      "email_addresses": [
        {
          "address_text": "[email protected]",
          "id": "eml_28ciEfVgqUBqrjNlNaawrWoeYHa",
          "is_primary": true,
          "type": null
        },
        {
          "address_text": "[email protected]",
          "id": "eml_28ciP0UvjhtT6JYgwm3YAAD2F2w",
          "is_primary": false,
          "type": null
        }
      ],
      "first_name": "Francesca",
      "id": "cus_28ciEisyBRsQZ2jBMIrrpIrJFqh",
      "last_name": "Brady",
      "marketplaces": {
        "magento2": [
          "43687TAY8AE8O"
        ],
        "shopify": [
          "64539812426"
        ]
      },
      "phone_numbers": [
        {
          "id": "phne_28ciEeNMWryFqGm8oY7Cbzf1c73",
          "is_primary": true,
          "phone_number_text": "+447860850915",
          "type": null
        },
        {
          "id": "phne_28ciMELzpW48jQt4O88QItGtuxX",
          "is_primary": false,
          "phone_number_text": "+447023732369",
          "type": null
        }
      ],
      "primary_email": "[email protected]",
      "primary_phone_number": "+447860850915"
    }
  ],
  "next_cursor": null,
  "previous_cursor": null,
  "limit": 20
}

undefined


POST/customers

Create Customer

Create a new customer.

Attaching addresses to the customer at the point of creation is not currently supported, and must be done with a subsequent request to the relevant endpoint.

Creating Customers with Existing Details

When creating a customer, it is possible that the primary email address or phone number that is supplied is in use by another customer. This can commonly occur in situations such as:

  • A couple using a shared email address.
  • A person ordering for multiple people from their account.
  • The phone number provided being a landline or a switchboard, eg. a work phone number.

In situations such as these, requiring email addresses/phone numbers to be unique would require us to return an error if someone attempted to create a new customer with conflicting details. As orders will generally come from external systems where we may be unable to request that the customer provide an alternative set of details, we instead allow email addresses and phone numbers to be assigned to multiple customers, and provide no guarantees of uniqueness.

To find customers associated with an email or phone number, the Get Customers endpoint provides filters for email addresses and phone numbers, which can be used to retrieve a list of customers associated with a given identifier, and to check if a customer exists beforehand to avoid creating duplicates.

Request

POST
/customers
curl --request POST \
--url https://api.envoy.one/customers \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"first_name":"Kevin","last_name":"Baxter","primary_email":"[email protected]","primary_phone_number":"+447860850915"}'

Response

{
  "addresses": [],
  "email_addresses": [
    {
      "address_text": "[email protected]",
      "id": "eml_29LUDEiV6jcwcJlAetCd0uO5t2r",
      "is_primary": true,
      "type": null
    }
  ],
  "first_name": "Kevin",
  "id": "cus_29LUDIdztCr9cpN0YyGM8hxsW6S",
  "last_name": "Baxter",
  "marketplaces": {},
  "phone_numbers": [
    {
      "id": "phne_29LUDHn2Dp1mn1npS0qWlo7eiUG",
      "is_primary": true,
      "phone_number_text": "+447493650915",
      "type": null
    }
  ],
  "primary_email": "[email protected]",
  "primary_phone_number": "+447493650915"
}

undefined


PUT/customers/bulk

Bulk Update Customers

Endpoint for bulk updating customer details.

The nature of this endpoint means that the following behaviour is present here that is not present on other endpoints:

  • Metadata and marketplace fields are added to those that are already present. Such fields cannot be deleted using this endpoint, and instead must use the update customer endpoint. At a later date it will be possible to delete metadata fields by passing a null value for the key that should be deleted.

  • All entries must contain a customer ID. If any customer ID is missing or invalid, the request will fail.

  • The endpoint will not return validation errors for individual entries in the request if present, but will instead fail with a generic validation error.

  • In the event that the request contains conflicting marketplace IDs (i.e. the client attempts to assign an ID to a customer when it has already been assigned to a different customer), the request will fail, and the error message will contain a list of the existing customer IDs that are already assigned to the specified ID.

  • Addresses can be created/updated for a customer using this endpoint. Addresses that are to be updated must pass the ID of the address to be updated, otherwise a new address will be created. It is the responsibility of the client to ensure updates to addresses are reflected in 3rd party platforms, as in many cases the platforms do not provide a mechanism to update addresses once created, and we do not create a new address & ID on 3rd party providers, as this has the potential to cause confusion if done automatically.

Detailed descriptions

»»»»»» confidence: A confidence score associated with the cordinates, indicating how accurately they represent the address.

For manually set coordinates, set the confidence score to 1 to indicate that the location has been manually specified/verified.

Request

PUT
/customers/bulk
curl --request PUT \
--url https://api.envoy.one/customers/bulk \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"customers":[{"first_name":"Francesca","last_name":"Brady","primary_email":"[email protected]","primary_phone_number":"+4478 6085 0915","marketplaces":{"shopify":["gid://shopify/Customer/12673496781"],"magento2":["35167221"]}}]}'

Response

{
  "data": [
    {
      "id": "cus_2VJyUrMWv1T1UkOh0FkWGiGSX4h",
      "first_name": "Sarah",
      "last_name": "Chivers",
      "primary_email": "[email protected]",
      "primary_phone_number": "+447371917407",
      "marketplaces": {
        "shopify": [
          "gid://shopify/Customer/12673496781",
          "gid://shopify/Customer/7845327584"
        ]
      },
      "addresses": [
        {
          "id": "addr_2VJyUt3RuYaeEbrH2IRuwOprcpW",
          "contact": {
            "name": "Sarah Chivers",
            "company": null
          },
          "display_name": "Work",
          "address": {
            "line_1": "30 Holgate Rd",
            "line_2": null,
            "line_3": null,
            "city": "RACKWICK",
            "province": null,
            "post_code": "KW16 2PE",
            "country_code": "GB"
          },
          "metadata": {},
          "marketplaces": {
            "shopify": "gid://shopify/Address/47239593938"
          }
        }
      ],
      "email_addresses": [
        {
          "id": "eml_2VJyUtgAp7ds07wTDIEYrqBa7fx",
          "address_text": "[email protected]",
          "type": null,
          "is_primary": true
        }
      ],
      "phone_numbers": [
        {
          "id": "phne_2VJyUulYdQQpxyGCKuktPRLmSoD",
          "phone_number_text": "+447371917407",
          "type": null,
          "is_primary": true
        }
      ],
      "created_at": "2023-09-13T01:28:16.683215",
      "updated_at": "2023-09-13T01:28:16.683222"
    },
    {
      "id": "cus_2VJyUscAKvMjXTuaHG5Zdghsa4K",
      "first_name": "Austin",
      "last_name": "Smith",
      "primary_email": "[email protected]",
      "primary_phone_number": "+447623748594",
      "marketplaces": {
        "shopify": [
          "gid://shopify/Customer/74528935114"
        ]
      },
      "addresses": [],
      "email_addresses": [
        {
          "id": "eml_2VJyUsVOjli9GnkzmEA2dD9WBNN",
          "address_text": "[email protected]",
          "type": null,
          "is_primary": true
        }
      ],
      "phone_numbers": [
        {
          "id": "phne_2VJyUskukZWWf1SEughFQTwbs9V",
          "phone_number_text": "+447623748594",
          "type": null,
          "is_primary": true
        }
      ],
      "created_at": "2023-09-13T01:28:16.736589",
      "updated_at": "2023-09-13T01:28:16.736597"
    }
  ],
  "errors": []
}

undefined


POST/customers/bulk

Bulk Create Customers

Endpoint for bulk creating customers.

The nature of this endpoint means that the following behaviour is present here that is not present on other endpoints:

  • Addresses and marketplaces can be supplied as part of the request, and will be created at the same time the customer is created
  • Conflicting IDs in the case of marketplaces will cause a partial failure, which will be present in the errors parameter.

In the event of the request being partially successful, a 202 Accepted status is returned, and the errors field of the response contains details of the elements that failed to create. In the event that all customers in the request are successfully created, a 201 Created status is returned.

In both cases, the data parameter of the response will contain the customers that were successfully created.

Detailed descriptions

»»»»»» confidence: A confidence score associated with the cordinates, indicating how accurately they represent the address.

For manually set coordinates, set the confidence score to 1 to indicate that the location has been manually specified/verified.

Request

POST
/customers/bulk
curl --request POST \
--url https://api.envoy.one/customers/bulk \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"customers":[{"first_name":"Francesca","last_name":"Brady","primary_email":"[email protected]","primary_phone_number":"+4478 6085 0915","marketplaces":{"shopify":["gid://shopify/Customer/12673496781"],"magento2":["35167221"]}}]}'

Response

{
  "data": [
    {
      "first_name": "Francesca",
      "last_name": "Brady",
      "primary_email": "[email protected]",
      "primary_phone_number": "+4478 6085 0915",
      "marketplaces": {
        "shopify": [
          "gid://shopify/Customer/12673496781"
        ],
        "magento2": [
          "35167221"
        ]
      }
    }
  ],
  "errors": [
    {
      "code": "parameter_invalid",
      "message": "string",
      "param": "string",
      "type": "invalid_request"
    }
  ]
}

undefined


GET/customers/{customer_id}

Get Customer

Retrieve an individual customer by the unique ID.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

GET
/customers/{customer_id}
curl --request GET \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{
  "addresses": [
    {
      "address": {
        "city": "RACKWICK",
        "country_code": "GB",
        "line_1": "29 Holgate Rd",
        "line_2": null,
        "line_3": null,
        "post_code": "KW16 2PE",
        "province": null
      },
      "contact": {
        "company": null,
        "name": "Francesca Brady"
      },
      "display_name": "Work",
      "id": "addr_28cieh8cInlz85cQZiRzjSYJssI",
      "marketplaces": {},
      "metadata": {
        "contact_email": "[email protected]"
      }
    }
  ],
  "email_addresses": [
    {
      "address_text": "[email protected]",
      "id": "eml_28ciEfVgqUBqrjNlNaawrWoeYHa",
      "is_primary": true,
      "type": null
    },
    {
      "address_text": "[email protected]",
      "id": "eml_28ciP0UvjhtT6JYgwm3YAAD2F2w",
      "is_primary": false,
      "type": null
    }
  ],
  "first_name": "Francesca",
  "id": "cus_28ciEisyBRsQZ2jBMIrrpIrJFqh",
  "last_name": "Brady",
  "marketplaces": {
    "magento2": [
      "43687TAY8AE8O"
    ],
    "shopify": [
      "64539812426"
    ]
  },
  "phone_numbers": [
    {
      "id": "phne_28ciEeNMWryFqGm8oY7Cbzf1c73",
      "is_primary": true,
      "phone_number_text": "+447860850915",
      "type": null
    },
    {
      "id": "phne_28ciMELzpW48jQt4O88QItGtuxX",
      "is_primary": false,
      "phone_number_text": "+447023732369",
      "type": null
    }
  ],
  "primary_email": "[email protected]",
  "primary_phone_number": "+447860850915"
}

undefined


PUT/customers/{customer_id}

Update Customer

Update the attributes of a given customer.

N.B. It is currently not possible to update the emails, phone numbers or addresses associated with the customer with this method. Such updates should be carried out using the dedicated endpoints.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

PUT
/customers/{customer_id}
curl --request PUT \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"first_name":"Francesca","last_name":"Brady","primary_email":"[email protected]","primary_phone_number":"+447860850915","marketplaces":{"shopify":["64539812426"],"magento2":["43687TAY8AE8O"]}}'

Response

{
  "addresses": [],
  "email_addresses": [
    {
      "address_text": "[email protected]",
      "id": "eml_29LUDEiV6jcwcJlAetCd0uO5t2r",
      "is_primary": true,
      "type": null
    }
  ],
  "first_name": "Kevin",
  "id": "cus_29LUDIdztCr9cpN0YyGM8hxsW6S",
  "last_name": "Baxter",
  "marketplaces": {},
  "phone_numbers": [
    {
      "id": "phne_29LUDHn2Dp1mn1npS0qWlo7eiUG",
      "is_primary": true,
      "phone_number_text": "+447493650915",
      "type": null
    }
  ],
  "primary_email": "[email protected]",
  "primary_phone_number": "+447493650915"
}

undefined


DELETE/customers/{customer_id}

Delete Customer

Deletes a customer with the specified ID.

If successful, a 204 status code is returned. If the customer has already been deleted or otherwise could not be located, a 404 error is returned.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

DELETE
/customers/{customer_id}
curl --request DELETE \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{}

undefined


HEAD/customers/{customer_id}

Check Customer Exists

Check if the customer exists in the database. This request is functionally identical to the Get Customer endpoint, except that no response body is returned.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

HEAD
/customers/{customer_id}
curl --request HEAD \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh \
--header 'Authorization: Bearer {access-token}'

undefined


GET/customers/{customer_id}/email_addresses

Get Customer Email Addresses

Retrieves all the email addresses associated with a given customer.

As described in Create Customer, these email addresses are not guaranteed ot be unique to the customer.

All emails are returned in one request, there is currently no pagination implemented.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

GET
/customers/{customer_id}/email_addresses
curl --request GET \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/email_addresses \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{
  "data": [
    {
      "id": "eml_28ciP0UvjhtT6JYgwm3YAAD2F2w",
      "address_text": "[email protected]",
      "is_primary": true,
      "type": "Work"
    },
    {
      "id": "eml_28ciP0UvjhtT6JYgwm3YAAD2F2w",
      "address_text": "[email protected]",
      "is_primary": false,
      "type": "Personal"
    }
  ]
}

undefined


POST/customers/{customer_id}/email_addresses

Add Customer Email Address

Add an email address to the specified customer.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

POST
/customers/{customer_id}/email_addresses
curl --request POST \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/email_addresses \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"address_text":"[email protected]","is_primary":false,"type":"Secondary"}'

Response

{
  "id": "eml_0ujsszwN8NRY24YaXiTIE2VWDTS",
  "address_text": "[email protected]",
  "is_primary": false,
  "type": "Secondary"
}

undefined


DELETE/customers/{customer_id}/email_addresses/{email_address_id}

Delete Customer Email Address

Delete an email address associated with a given customer.

At any given point a customer must have either a primary phone number or a primary email attached to their profile. Attempting to delete an email address will thus fail if the customer would be left without an email address or password attached to their account.

In the event that the email being deleted is the primary email, and the customer has an alternate email attached to their profile, the alternate email will automatically be assigned as the new primary email.

It is the end user's responsibility to ensure that any required consent from the customer to receive communication at the new primary email is gathered beforehand if necessary.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

  • Name
    email_address_id
    Type
    string
    Restrictions
    Description

    The unique ID for the email address.

Request

DELETE
/customers/{customer_id}/email_addresses/{email_address_id}
curl --request DELETE \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/email_addresses/eml_28ciP0UvjhtT6JYgwm3YAAD2F2w \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

undefined


GET/customers/{customer_id}/phone_numbers

Get Customer Phone Numbers

Retrieves all the phone numbers associated with a given customer.

As described in Create Customer, these phone numbers are not guaranteed ot be unique to the customer.

All phone numbers are returned in one request, there is currently no pagination implemented.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

GET
/customers/{customer_id}/phone_numbers
curl --request GET \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/phone_numbers \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{
  "data": [
    {
      "id": "phne_0ujssxh0cECutqzMgbtXSGnjorm",
      "phone_number_text": "+447860850915",
      "is_primary": true,
      "type": "Work"
    },
    {
      "id": "phne_0ujsszgFvbiEr7CDgE3z8MAUPFt",
      "phone_number_text": "+447023732369",
      "is_primary": false,
      "type": null
    }
  ]
}

undefined


POST/customers/{customer_id}/phone_numbers

Add Customer Phone Number

Add a phone number to the specified customer.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

POST
/customers/{customer_id}/phone_numbers
curl --request POST \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/phone_numbers \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"phone_number_text":"+447295620561","is_primary":false,"type":"Office"}'

Response

{
  "id": "phne_0ujsswThIGTUYm2K8FjOOfXtY1K",
  "phone_number_text": "447295620561",
  "is_primary": false,
  "type": "Office"
}

undefined


DELETE/customers/{customer_id}/phone_numbers/{phone_number_id}

Delete Customer Phone Number

Delete an email address associated with a given customer.

At any given point a customer must have either a primary phone number or a primary email attached to their profile. Attempting to delete an email address will thus fail if the customer would be left without an email address or password attached to their account.

In the event that the email being deleted is the primary email, and the customer has an alternate email attached to their profile, the alternate email will automatically be assigned as the new primary email.

It is the end user's responsibility to ensure that any required consent from the customer to receive communication at the new primary email is gathered beforehand if necessary.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

  • Name
    phone_number_id
    Type
    string
    Restrictions
    Description

    The unique ID for the phone number.

Request

DELETE
/customers/{customer_id}/phone_numbers/{phone_number_id}
curl --request DELETE \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/phone_numbers/phne_0ujsszgFvbiEr7CDgE3z8MAUPFt \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

undefined


GET/customers/{customer_id}/addresses

Get Customer Addresses

Retrieves all the postal addresses for a given customer.

All addresses are returned in a single request, there is no pagination implemented currently.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Request

GET
/customers/{customer_id}/addresses
curl --request GET \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/addresses \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{
  "data": [
    {
      "address": {
        "city": "HAVENHAM",
        "country_code": "GB",
        "line_1": "21 Broad Street",
        "line_2": "Great Oak Road",
        "line_3": null,
        "post_code": "HA16 5RT",
        "province": "Cambershire"
      },
      "contact": {
        "company": null,
        "name": "Christopher Richards"
      },
      "display_name": "UK Home",
      "id": "addr_28chumc6QjHu5muPOyiCWL0o7RD",
      "marketplaces": {},
      "metadata": {
        "access_code": "125367"
      }
    },
    {
      "address": {
        "city": "BIG SPRING",
        "country_code": "US",
        "line_1": "3249 Scenicview Drive",
        "line_2": null,
        "line_3": null,
        "post_code": "79720",
        "province": "TX"
      },
      "contact": {
        "company": null,
        "name": "Christopher Richards"
      },
      "display_name": "Home",
      "id": "addr_28ci3lu2plw2wice8uedJWKJSWW",
      "marketplaces": {},
      "metadata": {
        "access_code": "732-234",
        "safe_place": "Garage"
      }
    }
  ]
}

undefined


POST/customers/{customer_id}/addresses

Create Customer Address

Create a new address for a customer.

Normalisation

To try and both standardise the format of addresses, and reduce the likelihood of duplicates, any address that is added is formatted using Google's i18n dataset, the same dataset that is used for address formatting in Chromium. As a result, the case and layout of the address will be normalised according to the standards of the country that the address exists in.

The strict_normalisation parameter is currently disabled due to in progress changes to the underlying logic which may or may not render it obsolete. The documentation is left here for reference which the changes are pending.

If the strict_normalisation parameter is passed in the request, all fields of the address will be uppercased before storing. The decision to uppercase instead of lowercase was made on the basis of Microsoft CA1308, which points out that in some languages a letter can be converted from lowercase to uppercase, but not vice versa (an example of this is the Turkish 'i' problem, described here).

Address Expansion & Correction

It is also possible to pass the expand_address parameter. This parameter will attempt to expand abbreviations, convert written numbers to actual numbers, and so on, using unclean, but it should be used with care, as some expansions may be inaccurate (eg: 'St' may be expanded to 'Saint' instead of 'Street'). Expansion is currently only applied to the line_1, line_2 & line_3 parameters - the other parameters are only subject to normalisation as described in the previous paragraph.

Metadata

It is possible to attach metadata to each address. This is useful for when additional information relating to the address should be stored with it, such as safeplace locations, gate access codes, delivery contact information, etc.

The metadata object takes key/value pairs, both of which must be strings. Additionally, the keys may only contain alphanumeric characters and underscores, and can be up to 50 characters in length. The values may be up to 500 characters in length, and must be UTF-8 compliant strings.

The following keys are special property keys, with the following caveats:

  • contact_phone_number: The value must be an E.164 formatted number. The value is checked to ensure that it is formatted correctly, but further validation to check whether the number is in service is not performed.

  • contact_email: The value must be a syntactically valid email address. The usage of special use domain names is not permitted.
    Checks for the deliverability of emails to the provided address are not carried outcurrently, though this may change at a later date without notice.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID for the customer.

Query Parameters

  • Name
    strict_normalisation
    Type
    string
    Restrictions
    Description

    Whether to apply stricter normalisation to the submitted address. Results in the address being stored as uppercase.

  • Name
    expand_address
    Type
    string
    Restrictions
    Description

    Whether to apply expansions as described above to the submitted address.

Enumerated Values

ParameterValue
strict_normalisationtrue
strict_normalisationfalse
expand_addresstrue
expand_addressfalse

Request

POST
/customers/{customer_id}/addresses
curl --request POST \
--url https://api.envoy.one/customers/cus_28ciEisyBRsQZ2jBMIrrpIrJFqh/addresses \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"address":{"line_1":"29 Holgate Rd","city":"RACKWICK","post_code":"KW16 2PE","country_code":"GB"},"contact":{"name":"Francesca Brady"},"display_name":"Work","metadata":{"contact_email":"[email protected]"},"marketplaces":{"shopify":"657847832011"}}'

Response

{
  "address": {
    "city": "RACKWICK",
    "country_code": "GB",
    "line_1": "29 Holgate Rd",
    "line_2": null,
    "line_3": null,
    "post_code": "KW16 2PE",
    "province": null
  },
  "contact": {
    "company": null,
    "name": "Francesca Brady"
  },
  "display_name": "Work",
  "id": "addr_29P30FDGNXkBJ9lwxhDB3mg80Vm",
  "marketplaces": {
    "shopify": "657847832011"
  },
  "metadata": {
    "contact_email": "[email protected]"
  }
}

undefined


GET/customers/{customer_id}/addresses/{address_id}

Get Customer Address

Retrieve an address belonging to a customer by ID.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID of the customer.

  • Name
    address_id
    Type
    string
    Restrictions
    Description

    The unique ID of the address.

Request

GET
/customers/{customer_id}/addresses/{address_id}
curl --request GET \
--url https://api.envoy.one/customers/cus_28chAGqWwTyYVqdPML6t88yqefF/addresses/addr_29P7NefPHxG3SimgakjCefobnBb \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

Response

{
  "address": {
    "city": "BIG SPRING",
    "country_code": "US",
    "line_1": "3249 Scenicview Drive",
    "line_2": null,
    "line_3": null,
    "post_code": "79720",
    "province": "TX"
  },
  "contact": {
    "company": null,
    "name": "Christopher Richards"
  },
  "display_name": "Home",
  "id": "addr_28ci3lu2plw2wice8uedJWKJSWW",
  "marketplaces": {},
  "metadata": {
    "access_code": "732-234",
    "safe_place": "Garage"
  }
}

undefined


PUT/customers/{customer_id}/addresses/{address_id}

Update Customer Address

Update a customer address by it's unique ID.

No fields are explicity required as part of the update - either the full record or a partial record can be submitted.

It is currently not possible to depopulate a field once it has been populated (eg. line_2 contains Smith Street, we want to set it to null) due to possible interdependency issues. This will be resolved imminently alongside the addition of support for PATCH requests, which will be responsible for the partial updates currently supported by the PUT method.

Once support for depopulating fields is added, any attempts to depopulate required fields will result in a 400 error being thrown.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID of the customer.

  • Name
    address_id
    Type
    string
    Restrictions
    Description

    The unique ID of the address.

Request

PUT
/customers/{customer_id}/addresses/{address_id}
curl --request PUT \
--url https://api.envoy.one/customers/cus_28chAGqWwTyYVqdPML6t88yqefF/addresses/addr_29P7NefPHxG3SimgakjCefobnBb \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data '{"address":{"city":"LITTLE SPRING","country_code":"US","line_1":"4128 Scenicview Drive","line_2":null,"line_3":null,"post_code":"78423","province":"TX"},"contact":{"company":null,"name":"Christopher Richards"},"display_name":"Home","marketplaces":{},"metadata":{"access_code":"732-234","safe_place":"Garage"}}'

Response

{
  "address": {
    "city": "LITTLE SPRING",
    "country_code": "US",
    "line_1": "4128 Scenicview Drive",
    "line_2": null,
    "line_3": null,
    "post_code": "78423",
    "province": "TX"
  },
  "contact": {
    "company": null,
    "name": "Christopher Richards"
  },
  "display_name": "Home",
  "id": "addr_28ci3lu2plw2wice8uedJWKJSWW",
  "marketplaces": {},
  "metadata": {
    "access_code": "732-234",
    "safe_place": "Garage"
  }
}

undefined


DELETE/customers/{customer_id}/addresses/{address_id}

Delete Customer Address

Delete an address belonging to a customer by it's unique ID.

Path Parameters

  • Name
    customer_id
    Type
    string
    Restrictions
    Description

    The unique ID of the customer.

  • Name
    address_id
    Type
    string
    Restrictions
    Description

    The unique ID of the address.

Request

DELETE
/customers/{customer_id}/addresses/{address_id}
curl --request DELETE \
--url https://api.envoy.one/customers/cus_28chAGqWwTyYVqdPML6t88yqefF/addresses/addr_29P7NefPHxG3SimgakjCefobnBb \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access-token}'

undefined