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

> ## Agent Instructions
> Start with https://docs.scrip.dev/agents.md and https://docs.scrip.dev/which-endpoints-you-need.md. Your application only needs a few API calls as users earn and spend (`POST /v1/events`, balance/history reads, and redemptions); program setup happens in the dashboard or setup scripts.
> Use `https://api-sandbox.scrip.dev` with `sk_test_` keys for testing, and `https://api.scrip.dev` with `sk_live_` keys for production. Keep API keys on your server.
> Pass your own user ID as `external_id` on events and prefix it with `ext:` in participant URL paths (e.g., `GET /v1/participants/ext:user_123/balances`). By default (`on_unknown_participant: CREATE`), the first event for a new `external_id` creates and enrolls the participant automatically.
> Events process asynchronously: `POST /v1/events` returns `202 Accepted` when queued, and rules evaluate in the background. Pass an `idempotency_key` (such as an order ID) on every event, and wait for the `event.completed` webhook or poll `GET /v1/events/{event_id}` before reading updated balances.
> Connect the hosted MCP server at https://mcp.scrip.dev/mcp (OAuth, defaults to Sandbox) to inspect programs, validate and simulate rules, and trace events. Append `.md` to any docs URL for Markdown, or fetch https://docs.scrip.dev/openapi.json for full endpoint schemas.

# Apply a balance operation

> Adjust, hold, release, forfeit, void pending, or mature a participant's balance in one asset.

Runs a direct ledger operation (`ADJUST`, `HOLD`, `RELEASE`, `FORFEIT`, `VOID_PENDING`, or `MATURE`) on a participant's balance in one asset. The `type` field selects which fields the request accepts; passing fields not allowed for that `type` returns `400 validation_error` with `reason: not_allowed` in `fields`.

* **Response shape:** `ADJUST` returns the journal entry, direction (`type`), `bucket`, and updated balance; all other operation types return `operation`, `amount_processed`, `lots_processed` (for `LOT`-mode assets), and the updated balance.
* **Status and idempotency:** All operations require an `ACTIVE` participant except `FORFEIT`, which is also allowed on `CLOSED` participants (`409 participant_inactive` otherwise). Operation idempotency keys are stored permanently with the ledger record and do not expire.

> [!NOTE]
>
> For each operation's fields, responses, and examples, see the [Balance operations guide](https://docs.scrip.dev/guides/balance-operations.md).


## OpenAPI

````yaml POST /v1/participants/{participant_id}/balances/operations
openapi: 3.1.0
info:
  contact:
    email: support@scrip.dev
    name: Scrip Support
  description: >-
    Scrip is the operating system for rewards programs. Use this REST API to
    send events, read balances and history, trigger redemptions, and configure
    programs, assets, rules, tiers, and rewards. Full guides and reference:
    https://docs.scrip.dev


    Base URLs:

    - **Sandbox:** `https://api-sandbox.scrip.dev` (keys start with `sk_test_`)

    - **Production:** `https://api.scrip.dev` (keys start with `sk_live_`)


    Authentication & headers:

    - Pass `Authorization: Bearer <api_key>` on every request.

    - Pass `Content-Type: application/json` on requests with a JSON body.


    Response envelopes:

    - **List endpoints** return `{"data": [...], "pagination": {"has_more":
    false, "next_cursor": null}}`.

    - **Single-resource endpoints** return the resource object directly.

    - **Errors** return `{"type": "...", "code": "...", "message": "...",
    "request_id": "...", "doc_url": "..."}` (plus `param`, `fields`, or
    `details` when applicable). Match on `code` in your error handling and
    include `request_id` when contacting support.


    Participant identifiers: every `{participant_id}` path accepts either
    Scrip's UUID or `ext:` followed by your own `external_id` (for example,
    `/v1/participants/ext:user_123/balances`).


    Idempotency: every operation carries `x-scrip-idempotency` (`replay`,
    `conflict_safe`, `natural_key`, or `none`). On `replay` routes, repeating a
    request with the same `Idempotency-Key` within 24 hours returns the original
    response with `Idempotent-Replayed: true`.
  license:
    name: Proprietary
  termsOfService: https://scrip.dev/terms
  title: Scrip API
  version: '1.0'
servers:
  - description: Production
    url: https://api.scrip.dev
  - description: Sandbox
    url: https://api-sandbox.scrip.dev
security: []
tags:
  - description: Create and manage rewards programs and program wallets.
    name: Programs
  - description: Group programs and other folders inside your organization.
    name: Folders
  - description: Define and manage units of value (points, cashback, credits).
    name: Assets
  - description: Manage participants, balances, state, and transaction history.
    name: Participants
  - description: Manage participant groups with shared balances and state.
    name: Groups
  - description: Create, validate, simulate, and version earn rules.
    name: Rules
  - description: Ingest, inspect, retry, and reverse user events.
    name: Events
  - description: Transfer balances between participants and groups.
    name: Transfers
  - description: >-
      Liability, rollforward, attribution, expiration, activity, and fulfillment
      cost reports.
    name: Reporting
  - description: >-
      Redeem participant balances for catalog items, gift cards, or custom
      amounts.
    name: Redemptions
  - description: Manage items in a program's rewards catalog.
    name: Rewards
  - description: Schedule recurring, one-time, or participant-state-triggered events.
    name: Automations
  - description: >-
      Configure ranked tier tracks, qualification criteria, and downgrade
      policies.
    name: Tiers
  - description: Inspect double-entry ledger records for auditing and reconciliation.
    name: Journal Entries
  - description: >-
      Manage webhook endpoints and delivery logs. Webhooks notify your
      application of real-time events via HTTP POST with HMAC-SHA256 signatures.
    name: Webhooks
  - description: >-
      Inspect the gift-card provider accounts that fulfill redemptions, and the
      products each one offers.
    name: Fulfillment Accounts
  - description: >-
      Connect a program to a fulfillment account so its catalog backs rewards,
      and choose which products the program offers.
    name: Reward Sources
  - description: >-
      Group a program's rules into ordered sets, and reorder the sets and the
      rules inside them.
    name: Rule Sets
  - description: >-
      Events Scrip sends to your webhook endpoints. Each key under `webhooks` is
      an event type, and its request body is the delivery.
    name: Webhook events
