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

# Discard the draft

> Puts the draft back to what is published: every change since is lost (studios open on the scene can still undo it). `draftRevision` is required (in the body, or as If-Match; sent both ways, they must name the same draft, else 422 INVALID_INPUT): the draft you reviewed; if it changed after that, nothing is discarded (code CONFLICT with `currentRevision`: read it again; status 409 for the body's draftRevision, 412 for If-Match). From then on the draft is based on that version, a revert too: publishing it unchanged answers `unchanged`. `dryRun: true` says what would be lost (`lost`, as resource paths) and discards nothing. 409 NOT_PUBLISHED when nothing is published.



## OpenAPI

````yaml /api-reference/scenes-openapi.json post /scenes/{id}/discard
openapi: 3.1.0
info:
  title: Streamloop Scenes API
  version: 1.0.0
  description: >-
    Build and run scenes: live, designed streams. A scene (id `scn_…`) holds
    frames — full arrangements of layers (text, pictures, video, web pages,
    tables, tickers), one on air at a time — each at `frame/<id>`, plus the
    sources it reads (cameras, RTMP/SRT inputs, files, playlists, URLs, Google
    Sheets), its components and its script. You edit its draft as resources at
    paths (`frame/intro`, `frame/intro/title`, `source/data/headlines`,
    `component/LowerThird`, `script/show.ts`); every write is built and checked
    as the Streamloop studio checks it, and studios open on it see it at once.
    Nothing reaches viewers until you publish. To put a scene on a stream: `PUT
    /v1/streams/{id}/scene` (Streamloop REST API), then start the stream.


    This API follows the conventions of Streamloop's REST API: the same
    authentication (`X-API-Key`, an OAuth bearer, or the dashboard's session),
    `X-Workspace-Id`, RFC 7807 problems with a stable `code`, cursor pages,
    `Idempotency-Key` on POST and PATCH, and `RateLimit-*` headers (600 requests
    a minute).
servers:
  - url: https://api.streamloop.app/v1
security:
  - apiKey: []
  - oauth: []
tags:
  - name: scenes
    description: Create, list, read and delete scenes.
  - name: draft
    description: >-
      Read and change the scene's draft, resource by resource. Start with `GET
      /scenes/{id}/resources` (the kinds of thing it holds) and `GET
      /scenes/{id}/resources/element/*` (the building blocks and their props).
  - name: publishing
    description: Put the draft on air, see what was published, go back.
  - name: live
    description: What a stream playing the scene has on air, and the operator's actions.
  - name: inputs
    description: >-
      Live inputs: ingest keys for RTMP/RTMPS/SRT encoders, RTSP cameras, and
      secrets the scene's tables use.
paths:
  /scenes/{id}/discard:
    parameters:
      - $ref: '#/components/parameters/id'
      - $ref: '#/components/parameters/workspace'
    post:
      tags:
        - publishing
      summary: Discard the draft
      description: >-
        Puts the draft back to what is published: every change since is lost
        (studios open on the scene can still undo it). `draftRevision` is
        required (in the body, or as If-Match; sent both ways, they must name
        the same draft, else 422 INVALID_INPUT): the draft you reviewed; if it
        changed after that, nothing is discarded (code CONFLICT with
        `currentRevision`: read it again; status 409 for the body's
        draftRevision, 412 for If-Match). From then on the draft is based on
        that version, a revert too: publishing it unchanged answers `unchanged`.
        `dryRun: true` says what would be lost (`lost`, as resource paths) and
        discards nothing. 409 NOT_PUBLISHED when nothing is published.
      operationId: discardDraft
      parameters:
        - $ref: '#/components/parameters/ifMatch'
        - $ref: '#/components/parameters/idempotency'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                draftRevision:
                  type: string
                dryRun:
                  type: boolean
      responses:
        '200':
          description: >-
            The draft is the published version again (or, with dryRun, what
            would be lost)
          content:
            application/json:
              schema:
                type: object
                properties:
                  summary:
                    type: string
                  version:
                    type: integer
                  lost:
                    type: array
                    items:
                      type: string
                    description: >-
                      What the draft had that the published version doesn't, as
                      resource paths
                  dryRun:
                    type: boolean
                  draftRevision:
                    type: string
                    description: The draft's revision after the discard
        '409':
          $ref: '#/components/responses/Conflict'
        '412':
          $ref: '#/components/responses/PreconditionFailed'
        4XX:
          $ref: '#/components/responses/Problem'
        5XX:
          $ref: '#/components/responses/Problem'
components:
  parameters:
    id:
      name: id
      in: path
      required: true
      schema:
        type: string
        pattern: ^scn_
      description: The scene's id (`scn_…`)
    workspace:
      name: X-Workspace-Id
      in: header
      schema:
        type: string
      description: >-
        The workspace to act in. Required with an API key; otherwise the
        session's own.
    ifMatch:
      name: If-Match
      in: header
      schema:
        type: string
      description: >-
        The revision (ETag) you read — one, or a comma-separated list of which
        any current one matches — compared strongly (a weak `W/"…"` tag never
        matches): refused with 412 PRECONDITION_FAILED if the resource changed
        since or no longer exists (the problem carries `currentRevision`, null
        when it is gone, and for a layer `frameRevision`: either is taken). A
        layer takes its own revision or that of the `frame/<id>` it is in. `*`:
        it must exist. Checked atomically with the write: of two writes sent at
        once with the same revision, one lands and the other is 412.
    idempotency:
      name: Idempotency-Key
      in: header
      schema:
        type: string
        maxLength: 200
      description: >-
        Retry safely: the key (per caller, workspace, method and path) is taken
        before the request runs, and its first answer is replayed for 24 hours,
        with `Idempotency-Replayed: true` — a repeat sent while the first still
        runs waits for it. The same key with a different body is 422
        IDEMPOTENCY_KEY_REUSED. A 5xx is not kept: the retry runs.
  responses:
    Conflict:
      description: >-
        CONFLICT (a revision given in the body moved — `revisions` of a remove,
        a discard's draftRevision; `currentRevision`; If-Match is 412 instead),
        EDIT_NO_MATCH (the text to replace isn't there; the closest line is
        quoted), EDIT_AMBIGUOUS (it is there more than once), IN_USE (something
        uses it; named), CONFIRM_REQUIRED (on air: send confirm: true to accept
        it), STALE_PUBLISH (a version was published after this draft's base, or
        after the version a revert saw: `publishedVersion`, `basedOn`,
        `reverted`, `publishedVersionIsRevert`; after a revert, publish with
        overwritePublished or discard the draft to match it), DRAFT_NOT_SAVED
        (the server doesn't have those edits yet; retry)
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    PreconditionFailed:
      description: >-
        PRECONDITION_FAILED: the If-Match revision is not the resource's now
        (`currentRevision`), or If-Match: * and it doesn't exist
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    Problem:
      description: An RFC 7807 problem; branch on `code`
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
  schemas:
    Problem:
      type: object
      required:
        - type
        - title
        - status
        - code
        - detail
      properties:
        type:
          type: string
          const: about:blank
        title:
          type: string
        status:
          type: integer
        code:
          type: string
          description: >-
            Stable — branch on it: BAD_REQUEST (400), WORKSPACE_REQUIRED (400),
            UNAUTHENTICATED (401), INSUFFICIENT_SCOPE (403), WORKSPACE_FORBIDDEN
            (403), NOT_FOUND (404), METHOD_NOT_ALLOWED (405), READ_ONLY (422),
            CONFLICT (409; currentRevision), EDIT_NO_MATCH (409), EDIT_AMBIGUOUS
            (409), IN_USE (409), CONFIRM_REQUIRED (409), STALE_PUBLISH (409;
            publishedVersion, basedOn, reverted, publishedVersionIsRevert),
            REVISION_REQUIRED (MCP only: a set or remove of an existing resource
            without its revision), NOT_PUBLISHED (409), SCENE_IN_USE (409),
            DRAFT_NOT_SAVED (409), SCENE_OFFLINE (409), SCENE_REFUSED (409),
            INGEST_KEY_REVOKED (409), CAMERA_PULL_GONE (409), SECRETS_FULL
            (409), PRECONDITION_FAILED (412; currentRevision), TOO_LARGE (413),
            UNSUPPORTED_MEDIA_TYPE (415), INVALID_INPUT (422),
            IDEMPOTENCY_KEY_REUSED (422), CHECK_FAILED (422), SCENE_INVALID
            (422), CAMERA_INVALID (422), CAMERA_PRIVATE_ADDRESS (422),
            SECRET_MISSING (422), RATE_LIMITED (429), CAMERA_TEST_BUSY (429),
            INTERNAL (500), NOT_SUPPORTED (501), UNAVAILABLE (502 or 503),
            INGEST_UNAVAILABLE (503), CAMERAS_UNAVAILABLE (503),
            SECRETS_UNAVAILABLE (503), SCENE_TIMEOUT (504)
        detail:
          type: string
          description: What happened and what to do
        errors:
          type: array
          description: Each problem, when there are several (a check's findings)
          items:
            type: object
            properties:
              line:
                type: integer
              path:
                type: string
              node:
                type: string
              message:
                type: string
            additionalProperties: true
        currentRevision:
          type:
            - string
            - 'null'
          description: >-
            CONFLICT / PRECONDITION_FAILED: the resource's revision now; null
            when it no longer exists
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        A Streamloop API key (`sl_…`). It carries no workspace: send
        `X-Workspace-Id` too (400 WORKSPACE_REQUIRED otherwise).
    oauth:
      type: http
      scheme: bearer
      description: >-
        An OAuth access token (as Streamloop's MCP server uses). Each operation
        needs the scope named in its `x-scope`: streamloop:read ⊂
        streamloop:write ⊂ streamloop:destructive (403 INSUFFICIENT_SCOPE).

````

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