---
title: Customers
description: Create a meals customer, send them to the connect URL, read the connection and revoke it.
section: Meals
order: 2
---

# Customers

You will create a customer, send them to approve the connection, follow the result, and end the connection when you need to.

Creating a customer and revoking a connection need the `order:write` scope. Reading a customer or a connection needs `order:read`.

## Create a customer

`POST /meals/v1/customer/create/document` creates a customer and starts a connection with them. Nothing can be ordered for a customer until they approve.

| Field         | Required | Notes                                                                                        |
| ------------- | -------- | -------------------------------------------------------------------------------------------- |
| `external_id` | Yes      | Your own id for the customer, 1 to 200 characters.                                           |
| `email`       | Yes      | The approval page sends its code to the address on the customer's Nurish'd account.          |
| `first_name`  | Yes      |                                                                                              |
| `last_name`   | Yes      |                                                                                              |
| `return_url`  | No       | Where the customer goes after the approval page. Must be one of your registered return URLs. |

```bash
curl -X POST https://api.dev.nurishd.ca/meals/v1/customer/create/document \
  -H "X-Partner-API-Key: $NURISHD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "external_id": "customer-1001",
    "email": "ada.lovelace@example.com",
    "first_name": "Ada",
    "last_name": "Lovelace",
    "return_url": "https://shop.example.com/nurishd/return"
  }'
```

```javascript
const res = await fetch(
	'https://api.dev.nurishd.ca/meals/v1/customer/create/document',
	{
		method: 'POST',
		headers: {
			'X-Partner-API-Key': process.env.NURISHD_API_KEY,
			'Content-Type': 'application/json',
		},
		body: JSON.stringify({
			external_id: 'customer-1001',
			email: 'ada.lovelace@example.com',
			first_name: 'Ada',
			last_name: 'Lovelace',
			return_url: 'https://shop.example.com/nurishd/return',
		}),
	},
);
const customer = await res.json();
```

```python
import os
import requests

res = requests.post(
    "https://api.dev.nurishd.ca/meals/v1/customer/create/document",
    headers={"X-Partner-API-Key": os.environ["NURISHD_API_KEY"]},
    json={
        "external_id": "customer-1001",
        "email": "ada.lovelace@example.com",
        "first_name": "Ada",
        "last_name": "Lovelace",
        "return_url": "https://shop.example.com/nurishd/return",
    },
)
customer = res.json()
```

The answer:

```json
{
	"user": "6f1c0d2e-0000-4000-8000-000000000101",
	"connection": {
		"connection_id": "connection-0001",
		"company_id": "company-0001",
		"user": "6f1c0d2e-0000-4000-8000-000000000101",
		"external_id": "customer-1001",
		"status": "pending",
		"scopes": ["meals.orders"],
		"created_at": "2026-11-30T15:04:05Z",
		"approved_at": null,
		"revoked_at": null,
		"revoked_by": null
	},
	"connect_url": "https://app.nurishd.ca/connect/abc123",
	"connect_url_expires_at": "2026-12-01T15:04:05Z"
}
```

The customer's id is `user`. Use it in the customer routes and as `user` when you place an order. The connection's id is `connection.connection_id`.

Calling create again with the same `external_id` returns the same customer and a fresh link. The answer never says whether the email already had a Nurish'd account.

A customer is known to your company under one `external_id`. Two requests are refused with `409` and create nothing:

| Code                       | When                                                                    |
| -------------------------- | ----------------------------------------------------------------------- |
| `external_id_conflict`     | The `external_id` already belongs to a customer with a different email. |
| `person_already_connected` | The email is already connected under a different `external_id`.         |

To change the id you use for a customer, keep using the first one.

## Send the customer to the connect URL

Send the customer to `connect_url` as a full page or a new tab. Never open it in a frame or a web view. The link is valid for 24 hours and works once.

In the Sandbox, no email is sent. The connect page accepts the fixed code `424242`. See [Environments](/docs/get-started/environments).

## Follow the connection

Do not trust the `status` in the return URL. Do one of these:

- Wait for the `connection.approved` event. See [Events](/docs/events/events).
- Read the connection:

```bash
curl https://api.dev.nurishd.ca/meals/v1/connection/connection-0001/get/document \
  -H "X-Partner-API-Key: $NURISHD_API_KEY"
```

```javascript
const res = await fetch(
	'https://api.dev.nurishd.ca/meals/v1/connection/connection-0001/get/document',
	{
		headers: { 'X-Partner-API-Key': process.env.NURISHD_API_KEY },
	},
);
const connection = await res.json();
```

```python
import os
import requests

res = requests.get(
    "https://api.dev.nurishd.ca/meals/v1/connection/connection-0001/get/document",
    headers={"X-Partner-API-Key": os.environ["NURISHD_API_KEY"]},
)
connection = res.json()
```

```json
{
	"connection_id": "connection-0001",
	"company_id": "company-0001",
	"user": "6f1c0d2e-0000-4000-8000-000000000101",
	"external_id": "customer-1001",
	"status": "active",
	"scopes": ["meals.orders"],
	"created_at": "2026-11-30T15:04:05Z",
	"approved_at": "2026-11-30T15:10:12Z",
	"revoked_at": null,
	"revoked_by": null
}
```

`GET /meals/v1/customer/{customer_id}/get/document` returns the customer and the connection. Its `connect_url` and `connect_url_expires_at` are always `null`. Call create again for a fresh link.

## Revoke the connection

`PUT /meals/v1/connection/{connection_id}/revoke/document` ends the connection. Nothing can be ordered for the customer afterwards. It raises a `connection.revoked` event. A connection that is already revoked or declined answers `409 connection_not_active`.

```bash
curl -X PUT https://api.dev.nurishd.ca/meals/v1/connection/connection-0001/revoke/document \
  -H "X-Partner-API-Key: $NURISHD_API_KEY"
```

```javascript
const res = await fetch(
	'https://api.dev.nurishd.ca/meals/v1/connection/connection-0001/revoke/document',
	{
		method: 'PUT',
		headers: { 'X-Partner-API-Key': process.env.NURISHD_API_KEY },
	},
);
const connection = await res.json();
```

```python
import os
import requests

res = requests.put(
    "https://api.dev.nurishd.ca/meals/v1/connection/connection-0001/revoke/document",
    headers={"X-Partner-API-Key": os.environ["NURISHD_API_KEY"]},
)
connection = res.json()
```

The answer is the connection with `status` set to `revoked`, `revoked_at` set and `revoked_by` set to `partner`. To connect again, call create with the same `external_id` and send the customer to the new `connect_url`.

## Next

- [Connections](/docs/concepts/connections): statuses, scopes and return URLs.
- [Events](/docs/events/events): `connection.approved` and friends.
- [Saving a card](/docs/meals/saving-a-card): save a card to the customer's account.
- [Orders](/docs/meals/orders): place an order for a connected customer.
