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

# Create or update a contact

> Create or update a contact for a specific agent. This endpoint allows you to identify users and associate them with chat sessions, enabling personalized experiences and contact tracking.



## OpenAPI

````yaml post /api/v2/contacts
openapi: 3.0.1
info:
  title: LiveChatAI API v2
  description: >-
    LiveChatAI API v2 - Build powerful AI-powered customer support experiences.
    This API follows REST principles with predictable, resource-oriented URLs,
    JSON responses, and standard HTTP methods.
  version: 2.0.0
servers:
  - url: https://app.livechatai.com
    description: Production server
security:
  - bearerAuth: []
paths:
  /api/v2/contacts:
    post:
      tags:
        - Contacts
      summary: Create or update a contact
      description: >-
        Create or update a contact for a specific agent. This endpoint allows
        you to identify users and associate them with chat sessions, enabling
        personalized experiences and contact tracking.
      requestBody:
        required: true
        description: Contact creation or identification details.
        content:
          application/json:
            schema:
              type: object
              required:
                - agentId
                - distinctId
              properties:
                agentId:
                  type: string
                  example: clx1234567890abcdef
                  description: Unique identifier of the agent
                distinctId:
                  type: string
                  example: user_12345
                  description: Unique identifier for the user/contact
                contactId:
                  type: string
                  example: contact_1234567890
                  description: 'Optional: Existing contact ID to update'
                userHash:
                  type: string
                  example: abc123hash
                  description: Required if secure identification is enabled for the agent.
                name:
                  type: string
                  example: John Doe
                  description: Full name of the contact
                email:
                  type: string
                  example: john@example.com
                  description: Email address of the contact
                phone:
                  type: string
                  example: '+1234567890'
                  description: Phone number of the contact
                attributes:
                  type: object
                  example:
                    planType: premium
                    userLevel: advanced
                    signupDate: '2024-01-15'
                  description: >-
                    Custom attributes to associate with the contact. Only
                    allowed attributes configured for the agent will be saved.
      responses:
        '200':
          description: Contact created or updated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  contactId:
                    type: string
                    example: contact_1234567890
                    description: ID of the created or updated contact
        '400':
          description: Bad request - Missing required parameters or an invalid user hash.
        '401':
          description: Unauthorized access
        '404':
          description: Chatbot not found or access denied.
        '500':
          description: An internal server error occurred.
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````