# Contacts API

> The people a user works with, across email, phone and chat, with relationships and external ids.

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/contacts

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

## GET /contacts

List contacts

Returns the user's contacts, filtered by `status`, `scope`, `source` or `tags`, or searched by name and email. With an account key and no `X-User-Email`, pass `userId`.

Acts as one user: send `X-User-Email`.

**Query parameters**

- `page` (integer)
- `perPage` (integer)
- `userId` (string)
- `status` (string)
- `search` (string)
- `q` (string)
- `scope` (enum) One of: `user`, `team`.
- `sourceType` (string)
- `tags` (string)

**Responses**

- `200`: Contacts
  - `ok` (enum, required) One of: `true`.
  - `contacts` (object[], required)
    - `id` (string, required)
    - `user` (string, required)
    - `name` (string | null, required)
    - `preferredName` (string | null)
    - `email` (string, required)
    - `emails` (object[])
      - `address` (string, required)
      - `type` (enum) One of: `work`, `personal`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `phones` (object[])
      - `number` (string, required)
      - `type` (enum) One of: `work`, `mobile`, `home`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `iMessageCapable` (boolean | null)
    - `company` (object | null, required)
      - `id` (string, required)
      - `name` (string, required)
      - `slug` (string, required)
      - `domain` (string | null, required)
    - `title` (string | null, required)
    - `timezone` (string | null, required)
    - `tzOffset` (string | null)
    - `photoUrl` (string | null)
    - `website` (string | null, required)
    - `bookingLink` (string | null, required)
    - `social` (object)
      - `linkedIn` (string)
      - `x` (string)
      - `other` (string)
    - `address` (object)
      - `line1` (string)
      - `line2` (string)
      - `city` (string)
      - `state` (string)
      - `zip` (string)
      - `country` (string)
    - `enrichedAt` (string | null)
    - `source` (object | null)
      - `type` (enum) One of: `manual`, `teammate`, `teammate_archived`, `imported`, `email`, `import`, `crm`, `ats`, `hris`, `voice`, `onboarding`, `calendar`, `other`, `null`.
      - `userId` (string | null)
    - `lastContactedAt` (string | null)
    - `externalIds` (object[])
      - `integration` (string, required)
      - `externalId` (string, required)
      - `syncedAt` (string | null)
    - `properties` (object)
    - `priority` (integer)
    - `inheritCompanyPriority` (boolean)
    - `tags` (string[])
    - `introducedBy` (string | null)
    - `scope` (enum) One of: `user`, `team`.
    - `team` (string | null)
    - `status` (string, required)
    - `consumer` (object | null): When the contact is also a user of your app: that user. Otherwise null.
      - `id` (string, required)
      - `name` (string | null, required)
      - `email` (string | null, required)
    - `createdAt` (string, required)
    - `updatedAt` (string, required)
    - `assistant` (object | null)
      - `name` (string | null)
      - `email` (string | null)
      - `userIdentifier` (string | null)
      - `source` (enum) One of: `manual`, `null`.
    - `internal` (boolean)
    - `isMember` (boolean)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)
