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

# E-prescribe a pending prescription to a pharmacy

> Sends one PENDING prescription to one pharmacy over Surescripts. **Sending is the prescriber's signature in the EHR and cannot be recalled through Max AI.** It is released under the sending user's own EHR login, resolved from `sessionToken`; with none usable the answer is `409 no_sending_identity` — call `maxcare.pickProvider()` and retry with the same key. Every pre-send check refuses without sending and frees the key. `200` carries `submitted` or `refused`. `202` means `unknown`: the send was issued and no answer arrived, so it MAY have reached the pharmacy — never send again; repeat this request with the same `idempotencyKey` to learn the outcome. Controlled substances are always refused.



## OpenAPI

````yaml /openapi-v4.json post /prescriptions/{id}/send
openapi: 3.0.0
info:
  title: Max AI Public API
  description: API for third-party marketplace apps
  version: '4.0'
  contact: {}
servers:
  - url: https://api.maxcare.ai/v4
security: []
tags: []
paths:
  /prescriptions/{id}/send:
    post:
      tags:
        - Prescriptions
      summary: E-prescribe a pending prescription to a pharmacy
      description: >-
        Sends one PENDING prescription to one pharmacy over Surescripts.
        **Sending is the prescriber's signature in the EHR and cannot be
        recalled through Max AI.** It is released under the sending user's own
        EHR login, resolved from `sessionToken`; with none usable the answer is
        `409 no_sending_identity` — call `maxcare.pickProvider()` and retry with
        the same key. Every pre-send check refuses without sending and frees the
        key. `200` carries `submitted` or `refused`. `202` means `unknown`: the
        send was issued and no answer arrived, so it MAY have reached the
        pharmacy — never send again; repeat this request with the same
        `idempotencyKey` to learn the outcome. Controlled substances are always
        refused.
      operationId: PrescriptionsPublicController_sendPrescription
      parameters:
        - name: id
          required: true
          in: path
          description: Prescription ID (`rxp_…`)
          schema:
            type: string
        - name: X-Organization-Id
          in: header
          required: true
          schema:
            type: string
          description: Target clinic organization ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendPrescriptionBody'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendPrescriptionSuccessResponse'
        '202':
          description: Accepted — queued for background processing
        '400':
          description: Missing or invalid request parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadRequestResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiUnauthorizedResponse'
        '403':
          description: Insufficient scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiForbiddenResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiNotFoundResponse'
        '409':
          description: Resource conflict (e.g. editing a signed note)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiConflictResponse'
        '422':
          description: Request refused by the EHR's state (named `code`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiUnprocessableResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
        '502':
          description: EHR sync failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadGatewayResponse'
        '503':
          description: EHR integration unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiServiceUnavailableResponse'
      security:
        - api-key: []
