# Identifiers API

> The phone numbers and email addresses that belong to a user, so inbound messages and calls reach the right person.

Part of the AGNT API reference. AGNT (https://agnt.ai) is the developer platform behind OpenAssistant (https://openassistant.us). Docs index: https://agnt.ai/llms.txt. Web page: https://agnt.ai/reference/api/identifiers

Base URL: `https://api.agnt.ai`. Auth: `Authorization: Bearer ak_live_...`.

## GET /identifiers

List identifiers

Returns identifiers in your account, filtered by `type` or `userId`. Called as a user, returns only that user's identifiers.

**Query parameters**

- `type` (enum) One of: `email`, `phone`, `external_id`, `employee_id`, `google`, `microsoft`, `apple`, `custom`.
- `userId` (string)

**Responses**

- `200`: Identifiers list
  - `ok` (enum, required) One of: `true`.
  - `identifiers` (object[], required)
    - `id` (string, required)
    - `account` (string, required)
    - `user` (object | null, required)
      - `id` (string, required)
      - `name` (string | null, required)
      - `status` (enum, required) One of: `active`, `inactive`, `suspended`.
    - `type` (enum, required) One of: `email`, `phone`, `external_id`, `employee_id`, `google`, `microsoft`, `apple`, `custom`.
    - `value` (string, required)
    - `verified` (boolean, required)
    - `primary` (boolean, required)
    - `label` (string | null)
    - `platforms` (object)
    - `metadata` (object)
    - `iMessageCapable` (boolean | null)
    - `whatsAppCapable` (boolean | null)
    - `preferredTextPlatform` (enum) One of: `imessage`, `sms`, `whatsapp`, `null`.
    - `messagingWindow` (object)
      - `whatsapp` (any)
      - `imessage` (any)
    - `createdAt` (string, required)
    - `updatedAt` (string, required)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/identifiers' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "identifiers": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "user": {
        "id": "6660c4a1f2e3b7d8a9c01234",
        "name": "Ava",
        "status": "active"
      },
      "type": "email",
      "value": "value",
      "verified": true
    }
  ]
}
```

## POST /identifiers

Create an identifier

Adds an email address, phone number or other handle to a user, so messages from it reach that user. With an account key, pass `userId`. Phone numbers are stored in E.164; a number without a leading `+` uses the user's country. A value held by any user in your account returns `400`.

**Request body** (JSON)

- `type` (enum, required) One of: `email`, `phone`, `external_id`, `employee_id`, `google`, `microsoft`, `apple`, `custom`.
- `value` (string, required)
- `userId` (string)
- `verified` (boolean)
- `label` (string | null)
- `platforms` (object)
- `userData` (object)
  - `name` (string)
  - `firstName` (string)
  - `lastName` (string)
  - `avatar` (string)
  - `timezone` (string)
  - `locale` (string)

**Responses**

- `201`: Created
  - `ok` (enum, required) One of: `true`.
  - `identifier` (object, required)
    - `id` (string, required)
    - `account` (string, required)
    - `user` (object, required)
      - `id` (string, required)
      - `account` (string, required)
      - `email` (string)
      - `externalId` (string)
      - `assistant` (string | null, required)
      - `name` (string | null, required)
      - `firstName` (string)
      - `lastName` (string)
      - `avatarUrl` (string | null, required)
      - `timezone` (string, required)
      - `locale` (string, required)
      - `country` (string | null)
      - `city` (string)
      - `organization` (string | null, required)
      - `organizationRole` (enum, required) One of: `admin`, `member`, `guest`.
      - `team` (any, required)
      - `teamRole` (enum, required) One of: `member`, `admin`, `owner`, `null`.
      - `status` (enum, required) One of: `active`, `inactive`, `suspended`.
      - `voice` (object | null)
        - `voiceId` (string, required)
        - `provider` (string, required)
      - `metadata` (object)
      - `firstLoginAt` (string)
      - `username` (string | null)
      - `preferences` (any)
      - `assistantName` (string | null)
      - `appName` (string | null)
      - `createdAt` (string, required)
      - `updatedAt` (string, required)
    - `type` (enum, required) One of: `email`, `phone`, `external_id`, `employee_id`, `google`, `microsoft`, `apple`, `custom`.
    - `value` (string, required)
    - `verified` (boolean, required)
    - `primary` (boolean, required)
    - `label` (string | null)
    - `platforms` (object)
    - `metadata` (object)
    - `iMessageCapable` (boolean | null)
    - `whatsAppCapable` (boolean | null)
    - `preferredTextPlatform` (enum) One of: `imessage`, `sms`, `whatsapp`, `null`.
    - `messagingWindow` (object)
      - `whatsapp` (object)
        - `warmUntil` (string | null)
        - `lastInboundAt` (string | null)
      - `imessage` (object)
        - `warmUntil` (string | null)
        - `lastInboundAt` (string | null)
    - `createdAt` (string, required)
    - `updatedAt` (string)
- `400`: Invalid value (invalid_phone for an unparseable number), or the value is held by another user in your account
  - `status` (integer, required)
  - `error_code` (string)
  - `error` (string, required)

```bash
curl 'https://api.agnt.ai/identifiers' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "type": "email",
  "value": "value"
}'
```

Example response:

```json
{
  "ok": true,
  "identifier": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "user": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "assistant": "assistant",
      "name": "Ava",
      "avatarUrl": "https://example.com",
      "timezone": "America/New_York"
    },
    "type": "email",
    "value": "value",
    "verified": true
  }
}
```

## GET /identifiers/{identifierId}

Retrieve an identifier

Retrieves an identifier.

**Path parameters**

- `identifierId` (string, required)

**Responses**

- `200`: Identifier detail
  - Same fields as the `201` response of `POST /identifiers`.
- `404`: Not found
  - `status` (integer, required)
  - `error_code` (string)
  - `error` (string, required)

```bash
curl 'https://api.agnt.ai/identifiers/<identifierId>' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "identifier": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "user": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "assistant": "assistant",
      "name": "Ava",
      "avatarUrl": "https://example.com",
      "timezone": "America/New_York"
    },
    "type": "email",
    "value": "value",
    "verified": true
  }
}
```

## PUT /identifiers/{identifierId}

Update an identifier

Updates an identifier's `verified` flag, label, platforms and metadata. To change the value, create a new identifier.

**Path parameters**

- `identifierId` (string, required)

**Request body** (JSON)

- `verified` (boolean)
- `label` (string | null)
- `platforms` (object)
- `metadata` (object)

**Responses**

- `200`: Updated
  - Same fields as the `201` response of `POST /identifiers`.

```bash
curl 'https://api.agnt.ai/identifiers/<identifierId>' \
  -X PUT \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "verified": true,
  "label": "label",
  "platforms": {},
  "metadata": {}
}'
```

Example response:

```json
{
  "ok": true,
  "identifier": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "user": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "assistant": "assistant",
      "name": "Ava",
      "avatarUrl": "https://example.com",
      "timezone": "America/New_York"
    },
    "type": "email",
    "value": "value",
    "verified": true
  }
}
```

## DELETE /identifiers/{identifierId}

Delete an identifier

Deletes an identifier. A user's last identifier and their primary email cannot be deleted.

**Path parameters**

- `identifierId` (string, required)

**Responses**

- `200`: Deleted
  - `ok` (enum, required) One of: `true`.
  - `identifier` (object, required)
    - `id` (string, required)
    - `deleted` (boolean)
    - `message` (string)

```bash
curl 'https://api.agnt.ai/identifiers/<identifierId>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "identifier": {
    "id": "6660c4a1f2e3b7d8a9c01234"
  }
}
```

## POST /identifiers/{identifierId}/link

Link an identifier to a user

Attaches the identifier to the user given by `userId`.

**Path parameters**

- `identifierId` (string, required)

**Request body** (JSON)

- `userId` (string, required)

**Responses**

- `200`: Linked
  - Same fields as the `201` response of `POST /identifiers`.

```bash
curl 'https://api.agnt.ai/identifiers/<identifierId>/link' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "userId": "6660c4a1f2e3b7d8a9c01234"
}'
```

Example response:

```json
{
  "ok": true,
  "identifier": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "user": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "assistant": "assistant",
      "name": "Ava",
      "avatarUrl": "https://example.com",
      "timezone": "America/New_York"
    },
    "type": "email",
    "value": "value",
    "verified": true
  }
}
```

## POST /identifiers/{identifierId}/make-primary

Make an email primary

Makes an email identifier the user's primary email, which changes the user's `email`. Only email identifiers can be primary.

**Path parameters**

- `identifierId` (string, required)

**Responses**

- `200`: Result
  - `ok` (enum, required) One of: `true`.
  - `makePrimary` (object, required)
    - `user` (object, required)
      - `id` (string, required)
      - `account` (string, required)
      - `email` (string)
      - `externalId` (string)
      - `assistant` (string | null, required)
      - `name` (string | null, required)
      - `firstName` (string)
      - `lastName` (string)
      - `avatarUrl` (string | null, required)
      - `timezone` (string, required)
      - `locale` (string, required)
      - `country` (string | null)
      - `city` (string)
      - `organization` (string | null, required)
      - `organizationRole` (enum, required) One of: `admin`, `member`, `guest`.
      - `team` (object | null, required)
        - `id` (string, required)
        - `name` (string, required)
        - `organization` (string | null, required)
        - `status` (string, required)
      - `teamRole` (enum, required) One of: `member`, `admin`, `owner`, `null`.
      - `status` (enum, required) One of: `active`, `inactive`, `suspended`.
      - `voice` (object | null)
        - `voiceId` (string, required)
        - `provider` (string, required)
      - `metadata` (object)
      - `firstLoginAt` (string)
      - `username` (string | null)
      - `preferences` (object)
        - `reminders` (any)
        - `preferredProviders` (object)
        - `preferredContactChannel` (object)
      - `assistantName` (string | null)
      - `appName` (string | null)
      - `createdAt` (string, required)
      - `updatedAt` (string, required)
    - `identifier` (object, required)
      - `id` (string, required)
      - `type` (enum, required) One of: `email`, `phone`, `external_id`, `employee_id`, `google`, `microsoft`, `apple`, `custom`.
      - `value` (string, required)
      - `verified` (boolean, required)
      - `primary` (boolean, required)
- `400`: The identifier is not an email

```bash
curl 'https://api.agnt.ai/identifiers/<identifierId>/make-primary' \
  -X POST \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "makePrimary": {
    "user": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "assistant": "assistant",
      "name": "Ava",
      "avatarUrl": "https://example.com",
      "timezone": "America/New_York"
    },
    "identifier": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "type": "email",
      "value": "value",
      "verified": true,
      "primary": true
    }
  }
}
```