- `400`: No user: send X-User-Email, or pass userId with an account key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "contacts": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "user": "user",
      "name": "Ava",
      "email": "jane@harborview.co",
      "company": {
        "id": "6660c4a1f2e3b7d8a9c01234",
        "name": "Ava",
        "slug": "slug",
        "domain": "harborview.co"
      },
      "title": "Send Brightline the contract renewal"
    }
  ]
}
```

## POST /contacts

Create a contact

Creates a contact for the user. When the email address belongs to a user of your app, `consumer` links the contact to that user.

Acts as one user: send `X-User-Email`.

**Request body** (JSON)

- `email` (string, required)
- `name` (string)
- `preferredName` (string)
- `phones` (object[])
  - `number` (string, required)
  - `type` (enum) One of: `mobile`, `work`, `home`, `other`.
  - `primary` (boolean)
- `emails` (object[])
  - `address` (string, required)
  - `type` (enum) One of: `personal`, `work`, `other`.
  - `primary` (boolean)
- `company` (string)
- `title` (string)
- `timezone` (string)
- `consumerEmail` (string): Address used to link the contact to a user of your app; defaults to email
- `source` (string | object | null)
- `externalIds` (object[])
  - `integration` (string, required)
  - `externalId` (string, required)
- `properties` (object)
- `scope` (enum) One of: `user`, `team`.
- `team` (string)
- `tags` (string[])
- `priority` (integer)
- `inheritCompanyPriority` (boolean)

**Responses**

- `201`: Created
  - `ok` (enum, required) One of: `true`.
  - `contact` (object, required)
    - `id` (string, required)
    - `user` (string, required)
    - `name` (string | null, required)
    - `preferredName` (string | null)
    - `email` (string, required)
    - `emails` (object[])
      - `address` (string, required)
      - `type` (enum) One of: `work`, `personal`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `phones` (object[])
      - `number` (string, required)
      - `type` (enum) One of: `work`, `mobile`, `home`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `iMessageCapable` (boolean | null)
    - `company` (object | null, required)
      - `id` (string, required)
      - `name` (string, required)
      - `slug` (string, required)
      - `domain` (string | null, required)
    - `title` (string | null, required)
    - `timezone` (string | null, required)
    - `tzOffset` (string | null)
    - `photoUrl` (string | null)
    - `website` (string | null, required)
    - `bookingLink` (string | null, required)
    - `social` (object)
      - `linkedIn` (string)
      - `x` (string)
      - `other` (string)
    - `address` (object)
      - `line1` (string)
      - `line2` (string)
      - `city` (string)
      - `state` (string)
      - `zip` (string)
      - `country` (string)
    - `enrichedAt` (string | null)
    - `source` (object | null)
      - `type` (enum) One of: `manual`, `teammate`, `teammate_archived`, `imported`, `email`, `import`, `crm`, `ats`, `hris`, `voice`, `onboarding`, `calendar`, `other`, `null`.
      - `userId` (string | null)
    - `lastContactedAt` (string | null)
    - `externalIds` (object[])
      - `integration` (string, required)
      - `externalId` (string, required)
      - `syncedAt` (string | null)
    - `properties` (object)
    - `priority` (integer)
    - `inheritCompanyPriority` (boolean)
    - `tags` (string[])
    - `introducedBy` (string | null)
    - `scope` (enum) One of: `user`, `team`.
    - `team` (string | null)
    - `status` (string, required)
    - `consumer` (object | null): When the contact is also a user of your app: that user. Otherwise null.
      - `id` (string, required)
      - `name` (string | null, required)
      - `email` (string | null, required)
    - `createdAt` (string, required)
    - `updatedAt` (string, required)
    - `assistant` (object | null)
      - `name` (string | null)
      - `email` (string | null)
      - `userIdentifier` (string | null)
      - `source` (enum) One of: `manual`, `null`.
    - `internal` (boolean)
    - `isMember` (boolean)
- `400`: email is missing, or a contact already has one of these addresses
- `401`: No user on the call: send X-User-Email with an account key, or use a user-scoped key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "email": "user@example.com"
}'
```

Example response:

```json
{
  "ok": true,
  "contact": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "user": "user",
    "name": "Ava",
    "email": "jane@harborview.co",
    "company": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "name": "Ava",
      "slug": "slug",
      "domain": "harborview.co"
    },
    "title": "Send Brightline the contract renewal"
  }
}
```

## GET /contacts/{contactId}

Retrieve a contact

Retrieves one of the user's contacts with its relationships.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `contactId` (string, required)

**Responses**

- `200`: Contact
  - `ok` (enum, required) One of: `true`.
  - `contact` (object, required)
    - `id` (string, required)
    - `user` (string, required)
    - `name` (string | null, required)
    - `preferredName` (string | null)
    - `email` (string, required)
    - `emails` (object[])
      - `address` (string, required)
      - `type` (enum) One of: `work`, `personal`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `phones` (object[])
      - `number` (string, required)
      - `type` (enum) One of: `work`, `mobile`, `home`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `iMessageCapable` (boolean | null)
    - `company` (object | null, required)
      - `id` (string, required)
      - `name` (string, required)
      - `slug` (string, required)
      - `domain` (string | null, required)
    - `title` (string | null, required)
    - `timezone` (string | null, required)
    - `tzOffset` (string | null)
    - `photoUrl` (string | null)
    - `website` (string | null, required)
    - `bookingLink` (string | null, required)
    - `social` (object)
      - `linkedIn` (string)
      - `x` (string)
      - `other` (string)
    - `address` (object)
      - `line1` (string)
      - `line2` (string)
      - `city` (string)
      - `state` (string)
      - `zip` (string)
      - `country` (string)
    - `enrichedAt` (string | null)
    - `source` (object | null)
      - `type` (enum) One of: `manual`, `teammate`, `teammate_archived`, `imported`, `email`, `import`, `crm`, `ats`, `hris`, `voice`, `onboarding`, `calendar`, `other`, `null`.
      - `userId` (string | null)
    - `lastContactedAt` (string | null)
    - `externalIds` (object[])
      - `integration` (string, required)
      - `externalId` (string, required)
      - `syncedAt` (string | null)
    - `properties` (object)
    - `priority` (integer)
    - `inheritCompanyPriority` (boolean)
    - `tags` (string[])
    - `introducedBy` (string | null)
    - `scope` (enum) One of: `user`, `team`.
    - `team` (string | null)
    - `status` (string, required)
    - `consumer` (object | null): When the contact is also a user of your app: that user. Otherwise null.
      - `id` (string, required)
      - `name` (string | null, required)
      - `email` (string | null, required)
    - `createdAt` (string, required)
    - `updatedAt` (string, required)
    - `assistant` (object | null)
      - `name` (string | null)
      - `email` (string | null)
      - `userIdentifier` (string | null)
      - `source` (enum) One of: `manual`, `null`.
    - `internal` (boolean)
    - `isMember` (boolean)
    - `outgoingRelationships` (object[])
      - `id` (string, required)
      - `account` (string, required)
      - `user` (string, required)
      - `fromContact` (string | any, required)
      - `toContact` (string | any, required)
      - `type` (any, required)
      - `role` (string | null)
      - `isPrimary` (boolean)
      - `notes` (string | null)
      - `createdAt` (string, required)
      - `updatedAt` (string, required)
    - `incomingRelationships` (object[])
      - `id` (string, required)
      - `account` (string, required)
      - `user` (string, required)
      - `fromContact` (string | any, required)
      - `toContact` (string | any, required)
      - `type` (any, required)
      - `role` (string | null)
      - `isPrimary` (boolean)
      - `notes` (string | null)
      - `createdAt` (string, required)
      - `updatedAt` (string, required)