components:
  schemas:
    SendPrescriptionBody:
      type: object
      properties:
        pharmacyNcpdpId:
          type: string
          description: Target pharmacy NCPDP id (7 digits)
          example: '0000001'
        idempotencyKey:
          type: string
          description: >-
            Required, scoped to (app, organization), never expires. The same key
            and the same (prescription, pharmacy) returns the original send
            record and never sends again — also without a valid `sessionToken`,
            so a lost outcome can be learned after the token expired. A
            different prescription or pharmacy under a used key is `409
            idempotency_key_reused`.
          example: rxsend-rxp_5f1c0000000040000000000000000001-1
        sessionToken:
          type: string
          description: >-
            The App Bridge app token of the user who pressed Send, forwarded in
            the same request as the click. Required to create a send record.
        linkPharmacyToPatient:
          type: boolean
          description: >-
            Must be `true` in v1: the pharmacy is linked to the patient (never
            as default) before sending
          example: true
        acknowledgeActiveErx:
          type: boolean
          description: >-
            Send even though the same drug was released to another pharmacy
            within 90 days (recorded on the send)
          example: false
          default: false
      required:
        - pharmacyNcpdpId
        - idempotencyKey
        - linkPharmacyToPatient
    SendPrescriptionSuccessResponse:
      type: object
      properties:
        code:
          type: string
          description: Response code
          example: success
        data:
          $ref: '#/components/schemas/ExternalPrescriptionSendResponse'
      required:
        - code
        - data
    PublicApiBadRequestResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: bad_request
        message:
          type: string
          description: Human-readable error message
          example: '''id'' must be a valid UUID'
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiUnauthorizedResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unauthorized
        message:
          type: string
          description: Human-readable error message
          example: Invalid or missing API key
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiForbiddenResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: forbidden
        message:
          type: string
          description: Human-readable error message
          example: Insufficient scope
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiNotFoundResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: not_found
        message:
          type: string
          description: Human-readable error message
          example: Resource not found
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiConflictResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: conflict
        message:
          type: string
          description: Human-readable error message
          example: Cannot edit a signed note
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiUnprocessableResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: controlled_substance_unsupported
        message:
          type: string
          description: Human-readable error message
          example: Controlled substances cannot be prescribed through the API
        data:
          type: object
          description: Condition-specific detail, when the code defines any
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiRateLimitResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: rate_limit_exceeded
        message:
          type: string
          description: Human-readable error message
          example: Rate limit exceeded. Maximum 1000 requests per 60 seconds.
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiBadGatewayResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unexpected_integration_error
        message:
          type: string
          description: Human-readable error message
          example: EHR sync failed
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiServiceUnavailableResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: server_unresponsive
        message:
          type: string
          description: Human-readable error message
          example: EHR integration is not available for this note
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    ExternalPrescriptionSendResponse:
      type: object
      properties:
        id:
          type: string
          example: rxs_77aa000000004000a000000000000001
        prescriptionId:
          type: string
          example: rxp_5f1c0000000040000000000000000001
        pharmacyNcpdpId:
          type: string
          example: '0000001'
        status:
          type: string
          enum:
            - submitted
            - refused
            - unknown
            - not_sent
          description: >-
            `submitted`: the EHR acknowledged the send. `refused`: the EHR
            answered with errors; nothing was sent. `unknown`: the send was
            issued and no answer arrived — it MAY have reached the pharmacy;
            never resend, repeat the request with the same key to learn the
            outcome. `not_sent`: this request did not send it. With
            `statusDetail` `not_released` you may send again, with a NEW key;
            with `released_elsewhere` the prescription was released anyway, so
            do not create another draft.
          example: submitted
        statusDetail:
          type: string
          nullable: true
          description: Fixed platform text
          example: null
        authorizedBy:
          $ref: '#/components/schemas/PrescriptionSendAuthorizerResponse'
        acknowledgedActiveErx:
          type: boolean
          example: false
        requestedAt:
          type: string
          example: '2026-09-30T14:00:00.000Z'
        erx:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/PrescriptionSendErxResponse'
      required:
        - id
        - prescriptionId
        - pharmacyNcpdpId
        - status
        - statusDetail
        - authorizedBy
        - acknowledgedActiveErx
        - requestedAt
        - erx
    PrescriptionSendAuthorizerResponse:
      type: object
      properties:
        userId:
          type: string
          description: Max AI user who pressed Send
          example: usr_0a1b2c3d4e5f40718293a4b5c6d7e8f9
        clerkUserId:
          type: string
          example: user_2abcDEFghiJKLmno
        orgRole:
          type: string
          nullable: true
          example: org:member
      required:
        - userId
        - clerkUserId
        - orgRole
    PrescriptionSendErxResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - initiated
            - sent
            - pharmacy_verified
            - error
            - unrecognized
          example: initiated
        messageId:
          type: string
          nullable: true
          example: EMA00000000000000000000000000000000
        releasedAt:
          type: string
          nullable: true
          example: '2026-09-30T14:00:02.000Z'
        releasedBy:
          type: object
          nullable: true
          example:
            ehrStaffId: '333'
            name: Sam Staff
        pharmacy:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/PrescriptionPharmacyRefResponse'
      required:
        - status
        - messageId
        - releasedAt
        - releasedBy
        - pharmacy
    PrescriptionPharmacyRefResponse:
      type: object
      properties:
        ncpdpId:
          type: string
          nullable: true
          example: '0000001'
        name:
          type: string
          nullable: true
          example: Example Clinic Pharmacy
      required:
        - ncpdpId
        - name
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Marketplace API key

````

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