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

# Generate ICD codes

> Draws ICD-11 diagnosis codes from the visit's note. Answers 202 with a job; poll GET /jobs/{id}. The codes also appear on GET /visits/{id}. Scope `visits:write`.



## OpenAPI

````yaml /api-reference/openapi.json post /visits/{id}/icd-codes
openapi: 3.1.0
info:
  title: RxNote API
  version: 1.0.0
  description: >-
    The RxNote app's patient → visit → note flow for your own software: create a
    patient, create a visit with a recording or a transcript, and get back the
    transcript and a structured clinical note.
servers:
  - url: https://rxnote.ai/api/v1
    description: Production
  - url: https://dev.rxnote.ai/api/v1
    description: Sandbox (test keys)
  - url: http://localhost:3000/api/v1
    description: Local development
security: []
paths:
  /visits/{id}/icd-codes:
    post:
      tags:
        - Notes
      summary: Generate ICD codes
      description: >-
        Draws ICD-11 diagnosis codes from the visit's note. Answers 202 with a
        job; poll GET /jobs/{id}. The codes also appear on GET /visits/{id}.
        Scope `visits:write`.
      operationId: createIcdCodes
      parameters:
        - schema:
            type: integer
            exclusiveMinimum: 0
            example: 90211
          required: true
          name: id
          in: path
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: >-
              Your unique id for this request. Retrying with the same key
              returns the same job.
            example: letter-appt-0001
          required: true
          name: Idempotency-Key
          in: header
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateIcdCodesRequest'
      responses:
        '200':
          description: The job already created with this Idempotency-Key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Job'
        '202':
          description: The job, queued.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Job'
        '401':
          description: Missing, invalid, revoked or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The key lacks the scope, or the API is not enabled for the account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No such visit for this key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            The visit has no note yet, or the Idempotency-Key was used with a
            different body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate or concurrency limit reached; see `Retry-After`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
components:
  schemas:
    CreateIcdCodesRequest:
      type: object
      properties:
        clinician_email:
          type: string
          maxLength: 255
          format: email
          description: >-
            Required with an organization key: the RxNote member acting. With a
            personal key, omit it or send the owner's own email.
          example: doctor@clinic.example
    Job:
      type: object
      properties:
        id:
          type: string
          example: job_4Rt8Vb1Np3Zs7Hc2kQ9xLm
        kind:
          type: string
          enum:
            - note
            - icd_codes
        visit_id:
          type: integer
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - failed
        created_at:
          type: string
          format: date-time
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
        note:
          $ref: '#/components/schemas/AdditionalNote'
        icd_codes:
          allOf:
            - $ref: '#/components/schemas/IcdCodes'
            - description: For an `icd_codes` job, once completed.
        error:
          type:
            - object
            - 'null'
          properties:
            code:
              type: string
              enum:
                - NOTE_FAILED
                - ICD_FAILED
                - NOTHING_TO_WRITE_FROM
                - TIMED_OUT
            message:
              type: string
          required:
            - code
            - message
      required:
        - id
        - kind
        - visit_id
        - status
        - created_at
        - completed_at
        - error
      description: >-
        Work that runs after the request answers. Poll GET /jobs/{id} until
        completed or failed.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: VALIDATION_FAILED
            message:
              type: string
            request_id:
              type: string
              example: req_Q2w9Lx7Hc4Vb8Np1Zs3Kt6
          required:
            - code
            - message
            - request_id
      required:
        - error
    AdditionalNote:
      type:
        - object
        - 'null'
      properties:
        id:
          type: integer
          example: 5521
        visit_id:
          type: integer
        template:
          type:
            - object
            - 'null'
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
        framework:
          type: string
        sections:
          type: array
          items:
            $ref: '#/components/schemas/NoteSection'
        html:
          type: string
        created_at:
          type: string
          format: date-time
      required:
        - id
        - visit_id
        - template
        - framework
        - sections
        - html
        - created_at
      description: For a `note` job, once completed.
    IcdCodes:
      type:
        - object
        - 'null'
      properties:
        code_version:
          type:
            - string
            - 'null'
          example: icd11
        generated_at:
          type:
            - string
            - 'null'
        codes:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                example: CA02
              name:
                type: string
                example: Acute pharyngitis
              confidence:
                type:
                  - string
                  - 'null'
                enum:
                  - high
                  - medium
                  - low
            required:
              - code
              - name
              - confidence
      required:
        - code_version
        - generated_at
        - codes
      description: Set once POST /visits/{id}/icd-codes has run.
    NoteSection:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        fields:
          type: array
          items:
            $ref: '#/components/schemas/NoteField'
      required:
        - id
        - title
        - fields
    NoteField:
      type: object
      properties:
        id:
          type: string
        label:
          type: string
        text:
          type: string
      required:
        - id
        - label
        - text
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        Your API key, created in RxNote under Settings → API: `Authorization:
        Bearer rxn_live_…`.

````

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