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

# Update a folder

> Partially update, move, archive, or restore a folder.

Updates a folder's name, kind, or labels, moves it, or changes its status. Omitted fields remain unchanged, `metadata` replaces all existing labels (send `{}` to clear), and `parent_folder_id` cannot be combined with `status` in the same request.

* **Move:** Pass an active `parent_folder_id` (or `null` for top level) to move the folder and its entire subtree. Moves that create a cycle return `422 folder_cycle`; moves exceeding 8 levels return `422 folder_too_deep`.
* **Archive:** Set `status` to `ARCHIVED` only after every nested folder and program (including `SUSPENDED` programs) is archived (`409 folder_has_unarchived_contents` otherwise).
* **Restore:** Set `status` to `ACTIVE` when top-level or under an active parent (`409 folder_parent_archived` otherwise). Restoring a folder does not restore its programs.

> [!NOTE]
>
> For usage patterns and examples, see the [Folders guide](https://docs.scrip.dev/guides/folders.md).


## OpenAPI

````yaml PATCH /v1/folders/{folder_id}
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/folders/{folder_id}:
    patch:
      tags:
        - Folders
      summary: Update a folder
      description: Partially update, move, archive, or restore a folder.
      operationId: updateFolder
      parameters:
        - description: Folder ID
          example: 2c4e6a80-b1d3-4f57-8a92-c3e5a7b9d134
          in: path
          name: folder_id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            example:
              name: Coffee
            schema:
              $ref: '#/components/schemas/UpdateFolderRequest'
        description: Fields to update
        required: true
        x-originalParamName: request
      responses:
        '200':
          content:
            application/json:
              examples:
                default:
                  value:
                    created_at: '2027-01-15T10:30:00Z'
                    external_id: brand-coffee
                    id: 2c4e6a80-b1d3-4f57-8a92-c3e5a7b9d134
                    name: Coffee
                    status: ACTIVE
                    updated_at: '2027-01-15T10:30:00Z'
              schema:
                $ref: '#/components/schemas/FolderResponse'
          description: Updated folder
          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:
                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
                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: folder_id
                        message: folder_id is not valid.
                        reason: invalid_format
                    message: folder_id is not valid.
                    param: folder_id
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: invalid_request
              schema:
                $ref: '#/components/schemas/ErrBadRequestResponse'
          description: 'Validation failed (code: validation_error | invalid_json)'
          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:
                folder_not_found:
                  summary: No folder with that id exists in your organization.
                  value:
                    code: folder_not_found
                    doc_url: https://docs.scrip.dev/errors#folder_not_found
                    message: No folder with that id exists in your organization.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: not_found
              schema:
                $ref: '#/components/schemas/ErrNotFoundResponse'
          description: 'Folder not found (code: folder_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:
                folder_archived:
                  summary: >-
                    The folder is `ARCHIVED` and cannot accept new subfolders,
                    moved folders, or programs.
                  value:
                    code: folder_archived
                    doc_url: https://docs.scrip.dev/errors#folder_archived
                    message: >-
                      The folder is ARCHIVED and cannot accept new subfolders,
                      moved folders, or programs.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                folder_has_unarchived_contents:
                  summary: >-
                    The folder still contains unarchived subfolders or programs.
                    Error details include `unarchived_folders` and
                    `unarchived_programs` counts.
                  value:
                    code: folder_has_unarchived_contents
                    doc_url: >-
                      https://docs.scrip.dev/errors#folder_has_unarchived_contents
                    message: >-
                      The folder still contains unarchived subfolders or
                      programs. Error details include unarchived_folders and
                      unarchived_programs counts.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                folder_name_already_exists:
                  summary: >-
                    Another folder under the same parent already uses this name
                    (case-insensitive).
                  value:
                    code: folder_name_already_exists
                    doc_url: https://docs.scrip.dev/errors#folder_name_already_exists
                    message: >-
                      Another folder under the same parent already uses this
                      name (case-insensitive).
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
                folder_parent_archived:
                  summary: >-
                    The folder's parent is `ARCHIVED`, so the folder cannot be
                    restored.
                  value:
                    code: folder_parent_archived
                    doc_url: https://docs.scrip.dev/errors#folder_parent_archived
                    message: >-
                      The folder's parent is ARCHIVED, so the folder cannot be
                      restored.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: conflict
              schema:
                $ref: '#/components/schemas/ErrConflictResponse'
          description: >-
            Name conflict, target or parent folder is archived, or folder has
            unarchived contents (code: folder_name_already_exists |
            folder_archived | folder_has_unarchived_contents |
            folder_parent_archived)
          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'
        '422':
          content:
            application/json:
              examples:
                folder_cycle:
                  summary: >-
                    The target parent is the folder itself or one of its
                    descendants, which would create a cycle.
                  value:
                    code: folder_cycle
                    doc_url: https://docs.scrip.dev/errors#folder_cycle
                    message: >-
                      The target parent is the folder itself or one of its
                      descendants, which would create a cycle.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
                folder_too_deep:
                  summary: >-
                    The folder or its deepest subfolder would exceed the maximum
                    folder depth limit.
                  value:
                    code: folder_too_deep
                    doc_url: https://docs.scrip.dev/errors#folder_too_deep
                    message: >-
                      The folder or its deepest subfolder would exceed the
                      maximum folder depth limit.
                    request_id: req_6f1c2d7e-4b7a-4c0e-9c1a-2f3e4d5c6b7a
                    type: unprocessable
              schema:
                $ref: '#/components/schemas/ErrUnprocessableResponse'
          description: >-
            Move creates a cycle or exceeds the 8-level depth limit (code:
            folder_cycle | folder_too_deep)
          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:
  schemas:
    UpdateFolderRequest:
      additionalProperties: false
      description: >-
        Partially update a folder. Send at least one field; `parent_folder_id`
        and `status` cannot be combined.
      minProperties: 1
      properties:
        kind:
          description: Level classification (send `null` to clear).
          examples:
            - brand
          type:
            - string
            - 'null'
        metadata:
          additionalProperties:
            type: string
          description: >-
            Key-value string labels; replaces all existing labels (send `{}` to
            clear).
          type: object
        name:
          description: >-
            New display name, unique among siblings under the same parent or at
            top level (case-insensitive).
          examples:
            - Coffee
          maxLength: 255
          type: string
        parent_folder_id:
          description: >-
            Target active parent folder UUID to move the folder and its subtree
            (send `null` for top level; cannot be sent with `status`).
          examples:
            - 6a8c0e24-d3f5-4b79-9c1b-e5a7c9b1d335
          format: uuid
          type:
            - string
            - 'null'
        status:
          description: Target lifecycle status (cannot be sent with `parent_folder_id`).
          enum:
            - ACTIVE
            - ARCHIVED
          examples:
            - ARCHIVED
          type: string
      type: object
    FolderResponse:
      description: >-
        A folder that organizes programs and nested folders within an
        organization.
      properties:
        created_at:
          description: When the folder was created.
          examples:
            - '2027-01-15T10:30:00Z'
          format: date-time
          type: string
        external_id:
          description: External identifier, unique per organization.
          examples:
            - brand-coffee
          type: string
        id:
          description: >-
            UUID passed as `folder_id` in paths and `parent_folder_id` on child
            folders.
          examples:
            - 2c4e6a80-b1d3-4f57-8a92-c3e5a7b9d134
          format: uuid
          type: string
        kind:
          description: Level classification (e.g., `brand`, `region`); informational only.
          examples:
            - brand
          type: string
        metadata:
          additionalProperties:
            type: string
          description: Key-value string labels attached to this folder.
          type: object
        name:
          description: >-
            Display name, unique among siblings under the same parent or at top
            level (case-insensitive).
          examples:
            - Coffee
          type: string
        parent_folder_id:
          description: Parent folder UUID (absent for top-level folders).
          examples:
            - 6a8c0e24-d3f5-4b79-9c1b-e5a7c9b1d335
          format: uuid
          type: string
        status:
          description: Lifecycle status of the folder.
          enum:
            - ACTIVE
            - ARCHIVED
          examples:
            - ACTIVE
          type: string
        updated_at:
          description: When the folder was last modified.
          examples:
            - '2027-01-15T10:30:00Z'
          format: date-time
          type: string
      type: object
    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
    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
  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
    WWW-Authenticate:
      description: >-
        The authentication challenge: `Bearer realm="scrip"`. Send your API key
        as a bearer token.
      schema:
        examples:
          - Bearer realm="scrip"
        type: string
    Retry-After:
      description: Seconds to wait before you retry, rounded up to a whole second.
      schema:
        examples:
          - 1
        type: integer
  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.