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

# Save a patient's card (no charge)

> Vault a patient's card **without charging it**, so a subscription can be created
for a patient who has never bought anything. Requires `orders:write` or
`patients:write`.

1. On your own page, load Accept.js (`checkout.accept_js_url` from any
   `patient_checkout` order, or your Accept.js keys) and call
   `Accept.dispatchData` to tokenize the card in the browser. Card data never
   touches your server or VitaRelay's.
2. POST the single-use nonce here as `opaque_data`.
3. Use the returned `id` as `payment_method_id` when creating subscription
   lines on `POST /orders`.

Billing details default to the patient record. The card belongs to the patient.
With a test key the response is a simulated `sandbox_pm_…` card.




## OpenAPI

````yaml /openapi.yaml post /patients/{id}/payment-methods
openapi: 3.1.0
info:
  title: VitaRelay API
  version: 2.0.0
  description: |
    The VitaRelay REST API.

    **Base URL:** `https://vitarelay.com/api/public/v1`

    ## Authentication
    All requests require a Bearer API key:

    ```text
    Authorization: Bearer vr_live_xxxxxxxxxxxxxxxx
    ```

    Keys are issued per organization. `vr_live_` keys act on production data.
    `vr_test_` keys operate a fully-isolated **sandbox** (see below).

    ## Pagination
    List endpoints are cursor-based. Pass `limit` (default 50, max 100) and
    `cursor` (the `next_cursor` from the previous page). When `next_cursor`
    is `null` there are no further pages. All resource ids are UUIDs.

    ## Idempotency
    Write endpoints accept your own external identifiers —
    `external_patient_id`, `external_intake_id`, `external_order_id`. These act
    as idempotency keys: replaying a request with the same external id returns
    the original resource (HTTP `200` instead of `201`) rather than creating a
    duplicate.

    ## Rate limiting
    Write endpoints are rate limited per API key — default **60 requests per
    minute** (fixed window). Exceeding the limit returns `429 rate_limited`
    with `Retry-After`, `X-RateLimit-Limit`, `X-RateLimit-Remaining` and
    `X-RateLimit-Reset` headers. Read endpoints are not rate limited in v1.

    ## Sandbox
    With a `vr_test_` key, writes never create real patients, intakes or orders
    and never charge a card. They return synthetic ids (`sandbox_pat_…`,
    `sandbox_int_…`, `sandbox_ord_…`) and include `"sandbox": true` in the
    response. Sandbox objects advance through a simulated lifecycle that fires
    real webhook deliveries to your endpoint (`intake.reviewed`, `order.paid` →
    `order.shipped` → `order.delivered`) with `"sandbox": true` in the payload.
    In sandbox, reference a patient by `external_patient_id` or by the returned
    `sandbox_pat_…` id.

    ## Webhooks
    Outbound webhooks are configured in the VitaRelay admin UI (there is no
    webhook management API). Events: `order.paid`, `order.shipped`,
    `order.delivered`, `order.exception`, `intake.reviewed`. Each delivery is
    signed with HMAC-SHA256 over the raw body and carries the headers
    `X-VitaRelay-Signature: sha256=<hex>`, `X-VitaRelay-Event`,
    `X-VitaRelay-Delivery` (event id) and `X-VitaRelay-Timestamp`. Failed
    deliveries are retried with exponential backoff and dead-lettered after the
    maximum attempts.
  contact:
    name: VitaRelay Support
    email: info@vitarelay.com
servers:
  - url: https://vitarelay.com/api/public/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Patients
    description: Patient records scoped to your organization.
  - name: Intakes
    description: Intake form submissions. Write access is Vita Clinic only.
  - name: Orders
    description: >-
      Orders and fulfillment status. Two billing modes: `card_on_file` (default)
      charges the clinic's stored card synchronously, and `patient_checkout`
      creates the order unpaid and returns a checkout block so the patient can
      pay on your own page via Authorize.Net Accept.js (see POST
      /orders/{id}/pay).
  - name: Products
    description: Catalog products available to your organization.
  - name: Prescriptions
    description: >-
      Prescriptions written by your organization (read only). Refer patients
      into the Internal Doctor Network (IDN). You refer; an IDN doctor evaluates
      and prescribes. Requires IDN activation and rx scopes.
  - name: Storefront
    description: >-
      Build and manage your clinic's patient storefront — settings, curated
      product listings and bundles. Requires the `shop:read` / `shop:write`
      scopes.
  - name: Subscriptions
    description: >-
      Patient-shop subscription lifecycle. Requires `subscriptions:read` or
      `subscriptions:write`.
  - name: Partners
    description: >-
      Consultant (partner) program. **Available only to organizations enrolled
      in the program; every other organization receives `403 not_available`.**
      Create your consultants, assign customers to them and read the commission
      credit tracked on their orders. Requires `partners:read` /
      `partners:write`. Commissions are tracked for your own payouts — VitaRelay
      does not pay consultants.
