> ## 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.

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

# Add and update contact

export const SnippetObjectReference = ({objectName, objectPath = null}) => {
  const lowerCaseObjectName = objectName.toLowerCase();
  if (lowerCaseObjectName === 'lead' || lowerCaseObjectName === 'leads') {
    return <Note>
        This endpoint uses the <a href={`/api-reference/objects-definitions/${objectPath}`}>{objectName} object</a>. Make sure to also check the <a href={`/api-reference/objects-definitions/${lowerCaseObjectName === 'lead' ? 'contact' : 'lead'}`}>{lowerCaseObjectName === 'lead' ? 'Contact' : 'Lead'} object</a> to understand the distinction between the two.
      </Note>;
  }
  return <Note>
      This endpoint uses the <a href={`/api-reference/objects-definitions/${objectPath}`}>{objectName} object</a>.
    </Note>;
};

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).

During updates, only non-empty fields are applied — null or empty values are ignored to preserve existing data.

<SnippetObjectReference objectName="Contact" objectPath="contact" />

## 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.

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.
</Warning>

## 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`.

## 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 owner is **silently ignored** — no error or warning is returned. On creation, the contact defaults to the API key owner.
</Note>


## 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: []
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 will be updated with the provided non-empty fields. Null or
        empty values are ignored during updates to preserve existing data. 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`.
      parameters: []
      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.
                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 owner defaults to the API key
                    owner.
                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.
              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`.
              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
                      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: Optional warnings (e.g. company resolution issues).
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                        message:
                          type: string
              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`, `CONTACT_NOT_FOUND_BY_ID`,
                          `INVALID_EMAIL`, `INVALID_ADDITIONAL_EMAILS`,
                          `INVALID_LINKEDIN_URL`, `INVALID_FIELD`, or
                          `CONTACT_VALIDATION_FAILED`.
                      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
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````