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

# Create or update a contact

> Creates a new contact or updates an existing one (upsert).

**Lookup order:**
1. If `_id` is provided, finds by ID.
2. Otherwise finds by first email address.
3. If no match is found, creates a new contact.

**Body formats** — either native or legacy (capitalized keys) are accepted:

*Native:* `firstname`, `lastname`, `email` (string or array), `phone` (array of `{number, type}`),
`typeId`, `contactType`, `isCompany`, `title`, `company`, `imageUrl`, `customFields`

*Legacy:* `"First Name"`, `"Last Name"`, `Email`, `"Mobile Phone"`, `"Work Phone"`,
`"Home Phone"`, `"Contact Type"`, `Title`, `Company`

Returns the enriched contact with custom fields populated by their type definitions.




## OpenAPI

````yaml /openapi.yaml post /api/contacts
openapi: 3.0.3
info:
  title: Aptly API
  version: '1.0'
  description: >
    The Aptly API lets you read and write cards on any Aptly board from external
    systems.


    All requests require an API key passed as the `x-token` header.

    API keys are scoped to your company and work across all boards.
servers:
  - url: https://core-api.getaptly.com
    description: Production
security:
  - ApiKeyHeader: []
paths:
  /api/contacts:
    post:
      tags:
        - Contacts
      summary: Create or update a contact
      description: >
        Creates a new contact or updates an existing one (upsert).


        **Lookup order:**

        1. If `_id` is provided, finds by ID.

        2. Otherwise finds by first email address.

        3. If no match is found, creates a new contact.


        **Body formats** — either native or legacy (capitalized keys) are
        accepted:


        *Native:* `firstname`, `lastname`, `email` (string or array), `phone`
        (array of `{number, type}`),

        `typeId`, `contactType`, `isCompany`, `title`, `company`, `imageUrl`,
        `customFields`


        *Legacy:* `"First Name"`, `"Last Name"`, `Email`, `"Mobile Phone"`,
        `"Work Phone"`,

        `"Home Phone"`, `"Contact Type"`, `Title`, `Company`


        Returns the enriched contact with custom fields populated by their type
        definitions.
      operationId: upsertContact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                _id:
                  type: string
                  description: Existing contact ID — when provided, updates that contact.
                firstname:
                  type: string
                lastname:
                  type: string
                email:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: One or more email addresses.
                phone:
                  type: array
                  items:
                    type: object
                    properties:
                      number:
                        type: string
                      type:
                        type: string
                        enum:
                          - mobile
                          - work
                          - home
                typeId:
                  type: string
                  description: Contact type ID.
                contactType:
                  type: string
                  description: >-
                    Contact type name (alternative to `typeId` — resolved to an
                    ID automatically).
                isCompany:
                  type: boolean
                title:
                  type: string
                company:
                  type: string
                imageUrl:
                  type: string
                  description: Absolute URL to a JPG or PNG photo.
                customFields:
                  type: object
                  description: >-
                    Map of custom field ID to value. Unknown field IDs are
                    rejected.
            example:
              firstname: Jane
              lastname: Smith
              email: jane@example.com
              phone:
                - number: '+15555550100'
                  type: mobile
              contactType: Tenant
      responses:
        '200':
          description: Contact created or updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contact'
        '400':
          description: Invalid input (bad URL, unknown custom field, invalid date, etc.).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or missing API key.
      security:
        - ApiKeyHeader: []
        - DelegateToken: []
components:
  schemas:
    Contact:
      type: object
      properties:
        _id:
          type: string
          description: MongoDB ObjectId of the contact.
        uuid:
          type: string
        firstname:
          type: string
        lastname:
          type: string
        fullName:
          type: string
          description: >-
            Computed display name (first + last, or company name for org
            records).
        duogram:
          type: string
          description: Two-letter initials derived from first and last name.
        photoId:
          type: string
          nullable: true
        imageUrl:
          type: string
          nullable: true
          description: CDN thumbnail URL for the contact's photo, or null if none.
        email:
          type: string
        phone:
          type: string
        typeId:
          type: string
        companyId:
          type: string
        address:
          type: object
        title:
          type: string
        alerts:
          type: array
          items:
            type: object
        company:
          type: string
          description: Company name — populated when isCompany is true.
        isCompany:
          type: boolean
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-token
    DelegateToken:
      type: apiKey
      in: header
      name: Authorization
      description: 'Delegate token issued by the platform. Format: `DelegateToken <token>`'

````