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

> Record a patient's consent — for example to telehealth treatment, data sharing, or a privacy policy. Requires the consenting patient (`patient_id`), a `scope`, a `category`, and the `policy` consented to.



## OpenAPI

````yaml /openapi.json post /consents
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:
  /consents:
    post:
      tags:
        - Consents
      summary: Create consent
      description: >-
        Record a patient's consent — for example to telehealth treatment, data
        sharing, or a privacy policy. Requires the consenting patient
        (`patient_id`), a `scope`, a `category`, and the `policy` consented to.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  enum:
                    - draft
                    - proposed
                    - active
                    - rejected
                    - inactive
                    - entered-in-error
                scope:
                  type: object
                  properties:
                    system:
                      type: string
                      format: uri
                    code:
                      type: string
                      maxLength: 256
                    display:
                      type:
                        - string
                        - 'null'
                      maxLength: 500
                  required:
                    - code
                category:
                  type: array
                  items:
                    type: object
                    properties:
                      system:
                        type: string
                        format: uri
                      code:
                        type: string
                        maxLength: 256
                      display:
                        type:
                          - string
                          - 'null'
                        maxLength: 500
                    required:
                      - code
                  minItems: 1
                  maxItems: 20
                patient_id:
                  type: string
                  minLength: 1
                  maxLength: 64
                date_time:
                  type: string
                  pattern: >-
                    ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
                policy:
                  type: array
                  items:
                    type: object
                    properties:
                      authority:
                        type:
                          - string
                          - 'null'
                        maxLength: 500
                      uri:
                        type:
                          - string
                          - 'null'
                        maxLength: 2048
                  minItems: 1
                  maxItems: 20
                provision:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - deny
                        - permit
                    period:
                      type: object
                      properties:
                        start:
                          type: string
                          pattern: >-
                            ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$
                        end:
                          type: string
                          pattern: >-
                            ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$
                    actor:
                      type: array
                      items:
                        type: object
                        properties:
                          role:
                            type: array
                            items:
                              type: object
                              properties:
                                system:
                                  type: string
                                  format: uri
                                code:
                                  type: string
                                  maxLength: 256
                                display:
                                  type:
                                    - string
                                    - 'null'
                                  maxLength: 500
                              required:
                                - code
                            minItems: 1
                            maxItems: 20
                          reference:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 64
                              type:
                                type: string
                                enum:
                                  - Device
                                  - Group
                                  - CareTeam
                                  - Organization
                                  - Patient
                                  - Practitioner
                                  - RelatedPerson
                                  - PractitionerRole
                            required:
                              - id
                              - type
                        required:
                          - role
                          - reference
                      maxItems: 20
                    action:
                      type: array
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            system:
                              type: string
                              format: uri
                            code:
                              type: string
                              maxLength: 256
                            display:
                              type:
                                - string
                                - 'null'
                              maxLength: 500
                          required:
                            - code
                        minItems: 1
                        maxItems: 20
                      maxItems: 20
                    purpose:
                      type: array
                      items:
                        type: object
                        properties:
                          system:
                            type: string
                            format: uri
                          code:
                            type: string
                            maxLength: 256
                          display:
                            type:
                              - string
                              - 'null'
                            maxLength: 500
                        required:
                          - code
                      maxItems: 20
                    class:
                      type: array
                      items:
                        type: object
                        properties:
                          system:
                            type: string
                            format: uri
                          code:
                            type: string
                            maxLength: 256
                          display:
                            type:
                              - string
                              - 'null'
                            maxLength: 500
                        required:
                          - code
                      maxItems: 20
                    code:
                      type: array
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            system:
                              type: string
                              format: uri
                            code:
                              type: string
                              maxLength: 256
                            display:
                              type:
                                - string
                                - 'null'
                              maxLength: 500
                          required:
                            - code
                        minItems: 1
                        maxItems: 20
                      maxItems: 20
              required:
                - status
                - scope
                - category
                - patient_id
                - policy
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Consent'
                  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:
    Consent:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          enum:
            - draft
            - proposed
            - active
            - rejected
            - inactive
            - entered-in-error
        scope:
          type: array
          items:
            type: object
            properties:
              system:
                type: string
                format: uri
              code:
                type: string
                minLength: 1
              display:
                type: string
                maxLength: 500
            required:
              - code
        category:
          type: array
          items:
            type: array
            items:
              type: object
              properties:
                system:
                  type: string
                  format: uri
                code:
                  type: string
                  minLength: 1
                display:
                  type: string
                  maxLength: 500
              required:
                - code
        patient_id:
          type: string
        date_time:
          type: string
          pattern: >-
            ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
        policy:
          type: array
          items:
            type: object
            properties:
              authority:
                type: string
              uri:
                type: string
        provision:
          type: object
          properties:
            type:
              type: string
              enum:
                - deny
                - permit
            period:
              type: object
              properties:
                start:
                  type: string
                  pattern: >-
                    ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
                end:
                  type: string
                  pattern: >-
                    ^\d{4}(?:-\d{2}(?:-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?)?)?$
            actor:
              type: array
              items:
                type: object
                properties:
                  role:
                    type: array
                    items:
                      type: object
                      properties:
                        system:
                          type: string
                          format: uri
                        code:
                          type: string
                          minLength: 1
                        display:
                          type: string
                          maxLength: 500
                      required:
                        - code
                  reference:
                    type: object
                    properties:
                      id:
                        type: string
                        minLength: 1
                        maxLength: 64
                      type:
                        type: string
                        enum:
                          - Device
                          - Group
                          - CareTeam
                          - Organization
                          - Patient
                          - Practitioner
                          - RelatedPerson
                          - PractitionerRole
                    required:
                      - id
                      - type
                required:
                  - role
                  - reference
            action:
              type: array
              items:
                type: array
                items:
                  type: object
                  properties:
                    system:
                      type: string
                      format: uri
                    code:
                      type: string
                      minLength: 1
                    display:
                      type: string
                      maxLength: 500
                  required:
                    - code
            purpose:
              type: array
              items:
                type: object
                properties:
                  system:
                    type: string
                    format: uri
                  code:
                    type: string
                    minLength: 1
                  display:
                    type: string
                    maxLength: 500
                required:
                  - code
            class:
              type: array
              items:
                type: object
                properties:
                  system:
                    type: string
                    format: uri
                  code:
                    type: string
                    minLength: 1
                  display:
                    type: string
                    maxLength: 500
                required:
                  - code
            code:
              type: array
              items:
                type: array
                items:
                  type: object
                  properties:
                    system:
                      type: string
                      format: uri
                    code:
                      type: string
                      minLength: 1
                    display:
                      type: string
                      maxLength: 500
                  required:
                    - code
          required:
            - actor
            - action
            - purpose
            - class
            - code
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - status
        - scope
        - category
        - patient_id
        - policy
    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.