paths:
  /patients/{id}/payment-methods:
    parameters:
      - $ref: '#/components/parameters/PatientRef'
    post:
      tags:
        - Patients
      summary: Save a patient's card (no charge)
      description: >
        Vault a patient's card **without charging it**, so a subscription can be
        created

        for a patient who has never bought anything. Requires `orders:write` or

        `patients:write`.


        1. On your own page, load Accept.js (`checkout.accept_js_url` from any
           `patient_checkout` order, or your Accept.js keys) and call
           `Accept.dispatchData` to tokenize the card in the browser. Card data never
           touches your server or VitaRelay's.
        2. POST the single-use nonce here as `opaque_data`.

        3. Use the returned `id` as `payment_method_id` when creating
        subscription
           lines on `POST /orders`.

        Billing details default to the patient record. The card belongs to the
        patient.

        With a test key the response is a simulated `sandbox_pm_…` card.
      operationId: savePatientPaymentMethod
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - opaque_data
              properties:
                opaque_data:
                  type: object
                  required:
                    - dataDescriptor
                    - dataValue
                  properties:
                    dataDescriptor:
                      type: string
                    dataValue:
                      type: string
                billing:
                  type: object
                  description: >-
                    Cardholder billing details. Anything omitted falls back to
                    the patient record.
                  properties:
                    first_name:
                      type: string
                    last_name:
                      type: string
                    line1:
                      type: string
                    city:
                      type: string
                    state:
                      type: string
                    postal_code:
                      type: string
                    country:
                      type: string
                nickname:
                  type: string
                  description: Display-only label (max 40 characters).
                make_default:
                  type: boolean
                  description: >-
                    Make this the patient's default card. It already is when
                    they have none.
      responses:
        '201':
          description: Card saved.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/SavedCard'
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/PatientNotFound'
        '422':
          description: >-
            Validation failed, or the gateway couldn't save the card
            (`card_not_saved`) — ask the patient to re-enter it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    PatientRef:
      name: id
      in: path
      required: true
      description: >-
        The VitaRelay patient id (UUID), **or your own `external_patient_id`**
        from when you created the patient — you never have to store our id.
      schema:
        type: string
  schemas:
    SavedCard:
      type: object
      properties:
        id:
          type: string
          description: Use as `payment_method_id` on subscription lines.
        brand:
          type:
            - string
            - 'null'
        last4:
          type:
            - string
            - 'null'
        exp_month:
          type:
            - integer
            - 'null'
        exp_year:
          type:
            - integer
            - 'null'
        nickname:
          type:
            - string
            - 'null'
        is_default:
          type: boolean
        created_at:
          type: string
          format: date-time
      example:
        id: 8c1d5a0e-2b7f-4e3a-9d41-6f0a1b2c3d4e
        brand: Visa
        last4: '4242'
        exp_month: 12
        exp_year: 2030
        nickname: null
        is_default: true
        created_at: '2026-10-02T15:04:11.220Z'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: |
                One of `invalid_body`, `validation_failed`, `unauthorized`,
                `insufficient_scope`, `not_vita_clinic`, `patient_not_found`,
                `product_not_found`, `product_not_allowed`, `duplicate_request`,
                `rate_limited`, `card_required`, `payment_declined`,
                `internal_error`, `not_found`.
            message:
              type: string
      example:
        error:
          code: validation_failed
          message: One or more fields are invalid
  responses:
    InvalidBody:
      description: >-
        Malformed request or invalid path parameter (`invalid_body`,
        `invalid_id`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, invalid or revoked API key (`unauthorized`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PatientNotFound:
      description: >-
        Patient not found or owned by another organization
        (`patient_not_found`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Per-key rate limit exceeded (`rate_limited`). Default 60 writes/minute.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/XRateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/XRateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/XRateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Unexpected server error (`internal_error`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  headers:
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
    XRateLimitLimit:
      description: Requests permitted in the current window.
      schema:
        type: integer
    XRateLimitRemaining:
      description: Requests remaining in the current window.
      schema:
        type: integer
    XRateLimitReset:
      description: Unix timestamp when the current window resets.
      schema:
        type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        API key issued by VitaRelay. Send as `Authorization: Bearer vr_live_…`
        (production) or `Authorization: Bearer vr_test_…` (sandbox).

````

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