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

# Create a customer



## OpenAPI

````yaml post /v1/customers
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: >-
    Flextell REST API referansı. Kimlik doğrulama, scope ve istek kuralları için
    API sekmesindeki rehberlere bakın.
servers:
  - url: https://app.flextell.ai/api
    description: Üretim
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/customers:
    post:
      tags:
        - Customer
      summary: Create a customer
      operationId: customer.store
      parameters:
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerStoreRequest'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                  data:
                    $ref: '#/components/schemas/CustomerResource'
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
        '428':
          description: >-
            Mandatory setup is incomplete. Finish the setup wizard first;
            `data.next_step` names the step to continue with.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    examples:
                      - false
                  error_code:
                    type: string
                    enum:
                      - SETUP_REQUIRED
                    examples:
                      - SETUP_REQUIRED
                  message:
                    type: string
                    examples:
                      - Complete the required setup steps to continue.
                  data:
                    type: object
                    properties:
                      next_step:
                        type:
                          - string
                          - 'null'
                        examples:
                          - clinic_info
                    required:
                      - next_step
                required:
                  - success
                  - error_code
                  - message
                  - data
components:
  schemas:
    CustomerStoreRequest:
      type: object
      properties:
        first_name:
          type: string
          description: Customer's first name.
          maxLength: 255
        last_name:
          type: string
          description: Customer's last name.
          maxLength: 255
        phone_number:
          type: string
          description: Customer's phone number.
          maxLength: 20
        email:
          type:
            - string
            - 'null'
          format: email
          description: Customer's email address.
          maxLength: 255
        date_of_birth:
          type:
            - string
            - 'null'
          format: date-time
          description: Customer's date of birth.
        gender:
          type:
            - string
            - 'null'
          description: Customer's gender.
          enum:
            - male
            - female
            - other
            - null
        country_id:
          type:
            - integer
            - 'null'
          description: Customer's country identifier.
        city_id:
          type:
            - integer
            - 'null'
          description: >-
            Customer's city identifier. When country_id is provided, the city
            must belong to it.
        district_id:
          type:
            - integer
            - 'null'
          description: >-
            Customer's district identifier. When city_id is provided, the
            district must belong to it.
        identity_number:
          type:
            - string
            - 'null'
          description: Customer's identity number (11 digits, unique per tenant).
        passport_number:
          type:
            - string
            - 'null'
          description: >-
            Customer's passport number (6-12 uppercase letters and digits,
            unique per tenant).
          pattern: ^[A-Z0-9]+$
          minLength: 6
          maxLength: 12
        occupation_id:
          type:
            - integer
            - 'null'
          description: >-
            Customer's occupation identifier. The occupation must be active and
            available to the tenant.
        address:
          type:
            - string
            - 'null'
          description: Customer's address.
          maxLength: 1000
        default_channel_id:
          type:
            - integer
            - 'null'
          description: The customer's preferred default channel.
        user_id:
          type:
            - integer
            - 'null'
          description: Assigned user identifier.
        tags:
          type:
            - array
            - 'null'
          description: Tag identifiers to attach to the customer.
          items:
            type: integer
            description: A tag ID.
      required:
        - first_name
        - last_name
        - phone_number
      title: CustomerStoreRequest
    CustomerResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        first_name:
          anyOf:
            - type: string
            - type: 'null'
        last_name:
          anyOf:
            - type: string
            - type: 'null'
        phone_number:
          anyOf:
            - type: string
            - type: 'null'
        email:
          anyOf:
            - type: string
            - type: 'null'
        date_of_birth:
          type:
            - string
            - 'null'
        gender:
          anyOf:
            - $ref: '#/components/schemas/Gender'
            - type: 'null'
        country_id:
          type:
            - integer
            - 'null'
        country_name:
          type: string
        city_id:
          type:
            - integer
            - 'null'
        city_name:
          type: string
        district_id:
          type:
            - integer
            - 'null'
        district_name:
          type: string
        identity_number:
          anyOf:
            - type: string
            - type: 'null'
        passport_number:
          anyOf:
            - type: string
            - type: 'null'
        occupation_id:
          type:
            - integer
            - 'null'
        occupation_name:
          type: string
        address:
          anyOf:
            - type: string
            - type: 'null'
        default_channel_id:
          type:
            - integer
            - 'null'
        default_channel_name:
          type: string
        latest_conversation_id:
          type:
            - integer
            - 'null'
        avatar_url:
          type:
            - string
            - 'null'
        is_lead_stage:
          type: boolean
        lead_id:
          type:
            - integer
            - 'null'
        is_masked:
          type: boolean
          description: >-
            Whether the identity fields are masked because the viewer may not
            see this lead's patient.
        related_user:
          $ref: '#/components/schemas/RelatedUserResource'
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagResource'
        notification_channels:
          $ref: '#/components/schemas/CustomerNotificationChannelsResource'
        import_source:
          anyOf:
            - $ref: '#/components/schemas/RelatedImportSourceResource'
              description: >-
                The external system the record was imported from, or `null` when
                it was created in Flextell. Only present on detail responses.
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
        erased_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - record_state
        - first_name
        - last_name
        - phone_number
        - email
        - date_of_birth
        - gender
        - country_id
        - country_name
        - city_id
        - city_name
        - district_id
        - district_name
        - identity_number
        - passport_number
        - occupation_id
        - occupation_name
        - address
        - default_channel_id
        - default_channel_name
        - latest_conversation_id
        - avatar_url
        - is_lead_stage
        - lead_id
        - is_masked
        - related_user
        - created_at
        - updated_at
        - deleted_at
        - erased_at
      title: CustomerResource
    RecordStateResource:
      type: object
      properties:
        is_read_only:
          type: boolean
          description: >-
            True when every write on this record is refused; false does not
            imply the caller may write.
        reason_code:
          type:
            - string
            - 'null'
          description: >-
            Why the record is read-only (`CUSTOMER_ERASED`, or
            `LEAD_NOT_ASSIGNED` for a salesperson on another rep's lead), or
            null when it is not.
      required:
        - is_read_only
        - reason_code
      title: RecordStateResource
    Gender:
      type: string
      enum:
        - male
        - female
        - other
      title: Gender
    RelatedUserResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        avatar_url:
          type:
            - string
            - 'null'
          description: >-
            A signed profile photo URL valid for a few hours, or `null` without
            a photo. Only on responses that opt in.
      required:
        - id
        - name
      title: RelatedUserResource
    TagResource:
      type: object
      properties:
        id:
          type: integer
        tenant_id:
          type: integer
        name:
          type: string
        color:
          type: string
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - tenant_id
        - name
        - color
        - created_at
        - updated_at
        - deleted_at
      title: TagResource
    CustomerNotificationChannelsResource:
      type: object
      properties:
        default_channel_id:
          type:
            - string
            - 'null'
        source:
          type:
            - string
            - 'null'
        channels:
          type: array
          items: {}
      required:
        - default_channel_id
        - source
        - channels
      title: CustomerNotificationChannelsResource
    RelatedImportSourceResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        company_logo:
          type: 'null'
      required:
        - id
        - name
        - company_logo
      title: RelatedImportSourceResource
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://dev.flextell.ai/oauth/authorize
          tokenUrl: https://dev.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````

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