- `401`: No user on the call: send X-User-Email with an account key, or use a user-scoped key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts/<contactId>' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "contact": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "user": "user",
    "name": "Ava",
    "email": "jane@harborview.co",
    "company": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "name": "Ava",
      "slug": "slug",
      "domain": "harborview.co"
    },
    "title": "Send Brightline the contract renewal",
    "outgoingRelationships": [],
    "incomingRelationships": []
  }
}
```

## PUT /contacts/{contactId}

Update a contact

Updates a contact. Only the fields you send change.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `contactId` (string, required)

**Request body** (JSON)

- `name` (string)
- `preferredName` (string | null)
- `phones` (object[])
  - `number` (string, required)
  - `type` (enum) One of: `mobile`, `work`, `home`, `other`.
  - `primary` (boolean)
- `company` (string | null)
- `title` (string | null)
- `timezone` (string)
- `status` (string)
- `website` (string | null)
- `bookingLink` (string | null)
- `introducedBy` (string | null)
- `social` (object)
  - `linkedIn` (string)
  - `x` (string)
  - `other` (string)
- `address` (object)
  - `line1` (string)
  - `line2` (string)
  - `city` (string)
  - `state` (string)
  - `zip` (string)
  - `country` (string)
- `emails` (object[])
  - `address` (string, required)
  - `type` (enum) One of: `personal`, `work`, `other`.
  - `primary` (boolean)
- `lastContactedAt` (string | null)
- `enrichedAt` (string | null)
- `properties` (object)
- `scope` (enum) One of: `user`, `team`.
- `team` (string | null)
- `tags` (string[])
- `priority` (integer)
- `inheritCompanyPriority` (boolean)

**Responses**

- `200`: Updated
  - Same fields as the `201` response of `POST /contacts`.
- `401`: No user on the call: send X-User-Email with an account key, or use a user-scoped key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts/<contactId>' \
  -X PUT \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Ava",
  "preferredName": "Ava",
  "phones": [
    {
      "number": "+14155550142"
    }
  ],
  "company": "company"
}'
```

Example response:

```json
{
  "ok": true,
  "contact": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "user": "user",
    "name": "Ava",
    "email": "jane@harborview.co",
    "company": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "name": "Ava",
      "slug": "slug",
      "domain": "harborview.co"
    },
    "title": "Send Brightline the contract renewal"
  }
}
```

## DELETE /contacts/{contactId}

Delete a contact

Deletes a contact.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `contactId` (string, required)

**Responses**

- `200`: Deleted
  - `ok` (enum, required) One of: `true`.
  - `contact` (object, required)
    - `id` (string, required)
    - `deleted` (boolean)
    - `message` (string)
- `401`: No user on the call: send X-User-Email with an account key, or use a user-scoped key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts/<contactId>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

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

## POST /contacts/bulk-import

Import contacts

Creates or updates up to 1,000 contacts in one call, matched to existing contacts by email. Rows with no email, or with an address already in the batch, are skipped and listed in `errors`.

Acts as one user: send `X-User-Email`.

**Request body** (JSON)

