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

# Create Contact

> Creates a contact. Either `email` or `phone_number` is required. Requires the `contacts:write` permission.



## OpenAPI

````yaml post /api/v1/contacts
openapi: 3.0.0
info:
  title: libredesk API
  description: >-
    REST API documentation for libredesk helpdesk system.


    ## Authentication


    The libredesk API supports two authentication methods:


    ### 1. Basic Authentication

    Use your API key and secret with Basic authentication:

    ```

    Authorization: Basic <base64_encoded_api_key:api_secret>

    ```


    ### 2. Token Authentication  

    Use your API key and secret with token authentication:

    ```

    Authorization: token api_key:api_secret

    ```


    To obtain API credentials, generate them from your agent profile in the
    libredesk dashboard.
  version: 1.0.0
servers:
  - url: http://localhost:8080
    description: Local development server
security:
  - basicAuth: []
  - tokenAuth: []
paths:
  /api/v1/contacts:
    post:
      tags:
        - Contacts
      summary: Create Contact
      description: >-
        Creates a contact. Either `email` or `phone_number` is required.
        Requires the `contacts:write` permission.
      operationId: handleCreateContact
      requestBody:
        description: Contact details
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - first_name
              properties:
                first_name:
                  type: string
                  description: Contact's first name
                last_name:
                  type: string
                  description: Contact's last name
                email:
                  type: string
                  format: email
                  description: >-
                    Contact's email address. Must not belong to another contact.
                    Required when `phone_number` is empty.
                phone_number:
                  type: string
                  description: Contact's phone number. Required when `email` is empty.
                phone_number_country_code:
                  type: string
                  description: ISO country code of the phone number
                country:
                  type: string
                  description: Contact's country as an ISO 3166-1 alpha-2 code
                  example: US
      responses:
        '200':
          description: Contact created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - basicAuth: []
        - tokenAuth: []
components:
  schemas:
    ContactResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        data:
          $ref: '#/components/schemas/Contact'
    ErrorResponse:
      type: object
      description: Error response format
      properties:
        status:
          type: string
          example: error
        message:
          type: string
          description: Error message
          example: Invalid request
        data:
          nullable: true
          description: Additional error data
        error_type:
          type: string
          enum:
            - GeneralException
            - PermissionException
            - InputException
            - DataException
            - NetworkException
            - NotFoundException
            - ConflictException
            - UnauthorizedException
            - RateLimitException
    Contact:
      type: object
      properties:
        id:
          type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        first_name:
          type: string
        last_name:
          type: string
        email:
          type: string
          format: email
          nullable: true
        type:
          type: string
        availability_status:
          type: string
          enum:
            - online
            - away
            - away_manual
            - offline
            - away_and_reassigning
          example: online
        avatar_url:
          type: string
          nullable: true
        phone_number:
          type: string
          nullable: true
        phone_number_country_code:
          type: string
          nullable: true
        custom_attributes:
          type: object
          nullable: true
        enabled:
          type: boolean
        last_active_at:
          type: string
          format: date-time
          nullable: true
        last_login_at:
          type: string
          format: date-time
          nullable: true
        roles:
          type: array
          items:
            type: string
          nullable: true
        permissions:
          type: array
          items:
            type: string
          nullable: true
        teams:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/TeamCompact'
        api_key:
          type: string
          nullable: true
        api_key_last_used_at:
          type: string
          format: date-time
          nullable: true
        country:
          type: string
          nullable: true
          description: ISO 3166-1 alpha-2 country code
          example: US
        meta:
          type: object
          nullable: true
        external_user_id:
          type: string
          nullable: true
          description: External identifier for the user in your own system
        contact_channel_id:
          type: integer
          description: Present only when non-zero
    TeamCompact:
      type: object
      properties:
        id:
          type: integer
          example: 1
        name:
          type: string
          example: Support Team
        emoji:
          type: string
          nullable: true
          example: 🛠️
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Basic authentication using base64 encoded API key and secret. Format:
        `Authorization: Basic <base64(api_key:api_secret)>`
    tokenAuth:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        Token authentication using API key and secret. Format: `Authorization:
        token api_key:api_secret`

````

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