Developers

Search the docs

Search guides and headings.

Customers

Create a meals customer, send them to the connect URL, read the connection and revoke it.

View as Markdown

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.

FieldRequiredNotes
external_idYesYour own id for the customer, 1 to 200 characters.
emailYesThe approval page sends its code to the address on the customer's Nurish'd account.
first_nameYes
last_nameYes
return_urlNoWhere 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"
  }'

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:

CodeWhen
external_id_conflictThe external_id already belongs to a customer with a different email.
person_already_connectedThe 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.

Follow the connection#

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

  • Wait for the connection.approved event. See 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"

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"

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: statuses, scopes and return URLs.
  • Events: connection.approved and friends.
  • Saving a card: save a card to the customer's account.
  • Orders: place an order for a connected customer.