# Upsert a Requester by External ID

> Create or update a LemuTickets requester using your own customer id

URL: https://docs.lemuai.com/tickets-api/requesters/upsert-by-external-id

Creates or updates the requester with your own id for the customer, for example the customer number in your ERP. Use it whenever a customer record is created or changes in your system.

**Endpoint:** `PUT /v1/requesters/by-external-id/{external_id}`

Needs the `requesters.write` scope.

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `external_id` | string | Yes | Your own id for the customer, URL-encoded. |

## How it works

- **A requester with this `external_id` exists:** the fields you send are updated. Fields you leave out keep their values.
- **None exists yet:** LemuTickets looks for the same person by email, phone or WhatsApp number (see [how the requester is found](https://docs.lemuai.com/tickets-api/requesters/upsert#how-the-requester-is-found)), or creates a new requester, and then applies the fields you send. Later requests with the same id update the same requester.

## Request body

The same fields as [Create or update a requester](https://docs.lemuai.com/tickets-api/requesters/upsert#request-body), all optional. `external_id` in the body is ignored; the one in the path is used.

| Field | What happens |
|---|---|
| `name`, `email`, `phone`, `whatsapp_id`, `account_id`, `language`, `is_vip`, `lemu_contact_id` | Set to the value you send. |
| `tags` | Replaces all tags. |
| `custom_fields` | Replaces all custom fields. |

**Example request:**
```bash
curl -X PUT https://api.tickets.lemuai.com/v1/requesters/by-external-id/CUST-20931 \
  -H "Authorization: Bearer ltk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Priya Sharma",
    "email": "priya@example.com",
    "phone": "+919876543210",
    "account_id": "4a6c8e0b-2d1f-4b3a-8c5e-9f7d1b3a5c6e",
    "is_vip": true,
    "custom_fields": { "gstin": "29ABCDE1234F1Z5", "credit_limit": 500000 }
  }'
```

## Response

**`200`** with the requester.
```json
{
  "id": "8b4d6f2a-0c1e-4a3b-9d5f-7e6a8c0b2d4f",
  "name": "Priya Sharma",
  "email": "priya@example.com",
  "phone": "+919876543210",
  "whatsapp_id": null,
  "account_id": "4a6c8e0b-2d1f-4b3a-8c5e-9f7d1b3a5c6e",
  "language": "en",
  "is_vip": true,
  "external_id": "CUST-20931",
  "lemu_contact_id": null,
  "tags": ["distributor"],
  "custom_fields": { "gstin": "29ABCDE1234F1Z5", "credit_limit": 500000 },
  "anonymised": false,
  "created_at": "2026-11-25T09:05:12.330000+00:00",
  "open_tickets": null
}
```

See [requester fields](https://docs.lemuai.com/tickets-api/requesters/upsert#requester-fields).

A requester created by this endpoint has your id in `external_id`. You can then use it to [issue embed tokens](https://docs.lemuai.com/tickets-api/embedding) (`requester_external_id`) and to search with `GET /v1/requesters?q=CUST-20931`.

## Errors

| Status | `code` | When |
|---|---|---|
| `403` | `missing_capability` | The key does not have `requesters.write` |
| `422` | `invalid_fields` | A field has the wrong type |
