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

# Cancel an order

> Cancels an order you placed, identified by the **`placerId` it was placed with or its `sampleId`** — exactly one of the two (the `orderId` is not accepted).

What it costs depends on how far the order has travelled:

| Stage | Cancellable? | Fee |
|---|---|---|
| Before the kit ships | Yes | **Free** |
| After the kit ships,<br/>before the lab receives the sample | Yes | **$25** |
| After lab receipt | **No** | — |

Cancellation is **not** idempotent-echo: an already-cancelled order returns `422` with `reason: not_cancellable` (`"Order already canceled"`) — when retrying after a timeout, treat that as already done. An unknown identifier returns `422` with `reason: order_not_found`.

**WIP — coming soon:** cancellation through the API covers only orders placed through the API. An order placed in the Vibrant Portal returns `422` with `reason: not_placed_via_api`; an order outside your clinic is treated as not found.

Cancels an order you placed. Identify it by the **`placerId` you placed it with, or the
`sampleId`** from the place response — exactly one of the two (the `orderId` is not accepted).

## The policy

| Stage | Cancellable? | Fee |
| :- | :- | :- |
| **Before the kit ships** | Yes | **Free** |
| **After the kit ships**, before the lab receives the sample | Yes | **\$25** |
| **After lab receipt** (the lab has the sample) | **No** | — |

Once the lab has the sample the result is already in production; cancellation is rejected with
`422` / `not_cancellable`.

## What comes back

`201` with the cancellation result. `refundAmount` is what this cancellation actually refunded —
`0` when nothing had been charged yet (e.g. a patient-pays-later order that was never paid).

## Cancelling twice, and other rejections

Cancellation is **not** an idempotent echo: an already-cancelled order returns `422` with
`reason: "not_cancellable"` and `message: "Order already canceled"`. When retrying after a network
timeout, treat that response as "already done". An unknown `placerId`/`sampleId` returns `422`
with `reason: "order_not_found"`.

### Orders placed in the Portal

> [!NOTE]
>
> **WIP — coming soon.** This rejection is not returned yet, and its shape may change.

Cancellation through the API covers only orders placed through the API. An order placed in the
Vibrant Portal, for example one you identify by its `sampleId`, will return `422` with
`reason: "not_placed_via_api"`:

```json 422 theme={null}
{
  "status": "rejected",
  "reason": "not_placed_via_api",
  "message": "This order was not placed through the API. Only orders placed through the API can be looked up or cancelled with the API."
}
```

An order outside your clinic is treated as not found (`order_not_found`), as it is today.

> [!NOTE]
>
> There is no fee-preview API yet — the fee/refund that applies is the one returned by the
> cancellation itself. ([Get order status](https://developers.vibrant-wellness.com/api-reference/orders/status.md) remains a proposed
> endpoint.)


## OpenAPI

````yaml POST /orders/cancel
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/cancel:
    post:
      tags:
        - Orders
      summary: Cancel an order
      description: >-
        Cancels an order you placed, identified by the **`placerId` it was
        placed with or its `sampleId`** — exactly one of the two (the `orderId`
        is not accepted).


        What it costs depends on how far the order has travelled:


        | Stage | Cancellable? | Fee |

        |---|---|---|

        | Before the kit ships | Yes | **Free** |

        | After the kit ships,<br/>before the lab receives the sample | Yes |
        **$25** |

        | After lab receipt | **No** | — |


        Cancellation is **not** idempotent-echo: an already-cancelled order
        returns `422` with `reason: not_cancellable` (`"Order already
        canceled"`) — when retrying after a timeout, treat that as already done.
        An unknown identifier returns `422` with `reason: order_not_found`.


        **WIP — coming soon:** cancellation through the API covers only orders
        placed through the API. An order placed in the Vibrant Portal returns
        `422` with `reason: not_placed_via_api`; an order outside your clinic is
        treated as not found.
      operationId: cancelOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelRequest'
            example:
              placerId: VENDOR-ORDER-12345
      responses:
        '201':
          description: Order cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelResult'
              example:
                status: cancelled
                sampleId: 2575603
                refundAmount: 0
                currency: usd
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          description: >-
            Not cancelled — already cancelled, past lab receipt, not found, or
            (coming soon) not placed through the API.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelProblem'
              examples:
                already_cancelled:
                  summary: Already cancelled
                  value:
                    status: rejected
                    reason: not_cancellable
                    message: Order already canceled
                not_found:
                  summary: Unknown placerId / sampleId
                  value:
                    status: rejected
                    reason: order_not_found
                not_placed_via_api:
                  summary: Placed in the Vibrant Portal (WIP — coming soon)
                  value:
                    status: rejected
                    reason: not_placed_via_api
                    message: >-
                      This order was not placed through the API. Only orders
                      placed through the API can be looked up or cancelled with
                      the API.
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    CancelRequest:
      type: object
      description: Identify the order by exactly one of these.
      properties:
        placerId:
          type: string
          description: The placerId the order was placed with.
          example: VENDOR-ORDER-12345
        sampleId:
          type: integer
          description: The sampleId returned when the order was placed.
          example: 2575603
    CancelResult:
      type: object
      properties:
        status:
          type: string
          enum:
            - cancelled
        sampleId:
          type: integer
          example: 2575603
        refundAmount:
          type: number
          description: >-
            Amount refunded by this cancellation — 0 when nothing had been
            charged yet.
          example: 0
        currency:
          type: string
          example: usd
    CancelProblem:
      type: object
      properties:
        status:
          type: string
          enum:
            - rejected
        reason:
          type: string
          description: >-
            `not_cancellable` (already cancelled, or the lab already has the
            sample) or `order_not_found`. **WIP — coming soon:**
            `not_placed_via_api` (the order was placed in the Vibrant Portal).
        message:
          type: string
          description: Human-readable context, when available.
    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
  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
    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.