> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maqetin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Identify

> Create or update the profile of a person, with their traits.

Identify upserts a profile: it creates it the first time a `userId` is seen and updates its traits after that. Send it when a person signs up, signs in or changes their details.

> [!NOTE]
>
> This call names a `userId`, so in `required` mode, the default, it also needs the `Maqetin-Identity-Token` header. See [Identity verification](https://docs.maqetin.com/data/identity-verification.md).

## Headers

**Authorization** `string` *required*

`Bearer mq_live_…`, your public key. A secret key is refused here: send events with a secret key to [`/v1/batch`](https://docs.maqetin.com/api-reference/batch).

**Maqetin-Identity-Token** `string`

A token your server signed for this `userId`. Needed in `required` mode. See [Identity token](https://docs.maqetin.com/api-reference/introduction.md#identity-token).

## Body

The body is at most 32 KiB. Any other top-level field is a `400`.

**userId** `string` *required*

Your own id for the person, 1 to 256 characters.

**traits** `object` *required*

What you know about the person. Send `{}` when you have nothing to add. Trait names cannot hold the NUL character. Any trait not listed here can hold any JSON value.

**traits with a type**

**email** `string`

A valid email address.

**phone** `string`

A string.

**firstName** `string`

A string.

**lastName** `string`

A string.

**plan** `string`

A string.

**country** `string`

A string.

**createdAt** `string`

An ISO 8601 date-time. Maqetin stores it in UTC.

**channel** `string` *required*

Where the call came from: `web`, `ios`, `android`, `node`, `python`, `go` or `rest`. Use `rest` for your own HTTP calls.

**anonymousId** `string`

The id the person had before they signed in, at most 256 characters. Their earlier anonymous events join the profile.

**messageId** `string`

1 to 64 characters. A retry with the same id is stored once. See [Send an event once](https://docs.maqetin.com/api-reference/introduction.md#send-an-event-once).

**timestamp** `string`

When it happened, as an ISO 8601 date-time. Used only together with `sentAt`. See [Event time](https://docs.maqetin.com/api-reference/introduction.md#event-time).

**sentAt** `string`

When your client sent the request, as an ISO 8601 date-time.

**sessionId** `string`

The id of the session, at most 256 characters.

**sdkVersion** `string`

The version of the SDK that made the call.

**context** `object`

Where the call was made. The SDK fills it for you. Keys not listed here can hold any JSON value.

**context fields with a rule**

**timezone** `string`

An IANA time zone, at most 64 characters.

**locale** `string`

At most 35 characters.

**deviceId** `string`

At most 64 characters.

**userAgent** `string`

At most 512 characters.

**library** `object`

`name` and `version`, both strings, both required.

**app** `object`

`name`, `version` and `build`, all strings.

**os** `object`

`name` and `version`, both strings.

**device** `object`

`model` and `manufacturer`, both strings.

**page** `object`

`url` (at most 768 characters), `path` (256), `referrer` (512) and `title` (200). No other key.

**campaign** `object`

`source`, `medium`, `name`, `term` and `content` (each at most 100 characters), `clickIds` (an object of known ad click ids, each 1 to 256 characters) and `capturedAt` (an ISO 8601 date-time). No other key.

**consent** `object`

`analytics` (required), `adStorage`, `adUserData`, `adPersonalization` and `push`, each `granted`, `denied` or `unset`; `gpc` and `childDirected`, booleans; `att`, one of `notDetermined`, `restricted`, `denied` or `authorized`; `v`, a whole number; `ts`, an ISO 8601 date-time. No other key.

**userAgentData** `object`

`brands` (at most 10 of `{ brand, version }`), `mobile` (a boolean) and `platform` (at most 64 characters). No other key.

## Response

**accepted** `number` *required*

The number of events taken: `1`.

A `202` means the call is stored. A refusal has `error` and, for a body problem, `at`. See [Errors](https://docs.maqetin.com/api-reference/errors.md#event-routes).

```bash cURL theme={null}
curl https://in.maqetin.com/v1/identify \
  -H 'Authorization: Bearer mq_live_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "userId": "user_123",
  "traits": {
    "email": "ada@example.com",
    "firstName": "Ada",
    "lastName": "Lovelace",
    "plan": "pro"
  },
  "channel": "rest"
}'
```

```json 202 theme={null}
{ "accepted": 1 }
```

```json 400 theme={null}
{ "error": "invalid payload", "at": ["/traits/email"] }
```

```json 401 theme={null}
{ "error": "token_required" }
```


## Related topics

- [Profiles](https://docs.maqetin.com/data/profiles.md)
- [Batch](https://docs.maqetin.com/api-reference/batch.md)
- [Events](https://docs.maqetin.com/data/events.md)
- [Quickstart](https://docs.maqetin.com/quickstart.md)
- [JavaScript SDK](https://docs.maqetin.com/sdk/javascript.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.