> ## Documentation Index
> Fetch the complete documentation index at: https://developers.vibrant-wellness.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Order

> Submits a lab order for an existing patient using the same product `code`s you quoted. You send `patientId` and `testCodes` — plus `orderingProviderId`, unless your account's default ordering provider should be used; the lab prices the order (BestDeal), applies New York routing, runs the eligibility check, and — only when eligible — places it. You do NOT send demographics, prices, kit settings, or internal ids; `customerId`/`clinic_id` come from your token.

`placerId` is optional: omit it and every request creates a new order; send one and it becomes your idempotency key — resending the same value returns the original result and never charges twice.

All requested codes are ordered or none is: if any code cannot be fulfilled the whole order is rejected with `no_orderable_items`, naming it in `errorCodes`.

**WIP — coming soon:** `chargeIndicator: "T"` adds third-party platform payment. Send `platformId` and `X-Payment-Authorization: Bearer <platform-signed JWT>` in addition to the provider access token. The platform JWT uses RS256, a short expiration, and a new single-use `jti` per request. No platform token exchange is involved. Missing or invalid payment authorization, no stored card, or a failed charge prevents the order from being placed. Confirm environment availability with Vibrant before testing. See [Third-party payment](/guides/third-party-payment).

Submit a lab order for an existing patient using the **same product `code`s you quoted**. You send
`patientId` and `testCodes` — plus `orderingProviderId` unless your account's **default ordering
provider** should be used (the response echoes the provider applied); the lab prices the order (BestDeal), applies
New York routing, runs the eligibility check, and places it — only when eligible.

## Third-party payment

> [!NOTE]
>
> **WIP — coming soon.** `chargeIndicator: "T"` lets a third-party platform pay with its stored
> card. The contract may change; confirm environment availability with Vibrant before testing.

For `T`, send both `platformId` in the body and `X-Payment-Authorization: Bearer <platform-signed JWT>`
in the headers. Keep the provider's access token in `Authorization`. The platform JWT uses RS256
and must be newly signed for each request. A missing card or failed charge prevents the order
from being placed.

