> For the complete documentation index, see [llms.txt](https://docs.millimetric.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.millimetric.ai/api-reference/identify.md).

# POST /v1/identify

POST /v1/identify — link an anonymous\_id to a user\_id.

Bind a known `user_id` to the visitor's `anonymous_id`. Persists as a special `$identify` event so future analysis can stitch pre- and post-login behavior together.

## Auth

|                |                 |
| -------------- | --------------- |
| Required scope | `ingest`        |
| Key kinds      | `pk_*` · `sk_*` |

## Request

```http
POST /v1/identify
Authorization: Bearer {key}
Content-Type: application/json
```

```json
{
  "anonymous_id": "u_abc",
  "user_id": "user_42",
  "traits": { "email": "matt@example.com", "plan": "pro" }
}
```

| Field          | Required | Notes                                                                                |
| -------------- | -------- | ------------------------------------------------------------------------------------ |
| `anonymous_id` | **yes**  | The pseudonymous id the visitor's browser/server has been using.                     |
| `user_id`      | **yes**  | Your stable internal user id.                                                        |
| `traits`       | no       | Free-form attributes about the user, stored on the `$identify` event's `properties`. |

## Response

```json
{ "ok": true }
```

## How it integrates

After `/v1/identify`:

1. Subsequent events should include `"user_id"` on each `track` call. The SDK does this automatically once you call `identify()`.
2. Historical events for the same `anonymous_id` remain — they're not retroactively rewritten. Joins for user-level analysis use the `$identify` event as a stitch point.
3. The `sessions_v` view sees `user_id` on the `$identify` event itself; running totals per user are easy.

## Example query: time-to-conversion per user

```sql
SELECT
  user_id,
  MIN(if(event_name = '$identify', timestamp, NULL)) AS signed_up_at,
  MIN(if(event_name = 'purchase', timestamp, NULL)) AS first_purchase
FROM events
WHERE project_id = '...'
  AND timestamp > now() - INTERVAL 30 DAY
  AND user_id IS NOT NULL
GROUP BY user_id;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.millimetric.ai/api-reference/identify.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
