# Update a customer

`PATCH /api/v1/customers/{id}`

Changes contact details on a customer. Omitted fields are left as they are. Changing the email rewrites the customer's bookings and newsletter record too, the same way the admin customer page does. Requires the "customers:write" scope; an "Idempotency-Key" header is optional.

Scope: `customers:write`
Idempotency-Key: optional

## Parameters

- `id` (path, string, required) — Awrora id (UUID) for the customer.
- `Idempotency-Key` (header, string) — Optional. A unique key, 8-200 characters. Retrying with the same key replays the first response verbatim instead of acting twice.

## Request body

- `name` (string) — New name.
- `phone` (string | null) — New phone number. Pass null to clear it.
- `email` (string) — New email. Changing it rewrites the customer's bookings too. An email that already belongs to another customer answers 409 "conflict".
- `email_subscription` (boolean) — Whether the customer has agreed to marketing email.
- `tags` (string[]) — Replaces the customer's tags. Omit to leave them unchanged.

## Responses

- `200` — The updated customer.
- `400` — Invalid request — codes "validation_failed" or, on an endpoint that requires one, "idempotency_key_required".
- `401` — Missing, invalid, revoked or expired API key — codes "api_key_missing", "api_key_invalid", "api_key_revoked", "api_key_expired".
- `403` — The API app is off, the plan does not include the API, or the key lacks the required scope — codes "app_not_enabled", "plan_upgrade_required", "insufficient_scope" (the last carries "required_scope").
- `404` — No such resource. The same response is returned for a resource that belongs to another organization — code "not_found".
- `409` — The request conflicts with the current state — codes "insufficient_capacity" (carries "seats_available"), "conflict", or "idempotency_in_progress" when another request with the same Idempotency-Key is still running.
- `422` — The request was understood but cannot be fulfilled as asked — codes "validation_failed" or "idempotency_key_reused" (the same Idempotency-Key was already used with a different body).
- `429` — Rate limit exceeded — code "rate_limited". See the x-ratelimit-* headers.
- `500` — Something went wrong on our side — code "internal_error".

## Response `200`

- `id` (string, required) — Awrora id (UUID) for the customer record.
- `name` (string, required) — Customer name.
- `email` (string, required) — Customer email. Unique within the organization.
- `phone` (string | null, required) — Phone number, or null.
- `tags` (string[], required) — Merchant-defined tags. May be empty.
- `email_subscription` (boolean, required) — True when the customer has opted in to marketing email.
- `created_at` (string, required) — ISO 8601 timestamp with offset.

## Example

```bash
curl -X PATCH "https://your-site.awrora.app/api/v1/customers/id_8f2k3n" \
  -H "Authorization: Bearer $AWRORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "phone": "string",
  "email": "anna@example.com",
  "email_subscription": true,
  "tags": [
    "string"
  ]
}'
```