See [Third-party payment](https://developers.vibrant-wellness.com/guides/third-party-payment.md) for onboarding and a complete request.
Existing `C`, `P`, `I`, and `O` flows are unchanged and do not require these additional credentials.

## All codes are ordered, or none is

If any `code` cannot be fulfilled — an add-on sent without its host test, for example — the whole
order is rejected with `422` `no_orderable_items`, naming it in `errorCodes`. An order never
partially succeeds.

## Which provider the order is attributed to

| `orderingProviderId` | Result |
| :- | :- |
| Omitted (or empty) | Your account's **default ordering provider** is used |
| Sent | Overrides the default — must belong to your account, otherwise `422` `provider_scope_mismatch` |
| Omitted, no default configured | Rejected |

The response echoes the provider the order was actually placed under.

`placerId` is your **optional idempotency key**: omit it and every request creates a new order;
send one and resending the same value returns the original result and never charges twice.
See [Orders](https://developers.vibrant-wellness.com/concepts/orders.md).


## OpenAPI

````yaml POST /orders
openapi: 3.1.0
info:
  title: Vibrant Wellness Portal API
  version: 2026-07-01-draft
  description: >-
    Order lab tests and retrieve results programmatically. Authenticate once
    with OAuth2 client credentials, browse the catalog, quote and
    eligibility-check an order, create patients, place orders, and pull results
    with their report status and issues.


    This reference documents the target external contract (v1).
  contact:
    name: Vibrant Wellness Developer Support
    email: portal-api@vibrant-wellness.com
    url: https://developers.vibrant-wellness.com
  license:
    name: Proprietary
servers:
  - url: https://api.vibrant-america.com/v1
    description: Production
  - url: https://api-sandbox.vibrant-america.com/v1
    description: Staging (sandbox)
security:
  - oauth2: []
tags:
  - name: Catalog
    description: Browse orderable tests and panels.
  - name: Pricing
    description: Get an authoritative price and eligibility check before ordering.
  - name: Patients
    description: Create patients.
  - name: Orders
    description: Place lab orders.
  - name: Reports
    description: Retrieve results, report status, and issues.
paths:
  /orders:
    post:
      tags:
        - Orders
      summary: Place an order
      description: >-
        Submits a lab order for an existing patient using the same product
        `code`s you quoted. You send `patientId` and `testCodes` — plus
        `orderingProviderId`, unless your account's default ordering provider
        should be used; the lab prices the order (BestDeal), applies New York
        routing, runs the eligibility check, and — only when eligible — places
        it. You do NOT send demographics, prices, kit settings, or internal ids;
        `customerId`/`clinic_id` come from your token.


        `placerId` is optional: omit it and every request creates a new order;
        send one and it becomes your idempotency key — resending the same value
        returns the original result and never charges twice.


        All requested codes are ordered or none is: if any code cannot be
        fulfilled the whole order is rejected with `no_orderable_items`, naming
        it in `errorCodes`.


        **WIP — coming soon:** `chargeIndicator: "T"` adds third-party platform
        payment. Send `platformId` and `X-Payment-Authorization: Bearer
        <platform-signed JWT>` in addition to the provider access token. The
        platform JWT uses RS256, a short expiration, and a new single-use `jti`
        per request. No platform token exchange is involved. Missing or invalid
        payment authorization, no stored card, or a failed charge prevents the
        order from being placed. Confirm environment availability with Vibrant
        before testing. See [Third-party payment](/guides/third-party-payment).
      operationId: placeOrder
      parameters:
        - name: X-Payment-Authorization
          in: header
          required: false
          description: >-
            WIP — coming soon. Required only when `chargeIndicator` is `T`. Send
            `Bearer <platform-signed JWT>`: a fresh RS256 JWT signed with the
            private key registered for the body's `platformId`. Use matching
            `iss` and `sub`, the agreed API `aud`, an `exp` about 60 seconds
            ahead, and a unique single-use `jti`. Keep the provider access token
            in `Authorization`; this header is additional payment authorization,
            with no platform token exchange. See [Third-party
            payment](/guides/third-party-payment#create-the-payment-jwt).
          schema:
            type: string
          example: Bearer <platform-signed-jwt>
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderRequest'
            example:
              placerId: VENDOR-ORDER-12345
              emrName: ACME-EHR
              patientId: 123456
              orderingProviderId: '1234567890'
              chargeIndicator: C
              testCodes:
                - GUT_ZOOMER
                - VITD_25OH
      responses:
        '201':
          description: Order placed, or a duplicate of a prior placerId.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderResult'
              examples:
                placed:
                  summary: Placed
                  value:
                    status: placed
                    orderId: d53f297b-9e2e-45f5-8f00-1b42df2dbde6
                    sampleId: 2553966
                    accessionId: 2607216002
                    orderingProviderId: '1234567890'
                duplicate:
                  summary: Duplicate (resent placerId)
                  value:
                    status: duplicate
                    sampleId: 2553966
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          description: Understood but not placed — nothing was charged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderProblem'
              examples:
                ineligible:
                  summary: Ineligible
                  value:
                    status: ineligible
                    failures:
                      - code: IncompletePatientInfo
                        reason: >-
                          patient 123456 is missing required information:
                          address
                      - code: PFSAMaleOnly
                        reason: PFSA can only be ordered for male patients
                rejected:
                  summary: Rejected (unknown code)
                  value:
                    status: rejected
                    reason: unrecognized_test_codes
                    errorCodes:
                      - VACPBOGUS
                provider_scope_mismatch:
                  summary: Provider not in your account
                  value:
                    status: rejected
                    reason: provider_scope_mismatch
                no_orderable_items:
                  summary: A code could not be fulfilled
                  value:
                    status: rejected
                    reason: no_orderable_items
                    errorCodes:
                      - APOE_SALIVA
        '500':
          $ref: '#/components/responses/InternalError'
      x-codeSamples:
        - lang: bash
          label: Customer pays (C)
          source: |-
            curl -X POST https://api.vibrant-america.com/v1/orders \
              -H "Authorization: Bearer $PROVIDER_ACCESS_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "placerId": "VENDOR-ORDER-12345",
              "emrName": "ACME-EHR",
              "patientId": 123456,
              "orderingProviderId": "1234567890",
              "chargeIndicator": "C",
              "testCodes": [
                "GUT_ZOOMER",
                "VITD_25OH"
              ]
            }'
        - lang: bash
          label: Platform pays (T) — WIP
          source: |-
            curl -X POST https://api.vibrant-america.com/v1/orders \
              -H "Authorization: Bearer $PROVIDER_ACCESS_TOKEN" \
              -H "X-Payment-Authorization: Bearer $PLATFORM_PAYMENT_JWT" \
              -H "Content-Type: application/json" \
              -d '{
              "placerId": "PLATFORM-ORDER-12345",
              "patientId": 123456,
              "orderingProviderId": "1234567890",
              "chargeIndicator": "T",
              "platformId": "<your-platform-id>",
              "testCodes": [
                "GUT_ZOOMER"
              ]
            }'
components:
  schemas:
    OrderRequest:
      type: object
      required:
        - patientId
        - testCodes
      properties:
        placerId:
          type: string
          description: >-
            Optional idempotency key — your own unique id for this order. Omit
            it and every request creates a new order. Send one and: a value you
            already used returns the original order's result (`status:
            duplicate`, never a second charge); an unused value places a new
            order.
          example: VENDOR-ORDER-12345
        patientId:
          type: integer
          description: >-
            Vibrant patient id. Must already exist and belong to your token's
            clinic.
        orderingProviderId:
          type: string
          description: >-
            Optional. The provider the order is attributed to.


            - **Omitted** (or empty/null) — your account's **default ordering
            provider** is used.

            - **Sent** — overrides the default. It must belong to your account,
            otherwise the order is rejected with `provider_scope_mismatch`.

            - **Omitted with no default configured** — the order is rejected.


            The response echoes the provider the order was actually placed
            under.
        testCodes:
          type: array
          items:
            type: string
          description: Vibrant test / panel / bundle codes — the same codes you quoted.
          example:
            - GUT_ZOOMER
            - VITD_25OH
        chargeIndicator:
          type: string
          description: >-
            `C` = customer pays; `P`/`I`/`O` or omitted = patient pays later.
            **WIP — coming soon:** `T` = third-party platform pays with its
            stored card; requires `platformId` and the `X-Payment-Authorization`
            header in addition to the provider access token. Confirm environment
            availability before using `T`. Existing billing flows are unchanged.
            Unsupported values return `400 INVALID_CHARGE_INDICATOR`.
          enum:
            - C
            - P
            - I
            - O
            - T
        platformId:
          type: string
          minLength: 1
          description: >-
            WIP — coming soon. Required when `chargeIndicator` is `T`; used for
            third-party platform payment. The platform ID issued by Vibrant
            during onboarding, identifying the registered public key and the
            platform's single stored card. The JWT in `X-Payment-Authorization`
            must verify against that platform's key. An ID alone does not
            authorize a charge.
          example: <your-platform-id>
        emrName:
          type: string
          description: Your EMR / partner name (for tracking).
        specimenId:
          type: string
          description: Reserved for future use — leave unset.
        sampleCollectionTime:
          type: string
          description: Reserved for future use — leave unset.
      if:
        properties:
          chargeIndicator:
            const: T
        required:
          - chargeIndicator
      then:
        required:
          - platformId
    OrderResult:
      type: object
      description: Order placed, or a duplicate.
      properties:
        status:
          type: string
          enum:
            - placed
            - duplicate
        orderId:
          type: string
          description: Placed order id (status = placed).
        sampleId:
          type: integer
          description: Resulting sample id.
        accessionId:
          type: integer
          description: Resulting accession id (status = placed) — use it to get the report.
        orderingProviderId:
          type: string
          description: >-
            Ordering provider the order was placed under — what you sent, or
            your account's default when you omitted it.
          example: '1234567890'
    OrderProblem:
      type: object
      description: Order understood but not placed. Nothing charged.
      properties:
        status:
          type: string
          enum:
            - ineligible
            - rejected
        failures:
          type: array
          items:
            $ref: '#/components/schemas/EligibilityFailure'
          description: One entry per failed eligibility rule (status = ineligible).
        reason:
          type: string
          description: >-
            Build-failure reason, e.g. `unrecognized_test_codes` or
            `provider_scope_mismatch` (status = rejected).
        errorCodes:
          type: array
          items:
            type: string
          description: Unrecognized test codes, when applicable (status = rejected).
    Error:
      type: object
      description: >-
        🚧 Working in progress — this envelope is the contract; not yet returned
        by every endpoint.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable machine-readable error code.
            message:
              type: string
              description: Human-readable explanation.
            requestId:
              type: string
              description: >-
                Identifier for this request. Include it when contacting support.
                Also returned on every response as the X-Request-Id header.
              example: req_01JQ8ZC5X9K2MN
            details:
              type: array
              items:
                type: object
                additionalProperties: true
              description: Optional structured context.
          required:
            - code
            - message
            - requestId
    EligibilityFailure:
      type: object
      properties:
        code:
          type: string
          description: >-
            Machine-readable reason. Non-exhaustive — tolerate unknown future
            codes and fall back to `reason`.
          enum:
            - PatientNotFound
            - CustomerNotFound
            - PatientNotInClinic
            - IncompletePatientInfo
            - ProzFollowupNoPreviousOrder
            - SkincareFollowupNoPreviousOrder
            - GeneticTestAlreadyOrdered
            - PFSAMaleOnly
          example: IncompletePatientInfo
        reason:
          type: string
          example: 'patient 123456 is missing required information: address'
  responses:
    BadRequest:
      description: The request was invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_request
              message: One or more testCodes were not recognized.
              requestId: req_01JQ8ZC5X9K2MN
              details:
                - unknownCodes:
                    - FOO_BAR
    Unauthorized:
      description: Not authenticated. See Authentication.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Not authenticated.
              requestId: req_01JQ8ZC5X9K2MN
    Forbidden:
      description: Authenticated, but not permitted for this resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: forbidden
              message: Not permitted for this resource.
              requestId: req_01JQ8ZC5X9K2MN
    InternalError:
      description: >-
        Something went wrong on our side. Safe to retry (idempotent endpoints:
        reuse the same placerId).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal_error
              message: Unexpected error.
              requestId: req_01JQ8ZC5X9K2MN
  securitySchemes:
    oauth2:
      type: oauth2
      description: >-
        OAuth2 client credentials. Generate a client ID and client secret in the
        Portal, exchange them for an access token, then send `Authorization:
        Bearer <access_token>`. Request the `result` and `report` scopes to read
        results.
      flows:
        clientCredentials:
          tokenUrl: https://api.vibrant-america.com/v1/oauth2/token
          scopes:
            result: Read finalized lab results
            report: Read report status and issues

````

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