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

# Create contact

> Creates a new contact for a specific company.
At least one of contact_phone or contact_email must be provided.
User must have 'contacts' access role to create contacts.




## OpenAPI

````yaml POST /v1/create-contact
openapi: 3.0.3
info:
  title: SalesCaptain API Documentation Service
  description: >
    API Documentation Service for SalesCaptain platform.

    This service provides endpoints for managing and retrieving company
    information for API documentation purposes.
  version: 0.1.0
  contact:
    name: SalesCaptain API Team
    email: support@salescaptain.com
  license:
    name: Proprietary
    url: https://salescaptain.com/license
servers:
  - url: https://api.salescaptain.com
    description: Production server
security:
  - BearerAuth: []
tags:
  - name: Health
    description: Service health and status endpoints
  - name: Companies
    description: Company management and retrieval operations
  - name: Accounts
    description: Account management and retrieval operations
  - name: Conversation Profiles
    description: Conversation profile management for communication channels
  - name: Conversations
    description: Conversation management and retrieval operations
  - name: Contacts
    description: Contact management and retrieval operations
  - name: Custom Fields
    description: Custom field definition management
externalDocs:
  description: SalesCaptain API Documentation
  url: https://docs.salescaptain.com
paths:
  /v1/create-contact:
    post:
      tags:
        - Contacts
      summary: Create a new contact
      description: |
        Creates a new contact for a specific company.
        At least one of contact_phone or contact_email must be provided.
        User must have 'contacts' access role to create contacts.
      operationId: createContact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                company_id:
                  type: string
                  format: uuid
                  description: Unique identifier for the company
                  example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                contact_name:
                  type: string
                  description: Full name of the contact
                  example: John Doe
                contact_phone:
                  type: string
                  description: Phone number of the contact (required if no email provided)
                  example: '+14155551234'
                contact_email:
                  type: string
                  format: email
                  description: Email address of the contact (required if no phone provided)
                  example: john.doe@example.com
                custom_fields:
                  type: array
                  description: Optional list of custom fields to set for the contact
                  items:
                    $ref: '#/components/schemas/CustomFieldInput'
              required:
                - company_id
                - contact_name
            examples:
              with_both:
                summary: Contact with both phone and email
                value:
                  company_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  contact_name: John Doe
                  contact_phone: '+14155551234'
                  contact_email: john.doe@example.com
              with_phone_only:
                summary: Contact with phone only
                value:
                  company_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  contact_name: Jane Smith
                  contact_phone: '+14155559876'
              with_email_only:
                summary: Contact with email only
                value:
                  company_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  contact_name: Mike Johnson
                  contact_email: mike.johnson@example.com
              with_custom_fields:
                summary: Contact with custom fields
                value:
                  company_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  contact_name: John Doe
                  contact_phone: '+14155551234'
                  contact_email: john.doe@example.com
                  custom_fields:
                    - cf_id: d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a
                      cf_value: Technology
                    - cf_id: e5f6a7b8-c9d0-1e2f-3a4b-5c6d7e8f9a0b
                      cf_value: '50000'
      responses:
        '201':
          description: Contact created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Contact created successfully!
                  contact:
                    type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/ContactCreated'
              example:
                message: Contact created successfully!
                contact:
                  data:
                    contact_id: f47ac10b-58cc-4372-a567-0e02b2c3d479
                    name: John Doe
                    phone: '+14155551234'
                    email: john.doe@example.com
                    conversation_id: c8b7a6d5-e4f3-2c1b-0a9e-8d7c6b5a4f3e
                    created_at: '2024-03-13T10:30:00.000Z'
                    updated_at: '2024-03-13T10:30:00.000Z'
                    custom_fields:
                      - cf_name: Industry
                        cf_value: Technology
                      - cf_name: Budget
                        cf_value: '50000'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_company_id:
                  summary: Missing company_id
                  value:
                    status: failure
                    error: company_id is required
                missing_contact_info:
                  summary: Missing phone and email
                  value:
                    status: failure
                    error: >-
                      At least one of contact_phone or contact_email must be
                      provided
                invalid_custom_field:
                  summary: Invalid or inactive custom field for company
                  value:
                    status: failure
                    error: >-
                      Invalid or inactive custom field for this company:
                      d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          description: Access forbidden or permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: failure
                error: You don't have permission to create contact!
        '409':
          description: Conflict - Contact already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: failure
                error: Contact with this phone already exists!
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerAuth: []
components:
  schemas:
    CustomFieldInput:
      type: object
      description: Custom field input for create/update operations
      properties:
        cf_id:
          type: string
          format: uuid
          description: Unique identifier of the custom field
          example: d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a
        cf_value:
          type: string
          description: Value to set for the custom field
          example: Technology
      required:
        - cf_id
        - cf_value
    ContactCreated:
      type: object
      description: Created contact response object
      properties:
        contact_id:
          type: string
          format: uuid
          description: Unique identifier for the contact
          example: f47ac10b-58cc-4372-a567-0e02b2c3d479
        name:
          type: string
          description: Contact's full name
          example: John Doe
        phone:
          type: string
          nullable: true
          description: Contact's phone number
          example: '+14155551234'
        email:
          type: string
          format: email
          nullable: true
          description: Contact's email address
          example: john.doe@example.com
        conversation_id:
          type: string
          format: uuid
          description: Associated conversation identifier
          example: c8b7a6d5-e4f3-2c1b-0a9e-8d7c6b5a4f3e
        created_at:
          type: string
          format: date-time
          description: Timestamp when the contact was created
          example: '2024-03-13T10:30:00.000Z'
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the contact was last updated
          example: '2024-03-13T10:30:00.000Z'
        custom_fields:
          type: array
          description: List of custom fields for the contact
          items:
            $ref: '#/components/schemas/CustomField'
      required:
        - contact_id
        - name
        - conversation_id
        - created_at
    Error:
      type: object
      description: Error response object
      properties:
        error:
          type: string
          description: Error message
          example: Invalid request parameters
        code:
          type: string
          description: Error code for programmatic handling
          example: INVALID_PARAMS
        timestamp:
          type: string
          format: date-time
          description: Timestamp when the error occurred
          example: '2023-12-01T10:30:00Z'
        path:
          type: string
          description: API endpoint path where the error occurred
          example: /v1/fetch-companies
      required:
        - error
    CustomField:
      type: object
      description: Custom field key-value pair (response format)
      properties:
        cf_name:
          type: string
          description: Custom field name
          example: Industry
        cf_value:
          type: string
          description: Custom field value
          example: Technology
      required:
        - cf_name
        - cf_value
  responses:
    UnauthorizedError:
      description: Authentication token is missing or invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unauthorized access
            code: UNAUTHORIZED
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
    RateLimitError:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Too many requests, please try again later
            code: RATE_LIMIT_EXCEEDED
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
      headers:
        X-RateLimit-Limit:
          description: Request limit per time window
          schema:
            type: integer
            example: 30
        X-RateLimit-Remaining:
          description: Remaining requests in current window
          schema:
            type: integer
            example: 0
        X-RateLimit-Reset:
          description: Time when the rate limit resets
          schema:
            type: integer
            example: 1701425400
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Problem encountered while fetching companies!
            code: INTERNAL_ERROR
            timestamp: '2023-12-01T10:30:00Z'
            path: /v1/fetch-companies
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Authentication token required for accessing protected endpoints.

        The token should be obtained from the main SalesCaptain authentication
        service.

````