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

# Create questionnaire response

> Submit a patient's answers to a questionnaire; `answers` maps the questionnaire's item `link_id`s to typed values. `questionnaire_id` is required and identifies the Questionnaire the response belongs to (get it from `GET /questionnaires`); if you also send `questionnaire_canonical`, it must reference that same Questionnaire (`.../Questionnaire/<questionnaire_id>`, version suffix allowed) or the request is rejected with a 400. Submitting as `completed` with a patient subject marks the intake complete and can trigger automation configured for your program (survey observations, lab requisitions). Refill requests work the same way: a refill is simply another questionnaire type, and the patient's completed response is the refill application.



## OpenAPI

````yaml /openapi.json post /questionnaire-responses
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /questionnaire-responses:
    post:
      tags:
        - Questionnaire Responses
      summary: Create questionnaire response
      description: >-
        Submit a patient's answers to a questionnaire; `answers` maps the
        questionnaire's item `link_id`s to typed values. `questionnaire_id` is
        required and identifies the Questionnaire the response belongs to (get
        it from `GET /questionnaires`); if you also send
        `questionnaire_canonical`, it must reference that same Questionnaire
        (`.../Questionnaire/<questionnaire_id>`, version suffix allowed) or the
        request is rejected with a 400. Submitting as `completed` with a patient
        subject marks the intake complete and can trigger automation configured
        for your program (survey observations, lab requisitions). Refill
        requests work the same way: a refill is simply another questionnaire
        type, and the patient's completed response is the refill application.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                questionnaire_id:
                  type: string
                  maxLength: 64
                questionnaire_canonical:
                  type:
                    - string
                    - 'null'
                  maxLength: 2048
                status:
                  type: string
                  enum:
                    - in-progress
                    - completed
                    - amended
                    - entered-in-error
                    - stopped
                subject:
                  type: object
                  properties:
                    id:
                      type: string
                      minLength: 1
                      maxLength: 64
                    type:
                      type: string
                      enum:
                        - Patient
                        - Practitioner
                        - PractitionerRole
                        - RelatedPerson
                        - Device
                        - Organization
                        - CarePlan
                        - ServiceRequest
                        - Observation
                        - Procedure
                  required:
                    - id
                    - type
                encounter_id:
                  type:
                    - string
                    - 'null'
                  maxLength: 64
                authored_at:
                  type: string
                  format: date-time
                author:
                  type: object
                  properties:
                    id:
                      type: string
                      minLength: 1
                      maxLength: 64
                    type:
                      type: string
                      enum:
                        - Patient
                        - Practitioner
                        - PractitionerRole
                        - RelatedPerson
                        - Device
                        - Organization
                        - CarePlan
                        - ServiceRequest
                        - Observation
                        - Procedure
                  required:
                    - id
                    - type
                source:
                  type: object
                  properties:
                    id:
                      type: string
                      minLength: 1
                      maxLength: 64
                    type:
                      type: string
                      enum:
                        - Patient
                        - Practitioner
                        - PractitionerRole
                        - RelatedPerson
                        - Device
                        - Organization
                        - CarePlan
                        - ServiceRequest
                        - Observation
                        - Procedure
                  required:
                    - id
                    - type
                answers:
                  type: object
                  additionalProperties:
                    anyOf:
                      - type: object
                        properties:
                          value_boolean:
                            type: boolean
                        required:
                          - value_boolean
                        additionalProperties: false
                      - type: object
                        properties:
                          value_decimal:
                            type: number
                        required:
                          - value_decimal
                        additionalProperties: false
                      - type: object
                        properties:
                          value_integer:
                            type: integer
                        required:
                          - value_integer
                        additionalProperties: false
                      - type: object
                        properties:
                          value_date:
                            type: string
                            pattern: ^\d{4}-\d{2}-\d{2}$
                        required:
                          - value_date
                        additionalProperties: false
                      - type: object
                        properties:
                          value_date_time:
                            type: string
                            format: date-time
                        required:
                          - value_date_time
                        additionalProperties: false
                      - type: object
                        properties:
                          value_time:
                            type: string
                            pattern: >-
                              ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9](\.\d+)?)?$
                        required:
                          - value_time
                        additionalProperties: false
                      - type: object
                        properties:
                          value_string:
                            type: string
                            maxLength: 10000
                        required:
                          - value_string
                        additionalProperties: false
                      - type: object
                        properties:
                          value_uri:
                            type: string
                            maxLength: 2048
                            format: uri
                        required:
                          - value_uri
                        additionalProperties: false
                      - type: object
                        properties:
                          value_coding:
                            type: object
                            properties:
                              system:
                                type: string
                                format: uri
                              code:
                                type: string
                                minLength: 1
                              display:
                                type: string
                                maxLength: 500
                            required:
                              - code
                        required:
                          - value_coding
                        additionalProperties: false
                      - type: object
                        properties:
                          value_reference:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                enum:
                                  - Patient
                                  - Practitioner
                                  - PractitionerRole
                                  - RelatedPerson
                                  - Device
                                  - Organization
                                  - CarePlan
                                  - ServiceRequest
                                  - Observation
                                  - Procedure
                            required:
                              - id
                              - type
                        required:
                          - value_reference
                        additionalProperties: false
                      - type: object
                        properties:
                          value_quantity:
                            type: object
                            properties:
                              value:
                                type: number
                              unit:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 64
                              system:
                                type: string
                                format: uri
                              code:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 64
                            required:
                              - value
                        required:
                          - value_quantity
                        additionalProperties: false
                      - type: array
                        items:
                          anyOf:
                            - type: object
                              properties:
                                value_boolean:
                                  type: boolean
                              required:
                                - value_boolean
                              additionalProperties: false
                            - type: object
                              properties:
                                value_decimal:
                                  type: number
                              required:
                                - value_decimal
                              additionalProperties: false
                            - type: object
                              properties:
                                value_integer:
                                  type: integer
                              required:
                                - value_integer
                              additionalProperties: false
                            - type: object
                              properties:
                                value_date:
                                  type: string
                                  pattern: ^\d{4}-\d{2}-\d{2}$
                              required:
                                - value_date
                              additionalProperties: false
                            - type: object
                              properties:
                                value_date_time:
                                  type: string
                                  format: date-time
                              required:
                                - value_date_time
                              additionalProperties: false
                            - type: object
                              properties:
                                value_time:
                                  type: string
                                  pattern: >-
                                    ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9](\.\d+)?)?$
                              required:
                                - value_time
                              additionalProperties: false
                            - type: object
                              properties:
                                value_string:
                                  type: string
                                  maxLength: 10000
                              required:
                                - value_string
                              additionalProperties: false
                            - type: object
                              properties:
                                value_uri:
                                  type: string
                                  maxLength: 2048
                                  format: uri
                              required:
                                - value_uri
                              additionalProperties: false
                            - type: object
                              properties:
                                value_coding:
                                  type: object
                                  properties:
                                    system:
                                      type: string
                                      format: uri
                                    code:
                                      type: string
                                      minLength: 1
                                    display:
                                      type: string
                                      maxLength: 500
                                  required:
                                    - code
                              required:
                                - value_coding
                              additionalProperties: false
                            - type: object
                              properties:
                                value_reference:
                                  type: object
                                  properties:
                                    id:
                                      type: string
                                      minLength: 1
                                      maxLength: 64
                                    type:
                                      type: string
                                      enum:
                                        - Patient
                                        - Practitioner
                                        - PractitionerRole
                                        - RelatedPerson
                                        - Device
                                        - Organization
                                        - CarePlan
                                        - ServiceRequest
                                        - Observation
                                        - Procedure
                                  required:
                                    - id
                                    - type
                              required:
                                - value_reference
                              additionalProperties: false
                            - type: object
                              properties:
                                value_quantity:
                                  type: object
                                  properties:
                                    value:
                                      type: number
                                    unit:
                                      type:
                                        - string
                                        - 'null'
                                      maxLength: 64
                                    system:
                                      type: string
                                      format: uri
                                    code:
                                      type:
                                        - string
                                        - 'null'
                                      maxLength: 64
                                  required:
                                    - value
                              required:
                                - value_quantity
                              additionalProperties: false
                        maxItems: 100
              required:
                - questionnaire_id
                - status
                - answers
              additionalProperties: false
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/QuestionnaireResponse'
                  request_id:
                    type: string
                required:
                  - data
                  - request_id
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - serviceToken: []
        - userToken: []
