> ## 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.

# Complete a form on the patient's behalf

> Stores the answers of a pending form and completes it, recording the current user as the person who filled
it. Answers are validated against the template's questions (required, type and options of every visible
question) and errors are keyed `answers.{question_id}`. A form that is no longer pending answers 409
`CUSTOMER_FORM_ALREADY_COMPLETED`.



## OpenAPI

````yaml post /v1/customers/{customerId}/form/{customerFormId}/complete
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/{customerId}/form/{customerFormId}/complete:
    post:
      tags:
        - CustomerForm
      summary: Complete a form on the patient's behalf
      description: >-
        Stores the answers of a pending form and completes it, recording the
        current user as the person who filled

        it. Answers are validated against the template's questions (required,
        type and options of every visible

        question) and errors are keyed `answers.{question_id}`. A form that is
        no longer pending answers 409

        `CUSTOMER_FORM_ALREADY_COMPLETED`.
      operationId: customerForm.complete
      parameters:
        - name: customerId
          in: path
          required: true
          description: The customer identifier
          schema:
            type: integer
        - name: customerFormId
          in: path
          required: true
          description: The customer form identifier
          schema:
            type: integer
        - 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/CustomerFormCompleteRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                  data:
                    $ref: '#/components/schemas/CustomerFormResource'
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '409':
          $ref: '#/components/responses/CustomerErasedException'
        '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:
    CustomerFormCompleteRequest:
      type: object
      description: >-
        Staff answering a pending form for the patient. The answers are
        validated against the

        template's questions exactly like the patient's own form link.
      properties:
        answers:
          type: object
          description: >-
            Answers keyed by question id, e.g. `{"12": "Ayşe", "13": ["41",
            "42"], "14": true}`. Select and radio

            take one option id, checkbox a list of option ids, date a `Y-m-d`
            string and boolean `true`/`false`.

            Answers to questions hidden by their visibility rules are ignored.
          additionalProperties: {}
      required:
        - answers
      title: CustomerFormCompleteRequest
    CustomerFormResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        template_id:
          type: integer
        customer_id:
          type:
            - integer
            - 'null'
        status:
          $ref: '#/components/schemas/CustomerFormStatus'
        token:
          type: string
        is_ai_generated:
          type: boolean
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
        assigned_by_user_id:
          type:
            - integer
            - 'null'
        filled_by_user_id:
          type:
            - integer
            - 'null'
        template:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
        customer:
          type:
            - object
            - 'null'
          properties:
            id:
              type: integer
            first_name:
              type:
                - string
                - 'null'
            last_name:
              type:
                - string
                - 'null'
            full_name:
              type: string
          required:
            - id
            - first_name
            - last_name
            - full_name
        assigned_by_user:
          $ref: '#/components/schemas/RelatedUserResource'
        filled_by_user:
          $ref: '#/components/schemas/RelatedUserResource'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - record_state
        - template_id
        - customer_id
        - status
        - token
        - is_ai_generated
        - completed_at
        - assigned_by_user_id
        - filled_by_user_id
        - created_at
        - updated_at
      title: CustomerFormResource
    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
    CustomerFormStatus:
      type: string
      enum:
        - pending
        - completed
        - reviewed
      title: CustomerFormStatus
    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
  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
    CustomerErasedException:
      description: The patient record has been erased and is read-only
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                description: Always false for an error.
                examples:
                  - false
              error_code:
                type: string
                description: Machine-readable error code.
                examples:
                  - CUSTOMER_ERASED
              message:
                type: string
                description: Localized error message.
            required:
              - success
              - error_code
              - 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://app.flextell.ai/oauth/authorize
          tokenUrl: https://app.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.