paths:
  /v1/participants/{participant_id}/balances/operations:
    post:
      tags:
        - Participants
      summary: Apply a balance operation to a participant
      description: >-
        Adjust, hold, release, forfeit, void pending, or mature a participant's
        balance in one asset.
      operationId: applyParticipantBalanceOperation
      parameters:
        - description: >-
            The participant's id, or ext: followed by the participant's
            external_id.
          example: f7a8b9c0-1d2e-4f3a-b4c5-d6e7f8a9b006
          in: path
          name: participant_id
          required: true
          schema:
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}|ext:.{1,255})$
            type: string
        - $ref: '#/components/parameters/IdempotencyKeyConflictSafe'
      requestBody:
        content:
          application/json:
            examples:
              ADJUST:
                summary: ADJUST operation
                value:
                  amount: '100'
                  asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                  description: Customer service credit
                  direction: CREDIT
                  program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                  type: ADJUST
              FORFEIT:
                summary: FORFEIT operation
                value:
                  amount: '50'
                  asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                  bucket: AVAILABLE
                  description: Account closed
                  program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                  type: FORFEIT
              HOLD:
                summary: HOLD operation
                value:
                  amount: '100'
                  asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                  description: 'Order #123'
                  program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                  reference_id: auth_12345
                  type: HOLD
              MATURE:
                summary: MATURE operation
                value:
                  asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                  program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                  reason: Return window waived for a loyal customer
                  reference_id: order_1042
                  type: MATURE
              RELEASE:
                summary: RELEASE operation
                value:
                  asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                  description: 'Order #123 cancelled'
                  program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                  reference_id: auth_12345
                  type: RELEASE
              VOID_PENDING:
                summary: VOID_PENDING operation
                value:
                  asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                  description: Merchant reversed the authorization
                  program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                  reference_id: auth_12345
                  type: VOID_PENDING
            schema:
              $ref: '#/components/schemas/ParticipantBalanceOperationRequest'
        description: The operation and its fields
        required: true
        x-originalParamName: request
      responses:
        '200':
          content:
            application/json:
              examples:
                ADJUST:
                  summary: ADJUST result
                  value:
                    amount: '100'
                    asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                    balance:
                      available: '1500'
                      deferred: '0'
                      held: '200'
                    bucket: AVAILABLE
                    journal_entry_id: 657a0312-1aaa-4ba7-842b-edfbb39edf14
                    message: Balance adjusted successfully
                    program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                    type: CREDIT
                HOLD:
                  summary: Result of every other type
                  value:
                    amount_processed: '100'
                    asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
                    balance:
                      available: '1400'
                      deferred: '0'
                      held: '300'
                    journal_entry_id: 657a0312-1aaa-4ba7-842b-edfbb39edf14
                    message: Processed 100
                    operation: HOLD
                    program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
                    reference_id: auth_12345
              schema:
                $ref: '#/components/schemas/ParticipantBalanceOperationResult'
          description: Operation applied
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
        '400':
          content:
            application/json:
              examples:
                header_body_mismatch:
                  summary: >-
                    The `Idempotency-Key` header and the `idempotency_key` body
                    field carry different values.
                  value:
                    code: header_body_mismatch
                    doc_url: https://docs.scrip.dev/errors#header_body_mismatch
                    message: >-
                      The Idempotency-Key header and the idempotency_key body
                      field carry different values.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
                invalid_json:
                  summary: The request body is not a valid JSON object.
                  value:
                    code: invalid_json
                    doc_url: https://docs.scrip.dev/errors#invalid_json
                    message: The request body is not a valid JSON object.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
                invalid_lot_lifecycle:
                  summary: >-
                    `expires_at` or `matures_at` is not an RFC 3339 timestamp,
                    or `expires_in` or `matures_in` is not a positive duration.
                  value:
                    code: invalid_lot_lifecycle
                    doc_url: https://docs.scrip.dev/errors#invalid_lot_lifecycle
                    message: >-
                      expires_at or matures_at is not an RFC 3339 timestamp, or
                      expires_in or matures_in is not a positive duration.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
                invalid_lot_lifecycle_order:
                  summary: '`matures_at` is not before `expires_at`.'
                  value:
                    code: invalid_lot_lifecycle_order
                    doc_url: https://docs.scrip.dev/errors#invalid_lot_lifecycle_order
                    message: matures_at is not before expires_at.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
                reserved_reference_id:
                  summary: '`reference_id` uses the reserved `scrip:` namespace.'
                  value:
                    code: reserved_reference_id
                    doc_url: https://docs.scrip.dev/errors#reserved_reference_id
                    message: 'reference_id uses the reserved scrip: namespace.'
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
                validation_error:
                  summary: >-
                    One or more request fields are missing, malformed or not
                    allowed; `fields` lists each one.
                  value:
                    code: validation_error
                    doc_url: https://docs.scrip.dev/errors#validation_error
                    fields:
                      - field: amount
                        message: Add the amount field.
                        reason: required
                    message: Add the amount field.
                    param: amount
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
              schema:
                $ref: '#/components/schemas/ErrBadRequestResponse'
          description: >-
            The type is missing or unknown, a field the type does not accept was
            sent, validation failed, or the Idempotency-Key header is invalid or
            does not match the body (code: validation_error | invalid_json |
            header_body_mismatch | invalid_lot_lifecycle |
            invalid_lot_lifecycle_order | reserved_reference_id)
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          content:
            application/json:
              examples:
                asset_not_found:
                  summary: No asset with that id exists in your organization.
                  value:
                    code: asset_not_found
                    doc_url: https://docs.scrip.dev/errors#asset_not_found
                    message: No asset with that id exists in your organization.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: not_found
                lot_not_found:
                  summary: No lot with that id exists in your organization.
                  value:
                    code: lot_not_found
                    doc_url: https://docs.scrip.dev/errors#lot_not_found
                    message: No lot with that id exists in your organization.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: not_found
                participant_not_found:
                  summary: No participant with that id exists in your organization.
                  value:
                    code: participant_not_found
                    doc_url: https://docs.scrip.dev/errors#participant_not_found
                    message: No participant with that id exists in your organization.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: not_found
                program_not_found:
                  summary: No program with that id exists in your organization.
                  value:
                    code: program_not_found
                    doc_url: https://docs.scrip.dev/errors#program_not_found
                    message: No program with that id exists in your organization.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: not_found
              schema:
                $ref: '#/components/schemas/ErrNotFoundResponse'
          description: >-
            Participant, program, asset or lot not found (code:
            participant_not_found | program_not_found | asset_not_found |
            lot_not_found)
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
        '409':
          content:
            application/json:
              examples:
                idempotency_conflict:
                  summary: >-
                    This idempotency key was already used with a different
                    request.
                  value:
                    code: idempotency_conflict
                    doc_url: https://docs.scrip.dev/errors#idempotency_conflict
                    message: >-
                      This idempotency key was already used with a different
                      request.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                lot_not_deferred:
                  summary: >-
                    The lot is not `DEFERRED` or has expired, or no unexpired
                    `DEFERRED` lot has that `reference_id`; `details` carries
                    what was found.
                  value:
                    code: lot_not_deferred
                    doc_url: https://docs.scrip.dev/errors#lot_not_deferred
                    message: >-
                      The lot is not DEFERRED or has expired, or no unexpired
                      DEFERRED lot has that reference_id; details carries what
                      was found.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                participant_inactive:
                  summary: The participant's status does not allow this operation.
                  value:
                    code: participant_inactive
                    doc_url: https://docs.scrip.dev/errors#participant_inactive
                    message: The participant's status does not allow this operation.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                program_inactive:
                  summary: >-
                    The program is `SUSPENDED` or `ARCHIVED` and does not
                    process this request.
                  value:
                    code: program_inactive
                    doc_url: https://docs.scrip.dev/errors#program_inactive
                    message: >-
                      The program is SUSPENDED or ARCHIVED and does not process
                      this request.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                retryable_conflict:
                  summary: >-
                    Another request changed the same records at the same moment,
                    so nothing was saved.
                  value:
                    code: retryable_conflict
                    doc_url: https://docs.scrip.dev/errors#retryable_conflict
                    message: >-
                      Another request changed the same records at the same
                      moment, so nothing was saved.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
              schema:
                $ref: '#/components/schemas/ErrConflictResponse'
          description: >-
            The participant or program does not allow the operation, the lot is
            not DEFERRED, the idempotency key was used for a different request,
            or another request changed the same balance at the same time (code:
            participant_inactive | program_inactive | lot_not_deferred |
            idempotency_conflict | retryable_conflict)
          headers:
            Retry-After:
              $ref: '#/components/headers/Retry-After'
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
        '422':
          content:
            application/json:
              examples:
                amount_exceeds_maximum:
                  summary: >-
                    `amount` is larger than the asset's
                    `max_transaction_amount`.
                  value:
                    code: amount_exceeds_maximum
                    doc_url: https://docs.scrip.dev/errors#amount_exceeds_maximum
                    message: amount is larger than the asset's max_transaction_amount.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                asset_archived:
                  summary: The asset is `ARCHIVED` and cannot move value.
                  value:
                    code: asset_archived
                    doc_url: https://docs.scrip.dev/errors#asset_archived
                    message: The asset is ARCHIVED and cannot move value.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                asset_not_linked:
                  summary: The asset is not linked to this program.
                  value:
                    code: asset_not_linked
                    doc_url: https://docs.scrip.dev/errors#asset_not_linked
                    message: The asset is not linked to this program.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                insufficient_funds:
                  summary: The available balance is below what the request needs.
                  value:
                    code: insufficient_funds
                    doc_url: https://docs.scrip.dev/errors#insufficient_funds
                    message: The available balance is below what the request needs.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                invalid_amount:
                  summary: '`amount` is not a positive decimal string.'
                  value:
                    code: invalid_amount
                    doc_url: https://docs.scrip.dev/errors#invalid_amount
                    message: amount is not a positive decimal string.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                invalid_inventory_mode:
                  summary: >-
                    The operation needs lot tracking, but the asset's
                    `inventory_mode` is `SIMPLE`. Rule saves, configuration
                    previews and draft simulations report the same problem as
                    400 `validation_error`, with reason `not_allowed` on the
                    field.
                  value:
                    code: invalid_inventory_mode
                    doc_url: https://docs.scrip.dev/errors#invalid_inventory_mode
                    message: >-
                      The operation needs lot tracking, but the asset's
                      inventory_mode is SIMPLE. Rule saves, configuration
                      previews and draft simulations report the same problem as
                      400 validation_error, with reason not_allowed on the
                      field.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                invalid_scale:
                  summary: '`amount` has more decimal places than the asset allows.'
                  value:
                    code: invalid_scale
                    doc_url: https://docs.scrip.dev/errors#invalid_scale
                    message: amount has more decimal places than the asset allows.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
              schema:
                $ref: '#/components/schemas/ErrUnprocessableResponse'
          description: >-
            Insufficient funds, an archived asset, an invalid amount, or an
            asset that does not support the operation (code: insufficient_funds
            | asset_archived | invalid_amount | invalid_scale |
            amount_exceeds_maximum | invalid_inventory_mode | asset_not_linked)
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - BearerAuth: []
components:
  parameters:
    IdempotencyKeyConflictSafe:
      description: >-
        Unique key (1-255 printable ASCII characters) to make retries safe.
        Repeating the same request with the same key returns the original
        result; reusing the key with different fields returns `409
        idempotency_conflict`. When the body also accepts `idempotency_key`,
        supply either or both with the same value.
      in: header
      name: Idempotency-Key
      schema:
        maxLength: 255
        type: string
  schemas:
    ParticipantBalanceOperationRequest:
      description: >-
        A balance operation on a participant. `type` selects the operation and
        accepted fields.
      discriminator:
        mapping:
          ADJUST: '#/components/schemas/ParticipantBalanceOperationAdjust'
          FORFEIT: '#/components/schemas/ParticipantBalanceOperationForfeit'
          HOLD: '#/components/schemas/ParticipantBalanceOperationHold'
          MATURE: '#/components/schemas/ParticipantBalanceOperationMature'
          RELEASE: '#/components/schemas/ParticipantBalanceOperationRelease'
          VOID_PENDING: '#/components/schemas/ParticipantBalanceOperationVoidPending'
        propertyName: type
      examples:
        - amount: '100'
          asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          description: Customer service credit
          direction: CREDIT
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          type: ADJUST
      oneOf:
        - $ref: '#/components/schemas/ParticipantBalanceOperationAdjust'
        - $ref: '#/components/schemas/ParticipantBalanceOperationHold'
        - $ref: '#/components/schemas/ParticipantBalanceOperationRelease'
        - $ref: '#/components/schemas/ParticipantBalanceOperationForfeit'
        - $ref: '#/components/schemas/ParticipantBalanceOperationVoidPending'
        - $ref: '#/components/schemas/ParticipantBalanceOperationMature'
    ParticipantBalanceOperationResult:
      description: >-
        The result of a balance operation. ADJUST returns the adjustment's
        journal entry, direction and bucket; every other type returns the amount
        processed, the lots touched and the balance after.
      oneOf:
        - $ref: '#/components/schemas/AdjustBalanceResponse'
          required:
            - journal_entry_id
            - type
            - amount
            - bucket
        - $ref: '#/components/schemas/BalanceOperationResponse'
          required:
            - operation
            - amount_processed
    ErrBadRequestResponse:
      additionalProperties: false
      description: 'The error body for a 400 response: the request itself is wrong.'
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - validation_error
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#validation_error
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - The request failed validation. Fix every field listed in fields.
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - invalid_request
          type: string
      type: object
    ErrNotFoundResponse:
      description: >-
        The error body for a 404 response: the resource does not exist in your
        organization.
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - participant_not_found
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#participant_not_found
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - The participant was not found.
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - not_found
          type: string
      type: object
    ErrConflictResponse:
      description: >-
        The error body for a 409 response: the current state of a resource
        blocks the request.
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - idempotency_conflict
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#idempotency_conflict
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - >-
              The Idempotency-Key header was already used for a different
              request.
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - conflict
          type: string
      type: object
    ErrUnprocessableResponse:
      description: >-
        The error body for a 422 response: the request is well formed but breaks
        a business rule.
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - insufficient_funds
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#insufficient_funds
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - Insufficient funds
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - unprocessable
          type: string
      type: object
    ParticipantBalanceOperationAdjust:
      additionalProperties: false
      description: >-
        Posts a CREDIT or DEBIT journal entry that adds to or removes from the
        participant's balance in one asset. `direction` chooses which, and
        `amount` is always positive.
      examples:
        - amount: '100'
          asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          description: Customer service credit
          direction: CREDIT
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          type: ADJUST
      properties:
        allow_negative:
          description: >-
            When true on a `DEBIT` adjustment, allows the balance to go
            negative.
          examples:
            - false
          type: boolean
        amount:
          description: The positive amount to add or remove, in the asset's units.
          examples:
            - '100.00'
          minLength: 1
          type: string
        asset_id:
          description: The asset to operate on.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        bucket:
          description: The balance bucket to adjust. Defaults to `AVAILABLE`.
          enum:
            - AVAILABLE
            - HELD
          examples:
            - AVAILABLE
          type: string
        description:
          description: >-
            Why you are adjusting the balance. Scrip records it in the journal
            entry.
          examples:
            - Customer service credit
          maxLength: 500
          minLength: 1
          type: string
        direction:
          description: Whether to credit or debit the balance (`ADJUST` only).
          enum:
            - CREDIT
            - DEBIT
          examples:
            - CREDIT
          type: string
        expires_at:
          description: >-
            Expiration timestamp for a credited lot (RFC 3339, `LOT` assets with
            `direction: CREDIT` only). Mutually exclusive with `expires_in`. Not
            supported with `bucket: HELD`.
          examples:
            - '2027-12-31T23:59:59Z'
          format: date-time
          maxLength: 255
          minLength: 1
          type: string
        expires_in:
          description: >-
            Expiration duration from now for a credited lot, such as `"90d"`
            (`LOT` assets with `direction: CREDIT` only). Units are `w`, `d`,
            `h`, `m` and `s`. Mutually exclusive with `expires_at`. Not
            supported with `bucket: HELD`.
          examples:
            - 90d
          maxLength: 255
          minLength: 1
          type: string
        idempotency_key:
          description: >-
            Unique key for this operation. You can send it in the
            `Idempotency-Key` header instead. When you send both, they must
            match.
          examples:
            - order-1001-completed
          maxLength: 255
          minLength: 1
          type: string
        matures_at:
          description: >-
            Vesting timestamp when a credited lot becomes spendable (RFC 3339,
            `LOT` assets with `direction: CREDIT` only). A future value puts the
            credit in `DEFERRED`. Mutually exclusive with `matures_in`. Not
            supported with `bucket: HELD`.
          examples:
            - '2027-12-31T23:59:59Z'
          format: date-time
          maxLength: 255
          minLength: 1
          type: string
        matures_in:
          description: >-
            Vesting duration from now when a credited lot becomes spendable,
            such as `"7d"` (`LOT` assets with `direction: CREDIT` only). A
            future value puts the credit in `DEFERRED`. Mutually exclusive with
            `matures_at`. Not supported with `bucket: HELD`.
          examples:
            - 7d
          maxLength: 255
          minLength: 1
          type: string
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        type:
          description: 'The operation to run: ADJUST.'
          enum:
            - ADJUST
          examples:
            - ADJUST
          type: string
      required:
        - type
        - program_id
        - asset_id
        - direction
        - amount
        - description
      title: ADJUST operation
      type: object
    ParticipantBalanceOperationForfeit:
      additionalProperties: false
      description: >-
        Moves value from the `bucket` you name to the breakage account. A CLOSED
        participant allows it. An archived asset allows it as an explicit
        cleanup.
      examples:
        - amount: '50'
          asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          bucket: AVAILABLE
          description: Account closed
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          type: FORFEIT
      properties:
        amount:
          description: >-
            The positive amount to remove from `bucket`. Omit it to forfeit the
            full balance in that bucket for a `SIMPLE` asset, or every matching
            lot for a `LOT` asset.
          examples:
            - '100.00'
          minLength: 1
          type: string
        asset_id:
          description: The asset to operate on.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        bucket:
          description: The balance bucket to remove value from.
          enum:
            - AVAILABLE
            - HELD
          examples:
            - AVAILABLE
          type: string
        description:
          description: >-
            Why you are forfeiting this value. Scrip records it in the journal
            entry.
          examples:
            - Customer service credit
          maxLength: 500
          minLength: 1
          type: string
        earned_from:
          description: >-
            Process only lots earned on or after this timestamp (RFC 3339, `LOT`
            assets only).
          examples:
            - '2027-01-01T00:00:00Z'
          format: date-time
          type: string
        earned_to:
          description: >-
            Process only lots earned on or before this timestamp (RFC 3339,
            `LOT` assets only). It must not be earlier than `earned_from`.
          examples:
            - '2027-12-31T23:59:59Z'
          format: date-time
          type: string
        idempotency_key:
          description: >-
            Unique key for this operation. You can send it in the
            `Idempotency-Key` header instead. When you send both, they must
            match.
          examples:
            - order-1001-completed
          maxLength: 255
          minLength: 1
          type: string
        lot_ids:
          description: Restrict the operation to these lot IDs (`LOT` assets only).
          examples:
            - - 4a6c8e02-b1d3-4f57-9c80-e2a4b6d8f012
          items:
            type: string
          type: array
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        type:
          description: 'The operation to run: FORFEIT.'
          enum:
            - FORFEIT
          examples:
            - FORFEIT
          type: string
      required:
        - type
        - program_id
        - asset_id
        - bucket
        - description
      title: FORFEIT operation
      type: object
    ParticipantBalanceOperationHold:
      additionalProperties: false
      description: >-
        Moves value from AVAILABLE to HELD. The asset must be ACTIVE; an
        archived asset refuses new holds.
      examples:
        - amount: '100'
          asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          description: 'Order #123'
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          reference_id: auth_12345
          type: HOLD
      properties:
        amount:
          description: >-
            The positive amount to move from `AVAILABLE` to `HELD`. Omit it to
            hold the full balance for a `SIMPLE` asset, or every matching lot
            for a `LOT` asset.
          examples:
            - '100.00'
          minLength: 1
          type: string
        asset_id:
          description: The asset to operate on.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        description:
          description: >-
            Why you are holding this value. Scrip records it in the journal
            entry.
          examples:
            - Customer service credit
          maxLength: 500
          minLength: 1
          type: string
        earned_from:
          description: >-
            Process only lots earned on or after this timestamp (RFC 3339, `LOT`
            assets only).
          examples:
            - '2027-01-01T00:00:00Z'
          format: date-time
          type: string
        earned_to:
          description: >-
            Process only lots earned on or before this timestamp (RFC 3339,
            `LOT` assets only). It must not be earlier than `earned_from`.
          examples:
            - '2027-12-31T23:59:59Z'
          format: date-time
          type: string
        idempotency_key:
          description: >-
            Unique key for this operation. You can send it in the
            `Idempotency-Key` header instead. When you send both, they must
            match.
          examples:
            - order-1001-completed
          maxLength: 255
          minLength: 1
          type: string
        lot_ids:
          description: Restrict the operation to these lot IDs (`LOT` assets only).
          examples:
            - - 4a6c8e02-b1d3-4f57-9c80-e2a4b6d8f012
          items:
            type: string
          type: array
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        reference_id:
          description: >-
            Your id for this hold, so you can release it later. Only `LOT`
            assets support it. It cannot start with `scrip:`.
          examples:
            - auth_12345
          maxLength: 255
          minLength: 1
          pattern: ^[A-Za-z0-9._:@-]+$
          type: string
        type:
          description: 'The operation to run: HOLD.'
          enum:
            - HOLD
          examples:
            - HOLD
          type: string
      required:
        - type
        - program_id
        - asset_id
        - description
      title: HOLD operation
      type: object
    ParticipantBalanceOperationMature:
      additionalProperties: false
      description: >-
        Moves a DEFERRED lot, or every DEFERRED lot with one `reference_id`, to
        AVAILABLE now instead of on its maturity date. Send `lot_id` or
        `reference_id`, not both.
      examples:
        - asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          reason: Return window waived for a loyal customer
          reference_id: order_1042
          type: MATURE
      oneOf:
        - required:
            - lot_id
        - required:
            - reference_id
      properties:
        asset_id:
          description: The asset to operate on.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        idempotency_key:
          description: >-
            Unique key for this operation. You can send it in the
            `Idempotency-Key` header instead. When you send both, they must
            match.
          examples:
            - order-1001-completed
          maxLength: 255
          minLength: 1
          type: string
        lot_id:
          description: >-
            DEFERRED lot to make available early. Mutually exclusive with
            `reference_id`.
          examples:
            - 4a6c8e02-b1d3-4f57-9c80-e2a4b6d8f012
          format: uuid
          type: string
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        reason:
          description: >-
            Reason for making the lot available early, recorded in the journal
            entry description.
          examples:
            - Return window waived for a loyal customer
          maxLength: 500
          minLength: 1
          type: string
        reference_id:
          description: >-
            Make every `DEFERRED` lot with this id available now. Send this or
            `lot_id`, not both. It cannot start with `scrip:`.
          examples:
            - auth_12345
          maxLength: 255
          minLength: 1
          pattern: ^[A-Za-z0-9._:@-]+$
          type: string
        type:
          description: 'The operation to run: MATURE.'
          enum:
            - MATURE
          examples:
            - MATURE
          type: string
      required:
        - type
        - program_id
        - asset_id
        - reason
      title: MATURE operation
      type: object
    ParticipantBalanceOperationRelease:
      additionalProperties: false
      description: >-
        Moves value from HELD back to AVAILABLE. An archived asset allows it, so
        you can release existing holds.
      examples:
        - asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          description: 'Order #123 cancelled'
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          reference_id: auth_12345
          type: RELEASE
      properties:
        amount:
          description: >-
            The positive amount to move from `HELD` to `AVAILABLE`. Omit it to
            release the full held balance for a `SIMPLE` asset, or every
            matching lot for a `LOT` asset.
          examples:
            - '100.00'
          minLength: 1
          type: string
        asset_id:
          description: The asset to operate on.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        description:
          description: >-
            Why you are releasing this value. Scrip records it in the journal
            entry.
          examples:
            - Customer service credit
          maxLength: 500
          minLength: 1
          type: string
        earned_from:
          description: >-
            Process only lots earned on or after this timestamp (RFC 3339, `LOT`
            assets only).
          examples:
            - '2027-01-01T00:00:00Z'
          format: date-time
          type: string
        earned_to:
          description: >-
            Process only lots earned on or before this timestamp (RFC 3339,
            `LOT` assets only). It must not be earlier than `earned_from`.
          examples:
            - '2027-12-31T23:59:59Z'
          format: date-time
          type: string
        idempotency_key:
          description: >-
            Unique key for this operation. You can send it in the
            `Idempotency-Key` header instead. When you send both, they must
            match.
          examples:
            - order-1001-completed
          maxLength: 255
          minLength: 1
          type: string
        lot_ids:
          description: Restrict the operation to these lot IDs (`LOT` assets only).
          examples:
            - - 4a6c8e02-b1d3-4f57-9c80-e2a4b6d8f012
          items:
            type: string
          type: array
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        reference_id:
          description: >-
            The id you sent when holding the value to release. Only `LOT` assets
            support it. It cannot start with `scrip:`.
          examples:
            - auth_12345
          maxLength: 255
          minLength: 1
          pattern: ^[A-Za-z0-9._:@-]+$
          type: string
        type:
          description: 'The operation to run: RELEASE.'
          enum:
            - RELEASE
          examples:
            - RELEASE
          type: string
      required:
        - type
        - program_id
        - asset_id
        - description
      title: RELEASE operation
      type: object
    ParticipantBalanceOperationVoidPending:
      additionalProperties: false
      description: >-
        Cancels pending rewards credited into HELD under a `reference_id` and
        returns the value to its source. Send `amount` to void part of them.
      examples:
        - asset_id: a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          description: Merchant reversed the authorization
          program_id: 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          reference_id: auth_12345
          type: VOID_PENDING
      properties:
        amount:
          description: >-
            The positive amount of pending rewards to cancel. Omit it to cancel
            every pending reward under `reference_id`.
          examples:
            - '100.00'
          minLength: 1
          type: string
        asset_id:
          description: The asset to operate on.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        description:
          description: >-
            Why you are cancelling these pending rewards. Scrip records it in
            the journal entry.
          examples:
            - Customer service credit
          maxLength: 500
          minLength: 1
          type: string
        idempotency_key:
          description: >-
            Unique key for this operation. You can send it in the
            `Idempotency-Key` header instead. When you send both, they must
            match.
          examples:
            - order-1001-completed
          maxLength: 255
          minLength: 1
          type: string
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        reference_id:
          description: >-
            The id of the pending rewards to cancel. These rewards must have
            been credited into `HELD` on a `LOT` asset. It cannot start with
            `scrip:`.
          examples:
            - auth_12345
          maxLength: 255
          minLength: 1
          pattern: ^[A-Za-z0-9._:@-]+$
          type: string
        type:
          description: 'The operation to run: VOID_PENDING.'
          enum:
            - VOID_PENDING
          examples:
            - VOID_PENDING
          type: string
      required:
        - type
        - program_id
        - asset_id
        - reference_id
        - description
      title: VOID_PENDING operation
      type: object
    AdjustBalanceResponse:
      description: >-
        The result of a participant balance adjustment: the journal entry that
        recorded it and the balance after it.
      properties:
        amount:
          description: Amount adjusted
          examples:
            - '100.00'
          type: string
        asset_id:
          description: The asset that was adjusted.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        balance:
          $ref: '#/components/schemas/BalanceSummary'
          description: Balance after the adjustment
        bucket:
          description: The balance bucket that was adjusted.
          enum:
            - AVAILABLE
            - HELD
            - DEFERRED
          examples:
            - AVAILABLE
          type: string
        journal_entry_id:
          description: Ledger journal entry created by this adjustment
          examples:
            - 657a0312-1aaa-4ba7-842b-edfbb39edf14
          format: uuid
          type: string
        message:
          description: Confirmation message
          examples:
            - Balance adjusted successfully
          type: string
        program_id:
          description: The program the adjustment belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        type:
          description: Whether the adjustment was a credit or debit
          enum:
            - CREDIT
            - DEBIT
          examples:
            - CREDIT
          type: string
      type: object
    BalanceOperationResponse:
      description: >-
        The result of a hold, release, forfeit, void or early maturity: the
        amount processed, the lots touched and the balance after.
      properties:
        amount_processed:
          description: Total amount processed
          examples:
            - '100.00'
          type: string
        asset_id:
          description: The asset the operation applied to.
          examples:
            - a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02
          format: uuid
          type: string
        balance:
          $ref: '#/components/schemas/BalanceSummary'
          description: Balance after the operation
        journal_entry_id:
          description: Ledger journal entry created by this operation
          examples:
            - 657a0312-1aaa-4ba7-842b-edfbb39edf14
          format: uuid
          type: string
        lots_processed:
          description: Individual lots affected. Only present for LOT mode assets
          items:
            $ref: '#/components/schemas/ProcessedLotResponse'
          type: array
        message:
          description: Confirmation message
          examples:
            - Processed 100.00
          type: string
        operation:
          description: >-
            The balance operation that was performed, matching the endpoint you
            called.
          enum:
            - HOLD
            - RELEASE
            - FORFEIT
            - VOID_PENDING
            - MATURE
          type: string
        program_id:
          description: The program the operation belongs to.
          examples:
            - 8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01
          format: uuid
          type: string
        reference_id:
          description: Correlation ID linking this hold/release (if provided)
          examples:
            - auth_12345
          type: string
      type: object
    ErrorFieldDetail:
      description: 'One failing field: its JSON name, why it failed, and what to change.'
      properties:
        field:
          description: The JSON name of the failing field, with dots for nested fields
          type: string
        message:
          description: What to change in this field
          type: string
        reason:
          description: >-
            Why the field failed: required, invalid_format, out_of_range,
            unknown_field, not_allowed or too_long
          examples:
            - required
          type: string
      type: object
    ErrUnauthorizedResponse:
      description: 'The error body for a 401 response: the API key is missing or not valid.'
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - invalid_api_key
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#invalid_api_key
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - >-
              The API key in the Authorization header is unknown, revoked or
              needs rotation.
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - authentication
          type: string
      type: object
    ErrForbiddenResponse:
      description: 'The error body for a 403 response: the caller is not allowed to do this.'
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - insufficient_permissions
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#insufficient_permissions
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - Your dashboard role does not allow this action.
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - permission
          type: string
      type: object
    ErrTooManyRequestsResponse:
      additionalProperties: false
      description: >-
        The error body for a 429 response: you sent more requests than the rate
        limit allows.
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - rate_limit_exceeded
          type: string
        details:
          additionalProperties: true
          description: Extra context for this code, documented per code on the errors page
          type: object
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#rate_limit_exceeded
          type: string
        fields:
          description: Every failing field on a validation_error, reported in one pass
          items:
            $ref: '#/components/schemas/ErrorFieldDetail'
          type: array
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - Rate limit exceeded. Wait for the Retry-After delay, then retry.
          type: string
        param:
          description: The one request field at fault, when there is one
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - rate_limited
          type: string
      type: object
    ErrInternalResponse:
      description: >-
        The error body for a 500 response: something failed on Scrip's side.
        Quote the `request_id` when you contact support.
      properties:
        code:
          description: >-
            The specific reason for the error. Branch on this value, not on
            message
          examples:
            - internal_error
          type: string
        doc_url:
          description: A link to this code on the errors page
          examples:
            - https://docs.scrip.dev/errors#internal_error
          type: string
        message:
          description: What happened and what to do next, in one or two sentences
          examples:
            - >-
              An internal error occurred. Retry the request; if it keeps
              failing, contact support with the request_id.
          type: string
        request_id:
          description: >-
            The id of this request, the same req_ value as the X-Request-ID
            response header. Quote it when you contact support
          examples:
            - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
          type: string
        type:
          description: The error family. It is one value per HTTP status
          examples:
            - internal
          type: string
      type: object
    BalanceSummary:
      description: A balance split into available, held and deferred amounts.
      properties:
        available:
          description: Spendable balance
          examples:
            - '1400.00'
          type: string
        deferred:
          description: Balance not yet matured
          examples:
            - '0.00'
          type: string
        held:
          description: >-
            Amount in `HELD`: set aside by a hold or a pending redemption, plus
            pending rewards waiting to settle. It is not part of `available`.
          examples:
            - '200.00'
          type: string
      type: object
    ProcessedLotResponse:
      description: A lot that an operation changed and the amount it changed.
      properties:
        amount:
          description: Amount processed from this lot
          examples:
            - '50.00'
          type: string
        id:
          description: The id of the lot the operation changed.
          examples:
            - 4a6c8e02-b1d3-4f57-9c80-e2a4b6d8f012
          format: uuid
          type: string
      type: object
  headers:
    X-RateLimit-Limit:
      description: Request ceiling enforced by the API instance that served your request.
      schema:
        examples:
          - 1000
        type: integer
    X-RateLimit-Remaining:
      description: Requests left before the instance that served your request returns 429.
      schema:
        examples:
          - 0
        type: integer
    X-RateLimit-Reset:
      description: >-
        Unix time in seconds when the instance that served your request has its
        full allowance again.
      schema:
        examples:
          - 1790000000
        type: integer
    X-Request-ID:
      description: >-
        The id of this request, the same `req_` value as `request_id` in an
        error body. Quote it when you contact support.
      schema:
        examples:
          - req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
        type: string
    Retry-After:
      description: Seconds to wait before you retry, rounded up to a whole second.
      schema:
        examples:
          - 1
        type: integer
    WWW-Authenticate:
      description: >-
        The authentication challenge: `Bearer realm="scrip"`. Send your API key
        as a bearer token.
      schema:
        examples:
          - Bearer realm="scrip"
        type: string
  responses:
    Unauthorized:
      content:
        application/json:
          examples:
            authentication_required:
              summary: The request carried no API key or session token.
              value:
                code: authentication_required
                doc_url: https://docs.scrip.dev/errors#authentication_required
                message: The request carried no API key or session token.
                request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                type: authentication
            invalid_api_key:
              summary: >-
                The API key in the `Authorization` header is unknown, revoked or
                needs rotation.
              value:
                code: invalid_api_key
                doc_url: https://docs.scrip.dev/errors#invalid_api_key
                message: >-
                  The API key in the Authorization header is unknown, revoked or
                  needs rotation.
                request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                type: authentication
          schema:
            $ref: '#/components/schemas/ErrUnauthorizedResponse'
      description: >-
        The API key is missing or not valid. See
        [Authentication](https://docs.scrip.dev/authentication).
      headers:
        WWW-Authenticate:
          $ref: '#/components/headers/WWW-Authenticate'
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
    Forbidden:
      content:
        application/json:
          examples:
            insufficient_permissions:
              summary: Your dashboard role does not allow this action.
              value:
                code: insufficient_permissions
                doc_url: https://docs.scrip.dev/errors#insufficient_permissions
                message: Your dashboard role does not allow this action.
                request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                type: permission
          schema:
            $ref: '#/components/schemas/ErrForbiddenResponse'
      description: The caller is not allowed to do this.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
    TooManyRequests:
      content:
        application/json:
          examples:
            rate_limit_exceeded:
              summary: Your organization sent more requests than the rate limit allows.
              value:
                code: rate_limit_exceeded
                doc_url: https://docs.scrip.dev/errors#rate_limit_exceeded
                message: >-
                  Your organization sent more requests than the rate limit
                  allows.
                request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                type: rate_limited
          schema:
            $ref: '#/components/schemas/ErrTooManyRequestsResponse'
      description: >-
        Too many requests. Wait the number of seconds in the `Retry-After`
        header, then retry. See [Limits and
        durations](https://docs.scrip.dev/limits#rate-limits).
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
    InternalError:
      content:
        application/json:
          examples:
            internal_error:
              summary: Scrip hit an unexpected error while handling the request.
              value:
                code: internal_error
                doc_url: https://docs.scrip.dev/errors#internal_error
                message: Scrip hit an unexpected error while handling the request.
                request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                type: internal
          schema:
            $ref: '#/components/schemas/ErrInternalResponse'
      description: >-
        Something failed on Scrip's side. Retry the request, and quote
        `request_id` if it keeps failing.
        [Errors](https://docs.scrip.dev/errors) lists every code, and the [API
        introduction](https://docs.scrip.dev/api-reference/introduction)
        describes the error format.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
  securitySchemes:
    BearerAuth:
      description: 'Send your API key as `Authorization: Bearer <key>`.'
      scheme: bearer
      type: http
      x-default: sk_...

````

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