components:
  schemas:
    QuestionnaireResponse:
      type: object
      properties:
        id:
          type: string
          maxLength: 64
          pattern: ^[A-Za-z0-9\-.]{1,64}$
        questionnaire_id:
          type: string
          maxLength: 64
        questionnaire_canonical:
          type: string
          maxLength: 2048
        status:
          type: string
          enum:
            - in-progress
            - completed
            - amended
            - entered-in-error
            - stopped
        subject:
          type: object
          properties:
            id:
              type: string
              maxLength: 64
              pattern: ^[A-Za-z0-9\-.]{1,64}$
            type:
              type: string
              minLength: 1
              maxLength: 64
              pattern: ^[A-Z][A-Za-z]+$
          required:
            - id
            - type
        encounter_id:
          type: string
          maxLength: 64
        authored_at:
          type: string
          pattern: >-
            ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
        author:
          type: object
          properties:
            id:
              type: string
              maxLength: 64
              pattern: ^[A-Za-z0-9\-.]{1,64}$
            type:
              type: string
              minLength: 1
              maxLength: 64
              pattern: ^[A-Z][A-Za-z]+$
          required:
            - id
            - type
        source:
          type: object
          properties:
            id:
              type: string
              maxLength: 64
              pattern: ^[A-Za-z0-9\-.]{1,64}$
            type:
              type: string
              minLength: 1
              maxLength: 64
              pattern: ^[A-Z][A-Za-z]+$
          required:
            - id
            - type
        answers:
          type: object
          additionalProperties:
            anyOf:
              - type: object
                properties:
                  value_boolean:
                    type: boolean
                required:
                  - value_boolean
              - type: object
                properties:
                  value_decimal:
                    type: number
                required:
                  - value_decimal
              - type: object
                properties:
                  value_integer:
                    type: integer
                required:
                  - value_integer
              - type: object
                properties:
                  value_date:
                    type: string
                    pattern: ^\d{4}-\d{2}-\d{2}$
                required:
                  - value_date
              - type: object
                properties:
                  value_date_time:
                    type: string
                    pattern: >-
                      ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
                required:
                  - value_date_time
              - type: object
                properties:
                  value_time:
                    type: string
                    pattern: ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9](\.\d+)?)?$
                required:
                  - value_time
              - type: object
                properties:
                  value_string:
                    type: string
                    maxLength: 10000
                required:
                  - value_string
              - type: object
                properties:
                  value_uri:
                    type: string
                    maxLength: 2048
                    format: uri
                required:
                  - value_uri
              - type: object
                properties:
                  value_coding:
                    type: object
                    properties:
                      system:
                        type: string
                        format: uri
                      code:
                        type: string
                        minLength: 1
                      display:
                        type: string
                        maxLength: 500
                    required:
                      - code
                required:
                  - value_coding
              - type: object
                properties:
                  value_reference:
                    type: object
                    properties:
                      id:
                        type: string
                        maxLength: 64
                        pattern: ^[A-Za-z0-9\-.]{1,64}$
                      type:
                        type: string
                        minLength: 1
                        maxLength: 64
                        pattern: ^[A-Z][A-Za-z]+$
                    required:
                      - id
                      - type
                required:
                  - value_reference
              - type: object
                properties:
                  value_quantity:
                    type: object
                    properties:
                      value:
                        type: number
                      unit:
                        type: string
                        maxLength: 64
                      system:
                        type: string
                        format: uri
                      code:
                        type: string
                        maxLength: 64
                    required:
                      - value
                required:
                  - value_quantity
              - type: array
                items:
                  anyOf:
                    - type: object
                      properties:
                        value_boolean:
                          type: boolean
                      required:
                        - value_boolean
                    - type: object
                      properties:
                        value_decimal:
                          type: number
                      required:
                        - value_decimal
                    - type: object
                      properties:
                        value_integer:
                          type: integer
                      required:
                        - value_integer
                    - type: object
                      properties:
                        value_date:
                          type: string
                          pattern: ^\d{4}-\d{2}-\d{2}$
                      required:
                        - value_date
                    - type: object
                      properties:
                        value_date_time:
                          type: string
                          pattern: >-
                            ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
                      required:
                        - value_date_time
                    - type: object
                      properties:
                        value_time:
                          type: string
                          pattern: >-
                            ^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9](\.\d+)?)?$
                      required:
                        - value_time
                    - type: object
                      properties:
                        value_string:
                          type: string
                          maxLength: 10000
                      required:
                        - value_string
                    - type: object
                      properties:
                        value_uri:
                          type: string
                          maxLength: 2048
                          format: uri
                      required:
                        - value_uri
                    - type: object
                      properties:
                        value_coding:
                          type: object
                          properties:
                            system:
                              type: string
                              format: uri
                            code:
                              type: string
                              minLength: 1
                            display:
                              type: string
                              maxLength: 500
                          required:
                            - code
                      required:
                        - value_coding
                    - type: object
                      properties:
                        value_reference:
                          type: object
                          properties:
                            id:
                              type: string
                              maxLength: 64
                              pattern: ^[A-Za-z0-9\-.]{1,64}$
                            type:
                              type: string
                              minLength: 1
                              maxLength: 64
                              pattern: ^[A-Z][A-Za-z]+$
                          required:
                            - id
                            - type
                      required:
                        - value_reference
                    - type: object
                      properties:
                        value_quantity:
                          type: object
                          properties:
                            value:
                              type: number
                            unit:
                              type: string
                              maxLength: 64
                            system:
                              type: string
                              format: uri
                            code:
                              type: string
                              maxLength: 64
                          required:
                            - value
                      required:
                        - value_quantity
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - status
        - answers
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            error_code:
              type: string
          required:
            - message
            - error_code
        request_id:
          type: string
      required:
        - error
        - request_id
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

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