- `contacts` (object[], required)
  - `email` (string, required)
  - `name` (string)
  - `preferredName` (string)
  - `phone` (string)
  - `phones` (object[])
    - `number` (string, required)
    - `type` (enum) One of: `mobile`, `work`, `home`, `other`.
    - `primary` (boolean)
  - `company` (string)
  - `title` (string)
  - `timezone` (string)
  - `emails` (object[])
    - `address` (string, required)
    - `type` (enum) One of: `personal`, `work`, `other`.
    - `primary` (boolean)
  - `properties` (object)
  - `tags` (string[])

**Responses**

- `200`: Import result
  - `ok` (enum, required) One of: `true`.
  - `bulkImport` (object, required)
    - `success` (boolean, required)
    - `total` (number, required)
    - `created` (number, required)
    - `updated` (number, required)
    - `skipped` (number, required)
    - `errors` (object[], required)
      - `index` (number)
      - `email` (string)
      - `error` (string, required)
- `401`: No user on the call: send X-User-Email with an account key, or use a user-scoped key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts/bulk-import' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "contacts": [
    {
      "email": "user@example.com"
    }
  ]
}'
```

Example response:

```json
{
  "ok": true,
  "bulkImport": {
    "success": true,
    "total": 42,
    "created": 1,
    "updated": 1,
    "skipped": 1,
    "errors": [
      {
        "error": "error"
      }
    ]
  }
}
```

## POST /contacts/{contactId}/merge

Merge contacts

Merges `mergeContactId` into this contact. Fields are combined, tasks and relationships move to this contact, and the other contact is deleted. `preferredEmail` sets the primary address.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `contactId` (string, required)

**Request body** (JSON)

- `mergeContactId` (string, required)
- `preferredEmail` (string)

**Responses**

- `200`: Merged
  - `ok` (enum, required) One of: `true`.
  - `contact` (object, required)
    - `id` (string, required)
    - `user` (string, required)
    - `name` (string | null, required)
    - `preferredName` (string | null)
    - `email` (string, required)
    - `emails` (object[])
      - `address` (string, required)
      - `type` (enum) One of: `work`, `personal`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `phones` (object[])
      - `number` (string, required)
      - `type` (enum) One of: `work`, `mobile`, `home`, `other`.
      - `primary` (boolean)
      - `source` (string)
    - `iMessageCapable` (boolean | null)
    - `company` (object | null, required)
      - `id` (string, required)
      - `name` (string, required)
      - `slug` (string, required)
      - `domain` (string | null, required)
    - `title` (string | null, required)
    - `timezone` (string | null, required)
    - `tzOffset` (string | null)
    - `photoUrl` (string | null)
    - `website` (string | null, required)
    - `bookingLink` (string | null, required)
    - `social` (object)
      - `linkedIn` (string)
      - `x` (string)
      - `other` (string)
    - `address` (object)
      - `line1` (string)
      - `line2` (string)
      - `city` (string)
      - `state` (string)
      - `zip` (string)
      - `country` (string)
    - `enrichedAt` (string | null)
    - `source` (object | null)
      - `type` (enum) One of: `manual`, `teammate`, `teammate_archived`, `imported`, `email`, `import`, `crm`, `ats`, `hris`, `voice`, `onboarding`, `calendar`, `other`, `null`.
      - `userId` (string | null)
    - `lastContactedAt` (string | null)
    - `externalIds` (object[])
      - `integration` (string, required)
      - `externalId` (string, required)
      - `syncedAt` (string | null)
    - `properties` (object)
    - `priority` (integer)
    - `inheritCompanyPriority` (boolean)
    - `tags` (string[])
    - `introducedBy` (string | null)
    - `scope` (enum) One of: `user`, `team`.
    - `team` (string | null)
    - `status` (string, required)
    - `consumer` (object | null): When the contact is also a user of your app: that user. Otherwise null.
      - `id` (string, required)
      - `name` (string | null, required)
      - `email` (string | null, required)
    - `createdAt` (string, required)
    - `updatedAt` (string, required)
    - `assistant` (object | null)
      - `name` (string | null)
      - `email` (string | null)
      - `userIdentifier` (string | null)
      - `source` (enum) One of: `manual`, `null`.
    - `internal` (boolean)
    - `isMember` (boolean)
    - `merged` (boolean, required)
    - `mergedContactId` (string, required)
- `401`: No user on the call: send X-User-Email with an account key, or use a user-scoped key
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/contacts/<contactId>/merge' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "mergeContactId": "6660c4a1f2e3b7d8a9c01234"
}'
```

Example response:

```json
{
  "ok": true,
  "contact": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "user": "user",
    "name": "Ava",
    "email": "jane@harborview.co",
    "company": {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "name": "Ava",
      "slug": "slug",
      "domain": "harborview.co"
    },
    "title": "Send Brightline the contract renewal",
    "merged": true,
    "mergedContactId": "6660c4a1f2e3b7d8a9c01234"
  }
}
```
