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

# Add and update contact

> Creates a new contact or updates an existing one based on email or LinkedIn URL.

Creates a new contact in your CRM, or updates an existing one if a contact with the same `email`, `linkedinUrl`, or `linkedinUrlSalesNav` already exists (upsert).

On update, the `updateStrategy` query parameter decides what the existing record keeps (see below). By default, sent values replace stored ones and empty values are ignored.

> [!NOTE]
>
> This endpoint uses the [Contact object](https://developer.lemlist.com/api-reference/objects-definitions/contact.md).

## Upsert matching

At least one identifier is required:

| Identifier | Description |
| - | - |
| `contactId` | Existing contact ID — updates a specific contact directly, bypassing email/LinkedIn matching |
| `email` | Primary email address — used as the main unique key |
| `linkedinUrl` | LinkedIn profile URL — used as an alternative unique key |
| `linkedinUrlSalesNav` | LinkedIn Sales Navigator profile URL — used as an alternative unique key |

If a contact with the same `email`, `linkedinUrl`, or `linkedinUrlSalesNav` already exists, the endpoint updates it instead of creating a duplicate.

Creating a contact requires the "Create contacts" permission on the API key's user, otherwise the request fails with `403 CONTACT_CREATE_NOT_ALLOWED` and nothing is written. Updating an existing contact does not require it. The error names that user (`The user jane@acme.com does not have the permission to create contacts`); when the API key's user is no longer in the team, it fails with `403 API_USER_NOT_IN_TEAM` instead.

When `contactId` is provided, the contact is matched by its ID directly — `email` and `linkedinUrl` are not required and are not used for matching (they are stored as data if provided).

> [!WARNING]
>
> `contactId` can only be used to **update** an existing contact. It cannot be used to create a new contact — use `email` or `linkedinUrl` for creation.

## Update strategy

The `updateStrategy` query parameter decides what an existing contact keeps:

| Value | Stored value | Empty string sent |
| - | - | - |
| `overwriteIgnoreEmpty` (default) | Replaced | Ignored |
| `overwrite` | Replaced | Cleared |
| `fillEmptyOnly` | Kept | Ignored |

`null` and absent keys never touch a field. Identifiers (`email`, `linkedinUrl`, `linkedinUrlSalesNav`) are never cleared. Under `fillEmptyOnly`, the company link, the owner and the status are kept when set and filled when missing. A new contact receives every value sent. Any other value answers `400 INVALID_UPDATE_STRATEGY`.

```bash theme={"theme":"dracula"}
curl -X POST "https://api.lemlist.com/api/contacts?updateStrategy=fillEmptyOnly" \
  -u ":YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "john@example.com", "jobTitle": "Founder", "phone": "+33600000000"}'
```

Kept values are reported: `warnings` carries a `FIELDS_KEPT` entry with the field names in `params.fields`. It appears under `fillEmptyOnly` on a stored value, and under the default when an empty string is ignored on a filled field, never for an identical value.

```json theme={"theme":"dracula"}
{
  "success": true,
  "data": { "_id": "ctc_2aB3cD4eF5gH6iJ7k", "jobTitle": "CEO", "phone": "+33600000000", "created": false, "updated": true, "companyLinked": false },
  "warnings": [
    { "code": "FIELDS_KEPT", "message": "Fields kept: the record already holds a different value, left unchanged by the update strategy", "params": { "fields": ["jobTitle"] } }
  ]
}
```

## Linking to a company

You can link the contact to a company that already exists in your lemlist CRM using one of the following fields (in order of priority):

| Field | Description |
| - | - |
| `companyId` | Direct company ID — takes priority over the others |
| `companyDomain` | Company domain (e.g. `lemlist.com`) — used if `companyId` is not provided |
| `companyLinkedinUrl` | Company LinkedIn URL — used as a last resort |

When a company is successfully linked, the response includes `companyLinked: true` and the `companyId`.

## Linking to a CRM record

Send `crmId` with the id of a record in your connected CRM to link the contact to that record. lemlist links it without searching the CRM, then runs a first sync that follows your field mapping (the CRM wins conflicts by default).

> [!WARNING]
>
> `crmId` is in closed beta. Unless the CRM ID remap beta is enabled for your team, it is refused like any unknown field, with `400 INVALID_FIELD`. It also requires an **admin** API key.

| CRM | Accepted id |
| - | - |
| HubSpot, Pipedrive, Zoho | Numeric record id. Send a Zoho id as a string: its 19 digits are too long for a JSON number. |
| Attio | Record id (UUID) |
| Salesforce | Contact (`003…`) or Lead (`00Q…`) id, 15 or 18 characters. A 15-character id is stored as 18. |

What happens depends on the contact and on who already holds the id:

| Situation | Result |
| - | - |
| New contact, the id is linked to no lemlist contact | The contact is created already linked to that record (`201`). |
| Existing contact, named by `contactId` or found by its email or LinkedIn URL | Its link moves to that record (`200`). The previous CRM record stops being synced: updates queued for it are cancelled. When your mapping includes the "synced with lemlist" field, it is set to false there; when it includes the Lemlist Contact ID, that field is cleared there. |
| The id is already linked to a lemlist contact, and at least one of the body's `email` (its primary email), `linkedinUrl` or `linkedinUrlSalesNav` is that contact's | The `crmId` finds the contact and that identifier confirms it: the body updates it (`200`) and its link stays as it is. The body's other identifiers are written to the contact, unless they already belong to another contact: `409 CONTACT_IDENTIFIER_CONFLICT`. Sending the same payload twice is safe. |
| The id is already linked to a lemlist contact, and none of the body's identifiers is that contact's | Refused, nothing written: `409 CRM_ID_ALREADY_LINKED`, `error.conflictingRecord` names that contact. Another of its email addresses is not enough: only its primary email confirms it. |

The `crmSync` block of the response shows the link the contact ends up with.

```bash theme={"theme":"dracula"}
curl -X POST "https://api.lemlist.com/api/contacts" \
  -u ":YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "john@example.com", "firstName": "John", "crmId": "123456789"}'
```

Every check runs before anything is written, so a refused call leaves the contact as it was:

| Status | Code | When |
| - | - | - |
| `400` | `INVALID_CRM_ID` | The id does not have the format of your CRM, or points to another kind of record (a Salesforce Account id for a contact). |
| `400` | `NO_CRM_CONNECTED` | Your team has no CRM connected. |
| `403` | `CRM_ID_UPDATE_NOT_ALLOWED` | The API key does not belong to a team admin. |
| `409` | `CRM_ID_ALREADY_LINKED` | Another lemlist contact holds the id (see above); `error.conflictingRecord` names it. |
| `422` | `CRM_RECORD_NOT_FOUND` | No record with this id exists in the CRM, or it was deleted. |
| `422` | `CRM_RECORD_MERGED` | The record was merged into another one; `error.survivorId` is the id to send. |
| `422` | `CRM_RECORD_CONVERTED` | The Salesforce Lead was converted; `error.convertedContactId` is the Contact id to send. |
| `422` | `CRM_ID_LEADS_NOT_SYNCED` | A Salesforce Lead id, while your team does not sync Leads. |
| `503` | `CRM_RECORD_UNREACHABLE` | The CRM could not be reached to check the record. Retry. |

```json theme={"theme":"dracula"}
{
  "success": false,
  "error": {
    "code": "CRM_ID_ALREADY_LINKED",
    "message": "This CRM id is already used by another lemlist record",
    "conflictingRecord": { "contactId": "ctc_A1B2C3D4E5F6G7H8i", "email": "jane@example.com", "name": "Jane Smith" }
  }
}
```

A Salesforce Lead id sent with the email of a contact already linked to the Contact of the same person, without `contactId`, keeps the existing link: the response is `200` with a `CRM_ID_NOT_APPLIED` entry in `warnings`. Send the `contactId` to move the link.

## Owner assignment

You can assign an owner to the contact using the `contactOwner` field. Accepted formats:

| Format | Example |
| - | - |
| User ID | `usr_2aB3cD4eF5gH6iJ7k` |
| Team member email | `john@yourcompany.com` |

> [!NOTE]
>
> If the provided value does not match a team member (invalid format, unknown email, or unknown user ID), the contact is still written and the response carries an `OWNER_NOT_FOUND` or `INVALID_OWNER_FORMAT` entry in `warnings`. On creation, the contact defaults to the API key owner; on update, the current owner is unchanged.

On an existing contact, `updateStrategy` decides the owner:

| Strategy | Current owner set | No current owner |
| - | - | - |
| `overwriteIgnoreEmpty` (default) and `overwrite` | Replaced by `contactOwner` | Set to `contactOwner` |
| `fillEmptyOnly` | Kept, reported as `ownerId` under `warnings` (`FIELDS_KEPT`) | Set to `contactOwner` |

Without `contactOwner`, the owner is never touched.


## OpenAPI

````yaml post /contacts
openapi: 3.0.0
info:
  title: lemlist API
  version: 1.0.0
  description: >-
    Welcome to the lemlist Developer Documentation.


    lemlist is very customizable and open. You'll find on this page all the API
    and integration you can do with lemlist.


    # Rate Limit


    lemlist's API rate limits requests in order to prevent abuse and overload of
    our services.  

    Rate limits are applied on all routes and per API key performing the
    request.  

    The rate limits are **20** requests per **2** seconds.  

    The response provides any information you may need about it:


    | Header | Description |

    | --- | --- |

    | Retry-After | The number of seconds in which you can retry |

    | X-RateLimit-Limit | The maximum requests in that time |

    | X-RateLimit-Remaining | The number of remaining requests you can make |

    | X-RateLimit-Reset | The date when the rate limit will reset |


    _Example of values for the rate limit headers_


    ``` json

    {
        "Retry-After": 2,
        "X-RateLimit-Limit": 20,
        "X-RateLimit-Remaining": 7,
        "X-RateLimit-Reset" : "Tue Feb 16 2021 09:02:42 GMT+0100 (Central European Standard Time)"
    }

     ```

    # Definitions


    ## Team


    A team is the entity of lemlist that can handle users and billing.


    ## Credits


    Credits are the coins a team uses to enrich emails, LinkedIn URLs, etc. via
    the enrich route. Each enrichment feature needs a certain amount of credits
    to run.


    ## User


    You use a user account to connect to lemlist and send messages via the
    connected emails or LinkedIn account.


    ## Campaign


    A campaign is the entity to automate outreach. A campaign has multiple
    sequences composed of steps.


    ## Lead


    A lead is a person that you try to contact via a campaign.


    ## Activity


    An activity is the history of all the steps.


    ## Unsubscribe


    An unsubscribe occurs when a person decides they don't want to receive
    emails from you anymore.


    # Authentication


    All API routes use the dedicated subdomain `api.lemlist.com`.


    lemlist uses API keys to allow access to the API. You can get your lemlist
    API key at our [integration
    page](https://app.lemlist.com/settings/integrations).


    You need to add the `Authorization` header using the `Basic` authentication
    type. `login:password` **where the login is always empty and the password is
    the API key**.


    ⚠️ **Don't forget to add the semicolon (**`:`**) before your API key in curl
    command.**


    > To authorize, use this code: 
      

    ``` shell

    curl https://api.lemlist.com/api/team \
      --user ":YourApiKey"

     ```

    **Make sure to replace** **`YourApiKey`** **with your API key.**


    # Give feedback


    If you want to report a bug, ask for data, or share with us a use case,
    please fill this [form](https://lemlist.typeform.com/to/mfVlkyGf). It will
    help us centralize your needs!
servers:
  - url: https://api.lemlist.com/api
security:
  - basicAuth: []
tags:
  - name: Enrichment Providers
    description: >-
      The data providers lemlist can call to find an email or a phone.


      Internal providers are paid with lemlist credits and always available.
      External providers run on your own account: connect one by saving its API
      key, and it becomes available to your waterfalls. `GET
      /enrichments/providers` is the catalog of provider ids accepted by the
      waterfall endpoints.
  - name: Enrichment Waterfalls
    description: >-
      Control which data providers lemlist calls when enriching a contact, and
      in which order.


      A waterfall is an ordered list of providers for one enrichment `type`
      (`email` or `phone`). Providers are tried one after the other until one
      returns a result.


      Every team has exactly one default waterfall per type (`isDefault: true`).
      While its `editor` is `lemlist` it follows the lemlist behaviour:
      providers you connected with your own API key are tried first, then
      internal providers in a random order. Once a team member edits its
      provider list, `editor` becomes that user's id and the list is followed as
      is; resetting it hands it back to `lemlist`.


      Custom waterfalls (`isDefault: false`) carry `conditions` on the contact
      being enriched, keyed by contact property; every key present must match.
      When a contact is enriched, lemlist runs a single waterfall: the custom
      waterfall of the requested type whose conditions match the contact, or the
      default waterfall when none does. If several match, the one with the most
      condition keys wins, then the most recently updated. Only that waterfall
      runs; when it finds nothing, the enrichment ends without falling back to
      another one.
paths:
  /contacts:
    post:
      tags:
        - Contacts
      summary: Add and update contact
      description: >-
        Creates a new contact or updates an existing one (upsert). If a contact
        with the same email, LinkedIn URL, or Sales Navigator URL already
        exists, it is updated as the `updateStrategy` query parameter says (by
        default, sent values replace stored ones and empty values are ignored).
        You can target an existing contact directly by providing `contactId`,
        bypassing email/LinkedIn matching. You can optionally link the contact
        to a company by providing `companyId`, `companyDomain`, or
        `companyLinkedinUrl`.


        **Permission:** creating a contact requires the "Create contacts"
        permission on the API key's user, otherwise the request fails with `403
        CONTACT_CREATE_NOT_ALLOWED`; when that user is no longer in the team,
        with `403 API_USER_NOT_IN_TEAM`. Updating an existing contact does not.
      parameters:
        - name: updateStrategy
          in: query
          required: false
          description: >-
            What an existing record keeps. `overwriteIgnoreEmpty` (default):
            sent values replace stored ones, empty values are ignored.
            `overwrite`: an empty string clears the field. `fillEmptyOnly`: only
            empty fields are filled, identifiers, links, owner and status kept.
            A new record receives every value sent. Other values: `400
            INVALID_UPDATE_STRATEGY`.
          example: fillEmptyOnly
          schema:
            type: string
            enum:
              - overwrite
              - overwriteIgnoreEmpty
              - fillEmptyOnly
            default: overwriteIgnoreEmpty
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contactId:
                  type: string
                  description: >-
                    Existing contact ID. Updates a specific contact by ID,
                    bypassing email/LinkedIn matching. Can only be used to
                    update an existing contact, not to create a new one. When
                    provided, `email` and `linkedinUrl` are not required. At
                    least one of `contactId`, `email`, `linkedinUrl`, or
                    `linkedinUrlSalesNav` is required.
                email:
                  type: string
                  description: >-
                    Contact email address. Used as a unique key for upsert
                    matching. At least one of `contactId`, `email`,
                    `linkedinUrl`, or `linkedinUrlSalesNav` is required.
                linkedinUrl:
                  type: string
                  description: >-
                    LinkedIn profile URL. Used as an alternative unique key for
                    upsert matching. At least one of `contactId`, `email`,
                    `linkedinUrl`, or `linkedinUrlSalesNav` is required.
                linkedinUrlSalesNav:
                  type: string
                  description: >-
                    LinkedIn Sales Navigator profile URL. Used as an alternative
                    unique key for upsert matching.
                additionalEmails:
                  type: array
                  items:
                    type: string
                  description: >-
                    Additional email addresses for the contact. Each must be a
                    valid email address.
                firstName:
                  type: string
                  description: Contact first name.
                lastName:
                  type: string
                  description: Contact last name.
                phone:
                  type: string
                  description: Contact phone number.
                jobTitle:
                  type: string
                  description: >-
                    Contact job title. If a company is linked, this is saved as
                    part of the job data.
                jobDescription:
                  type: string
                  description: >-
                    Contact job description. If a company is linked, this is
                    saved as part of the job data.
                picture:
                  type: string
                  description: URL of the contact's profile picture.
                timezone:
                  type: string
                  description: Contact timezone.
                industry:
                  type: string
                  description: Contact industry.
                languages:
                  type: string
                  description: Contact languages.
                location:
                  type: string
                  description: Contact location.
                skills:
                  type: string
                  description: Contact skills.
                summary:
                  type: string
                  description: Contact summary or bio.
                tagline:
                  type: string
                  description: Contact tagline.
                peopleDbSeniority:
                  type: string
                  description: Seniority of the person, from the People Database.
                peopleDbDepartment:
                  type: string
                  description: Department of the person, from the People Database.
                peopleDbConnectionCount:
                  type: string
                  description: >-
                    LinkedIn connections count of the person, from the People
                    Database. 500 usually means 500 or more.
                contactOwner:
                  type: string
                  description: >-
                    Owner of the contact. Can be a user ID (e.g. `usr_...`) or a
                    team member's email address. If the provided value does not
                    match a team member, the contact is still written with an
                    `OWNER_NOT_FOUND` or `INVALID_OWNER_FORMAT` entry in
                    `warnings`: the owner defaults to the API key owner on
                    creation and is unchanged on update. On update it replaces
                    the current owner, except under `fillEmptyOnly` where it is
                    only set when the contact has none.
                source:
                  type: string
                  description: >-
                    Origin of the contact record. Set on creation only and
                    cannot be updated afterwards. Defaults to `api`.
                  default: api
                companyId:
                  type: string
                  description: >-
                    ID of a company already existing in lemlist to link to this
                    contact. Takes priority over `companyDomain` and
                    `companyLinkedinUrl`.
                companyDomain:
                  type: string
                  description: >-
                    Domain of a company already existing in lemlist to link to
                    this contact (e.g. `lemlist.com`). Used if `companyId` is
                    not provided.
                companyLinkedinUrl:
                  type: string
                  description: >-
                    LinkedIn URL of a company already existing in lemlist to
                    link to this contact. Used if `companyId` and
                    `companyDomain` are not provided.
                crmId:
                  type: string
                  description: >-
                    Closed beta: refused as an unknown field (`400
                    INVALID_FIELD`) unless the CRM ID remap beta is enabled for
                    your team. Id of the record of the connected CRM to link the
                    contact to: a HubSpot, Pipedrive or Zoho numeric id (send a
                    Zoho id as a string: its 19 digits are too long for a JSON
                    number), an Attio record id, or a Salesforce Contact
                    (`003…`) or Lead (`00Q…`) id of 15 or 18 characters.
                    Requires an admin API key. A new contact is created already
                    linked; an existing one has its link moved to this record.
                    An id another contact holds updates that contact when the
                    body carries its email or LinkedIn URL, and is refused
                    otherwise. See the endpoint page for the refusals.
                  example: '123456789'
              additionalProperties:
                description: >-
                  Any additional key is treated as a custom field. Custom fields
                  must be registered in the team's CRM field registry
                  beforehand.
            example:
              email: jane.smith@example.com
              firstName: Jane
              lastName: Smith
              linkedinUrl: https://linkedin.com/in/janesmith
              jobTitle: Product Manager
              companyDomain: acme.com
      responses:
        '200':
          description: Existing contact updated (upsert matched by email or LinkedIn URL)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    description: >-
                      Same shape as the 201 response, with `created: false` and
                      `updated: true`.
                  warnings:
                    type: array
                    description: >-
                      Non-blocking notices: owner or company not resolved, or
                      `FIELDS_KEPT` when the update strategy kept values you
                      sent (`params.fields` names them).
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          description: >-
                            `OWNER_NOT_FOUND` or `INVALID_OWNER_FORMAT`
                            (`contactOwner` matches no team member);
                            `COMPANY_NOT_FOUND_BY_ID`,
                            `COMPANY_NOT_FOUND_BY_DOMAIN` or
                            `COMPANY_NOT_FOUND_BY_LINKEDIN_URL` (company not
                            linked); `FIELDS_KEPT` (values the update strategy
                            kept); `CRM_ID_NOT_APPLIED` (`crmId` not applied:
                            the contact stays linked to another CRM record of
                            the same person, typically a Salesforce Contact
                            facing a Lead id; send its `contactId` to move the
                            link).
                        message:
                          type: string
                        params:
                          type: object
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          description: >-
                            Details: the input echoed back, or `fields` for
                            `FIELDS_KEPT`.
              example:
                success: true
                data:
                  _id: ctc_xW8Ou6C03Csv8vatp
                  teamId: tea_8QvkOiBfPdb2ZRhHi
                  emails:
                    - value: jane.smith@example.com
                  fields:
                    firstName: Jane
                    lastName: Smith
                    jobTitle: Product Manager
                  ownerId: usr_ahfFktBBHUIxbVG5P
                  source: api
                  createdAt: '2025-10-28T00:40:37.917Z'
                  createdBy: usr_ahfFktBBHUIxbVG5P
                  unsubscribed: false
                  created: false
                  updated: true
                  companyLinked: false
        '201':
          description: Contact created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      _id:
                        type: string
                        description: Unique contact identifier
                      teamId:
                        type: string
                        description: Team ID
                      emails:
                        type: array
                        description: Contact email addresses
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                      linkedinUrl:
                        type: string
                        description: LinkedIn profile URL
                      linkedinUrlSalesNav:
                        type: string
                        description: LinkedIn Sales Navigator URL
                      fields:
                        type: object
                        description: >-
                          Key/value fields (firstName, lastName, phone,
                          jobTitle, custom fields, etc.)
                        additionalProperties: true
                      ownerId:
                        type: string
                        description: Owner user ID
                      companyId:
                        type: string
                        description: >-
                          Linked company ID (present only when a company was
                          linked)
                      source:
                        type: string
                        description: Record origin
                      createdAt:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      createdBy:
                        type: string
                        description: User ID who created the record
                      unsubscribed:
                        type: boolean
                        description: Whether the contact is unsubscribed
                      crmSync: 58b96bf9-92d8-4253-a578-498eae4694a4
                      created:
                        type: boolean
                        description: >-
                          `true` when a new contact was created, `false` when an
                          existing contact was updated.
                      updated:
                        type: boolean
                        description: >-
                          Present and set to `true` only when an existing
                          contact was updated (i.e. `created` is `false`).
                      companyLinked:
                        type: boolean
                        description: >-
                          Whether a company was successfully linked to the
                          contact.
                  warnings:
                    type: array
                    description: >-
                      Non-blocking notices: owner or company not resolved, or
                      `FIELDS_KEPT` when the update strategy kept values you
                      sent (`params.fields` names them).
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          description: >-
                            `OWNER_NOT_FOUND` or `INVALID_OWNER_FORMAT`
                            (`contactOwner` matches no team member);
                            `COMPANY_NOT_FOUND_BY_ID`,
                            `COMPANY_NOT_FOUND_BY_DOMAIN` or
                            `COMPANY_NOT_FOUND_BY_LINKEDIN_URL` (company not
                            linked); `FIELDS_KEPT` (values the update strategy
                            kept); `CRM_ID_NOT_APPLIED` (`crmId` not applied:
                            the contact stays linked to another CRM record of
                            the same person, typically a Salesforce Contact
                            facing a Lead id; send its `contactId` to move the
                            link).
                        message:
                          type: string
                        params:
                          type: object
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          description: >-
                            Details: the input echoed back, or `fields` for
                            `FIELDS_KEPT`.
              example:
                success: true
                data:
                  _id: ctc_xW8Ou6C03Csv8vatp
                  teamId: tea_8QvkOiBfPdb2ZRhHi
                  emails:
                    - value: jane.smith@example.com
                  linkedinUrl: https://www.linkedin.com/in/janesmith
                  fields:
                    firstName: Jane
                    lastName: Smith
                    jobTitle: Product Manager
                  ownerId: usr_ahfFktBBHUIxbVG5P
                  source: api
                  createdAt: '2025-10-28T00:40:37.917Z'
                  createdBy: usr_ahfFktBBHUIxbVG5P
                  unsubscribed: false
                  created: true
                  companyLinked: true
                  companyId: cpn_gG7PsmZFpEAnpMCHO
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: >-
                          Error code: `MISSING_IDENTIFIER`,
                          `INVALID_CONTACT_ID`, `INVALID_EMAIL`,
                          `INVALID_ADDITIONAL_EMAILS`, `INVALID_LINKEDIN_URL`,
                          `INVALID_FIELD`, `INVALID_USER_FIELD_FORMAT`,
                          `USER_FIELD_NOT_FOUND`, `CONTACT_VALIDATION_FAILED`,
                          `INVALID_UPDATE_STRATEGY`, `INVALID_CRM_ID` (`crmId`
                          does not have the format of the connected CRM, or
                          points to another kind of record), or
                          `NO_CRM_CONNECTED` (`crmId` sent while no CRM is
                          connected).
                      message:
                        type: string
              example:
                success: false
                error:
                  code: MISSING_IDENTIFIER
                  message: >-
                    At least one identifier is required: email, linkedinUrl or
                    contactId
        '401':
          description: The authentication you supplied is incorrect
          content:
            text/plain:
              example: The authentication you supplied is incorrect
        '403':
          description: >-
            The request would create a contact and the API key's user does not
            have the "Create contacts" permission
            (`CONTACT_CREATE_NOT_ALLOWED`); updating an existing contact is not
            affected. The message names the API key's user by email; when that
            user is no longer in the team, the code is `API_USER_NOT_IN_TEAM`.
            Or the API key does not belong to a team admin, and the body carries
            `crmId` (`CRM_ID_UPDATE_NOT_ALLOWED`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmIdLinkErrorEnvelope'
              examples:
                create-not-allowed:
                  value:
                    success: false
                    error:
                      code: CONTACT_CREATE_NOT_ALLOWED
                      message: >-
                        The user jane@acme.com does not have the permission to
                        create contacts
                api-user-not-in-team:
                  value:
                    success: false
                    error:
                      code: API_USER_NOT_IN_TEAM
                      message: >-
                        The user jane@acme.com is no longer in this team: ask a
                        current member to create a new API key or reconnect
                not-admin:
                  value:
                    success: false
                    error:
                      code: CRM_ID_UPDATE_NOT_ALLOWED
                      message: >-
                        Only a team admin can define or change the CRM id of a
                        record
        '404':
          description: >-
            No contact of the team matches `contactId`
            (`CONTACT_NOT_FOUND_BY_ID`), or the contact whose link `crmId` moves
            was deleted meanwhile (`CRM_ID_RECORD_NOT_FOUND`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
              examples:
                not-found:
                  value:
                    success: false
                    error:
                      code: CONTACT_NOT_FOUND_BY_ID
                      message: No contact found with the provided contactId
        '409':
          description: >-
            An email, LinkedIn or Sales Navigator URL already belongs to another
            contact (`CONTACT_IDENTIFIER_CONFLICT`); retrying as is fails again.
            With `crmId`: another contact holds that CRM id and the body carries
            none of its identifiers (`CRM_ID_ALREADY_LINKED`,
            `error.conflictingRecord` names it). Nothing is written.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmIdLinkErrorEnvelope'
              examples:
                conflict:
                  value:
                    success: false
                    error:
                      code: CONTACT_IDENTIFIER_CONFLICT
                      message: >-
                        An identifier (email, linkedinUrl or salesnavUrl)
                        already belongs to another contact
                crm-id-already-linked:
                  value:
                    success: false
                    error:
                      code: CRM_ID_ALREADY_LINKED
                      message: This CRM id is already used by another lemlist record
                      conflictingRecord:
                        contactId: ctc_A1B2C3D4E5F6G7H8i
                        email: jane@example.com
                        name: Jane Smith
        '422':
          description: >-
            `crmId` names no live record the contact can be linked to: none in
            the CRM (`CRM_RECORD_NOT_FOUND`), a record merged into another one
            (`CRM_RECORD_MERGED`, `error.survivorId`), a converted Salesforce
            Lead (`CRM_RECORD_CONVERTED`, `error.convertedContactId`), or a
            Salesforce Lead while the team does not sync Leads
            (`CRM_ID_LEADS_NOT_SYNCED`). Nothing is written.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmIdLinkErrorEnvelope'
              examples:
                merged:
                  value:
                    success: false
                    error:
                      code: CRM_RECORD_MERGED
                      message: >-
                        This CRM record was merged into another one: use the id
                        of the surviving record (survivorId)
                      survivorId: '987654321'
                converted:
                  value:
                    success: false
                    error:
                      code: CRM_RECORD_CONVERTED
                      message: >-
                        This Salesforce Lead was converted: use the id of the
                        Contact it became (convertedContactId)
                      convertedContactId: 003000000000000AAA
                not-found:
                  value:
                    success: false
                    error:
                      code: CRM_RECORD_NOT_FOUND
                      message: No record with this id exists in the CRM
        '503':
          description: >-
            The CRM could not be reached to check the record sent as `crmId`
            (`CRM_RECORD_UNREACHABLE`). Nothing is written; retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmIdLinkErrorEnvelope'
              examples:
                unreachable:
                  value:
                    success: false
                    error:
                      code: CRM_RECORD_UNREACHABLE
                      message: >-
                        The CRM could not be reached to check this record,
                        please retry
components:
  schemas:
    CrmIdLinkErrorEnvelope:
      type: object
      description: >-
        Error envelope of a refused `crmId` (closed beta) on the contact and
        company upserts. The extra fields name what to send instead.
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code, stable across releases.
            message:
              type: string
              description: Human-readable explanation.
            conflictingRecord:
              type: object
              description: >-
                With `CRM_ID_ALREADY_LINKED`: the lemlist record already linked
                to this CRM id.
              properties:
                contactId:
                  type: string
                  description: The contact holding the id (contact upsert).
                companyId:
                  type: string
                  description: The company holding the id (company upsert).
                name:
                  type: string
                email:
                  type: string
                  description: Primary email of the contact.
                linkedinUrl:
                  type: string
                linkedinUrlSalesNav:
                  type: string
                domain:
                  type: string
                  description: Domain of the company.
            survivorId:
              type: string
              description: >-
                With `CRM_RECORD_MERGED`: the CRM record the sent one was merged
                into. Send this id instead.
            convertedContactId:
              type: string
              description: >-
                With `CRM_RECORD_CONVERTED`: the Salesforce Contact the Lead was
                converted into. Send this id instead.
          required:
            - code
            - message
      required:
        - success
        - error
    ApiErrorEnvelope:
      type: object
      description: Error envelope of the contact and company endpoints.
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code, stable across releases.
            message:
              type: string
              description: Human-readable explanation.
          required:
            - code
            - message
      required:
        - success
        - error
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````

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