{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Turn a finished livestream into a VOD. The server concatenates the MUXL segments it recorded for the livestream into a single content blob, derives the playback sidecars, and publishes the place.stream.media.track records. Processing completes server-side and creates a draft VOD; the client does not need to poll or publish — the user publishes the draft later via place.stream.vod.publishDraft. Returns the draft's ats:// URI so the client can navigate to it, alongside an uploadId for backwards compatibility.",
      "errors": [
        {
          "description": "No livestream with the given URI is known, or it does not belong to the authenticated user.",
          "name": "LivestreamNotFound"
        },
        {
          "description": "The livestream has no recorded MUXL segments to finalize (recording was not enabled, or none completed).",
          "name": "NoRecording"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "livestream": {
              "description": "AT-URI of the place.stream.livestream record to finalize into a VOD. Must belong to the authenticated user.",
              "format": "at-uri",
              "type": "string"
            }
          },
          "required": [
            "livestream"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "draftUri": {
              "description": "The ats:// URI of the draft VOD created for this finalize. The draft reaches status 'ready' when processing completes; the user publishes it from the Drafts tab via place.stream.vod.publishDraft.",
              "type": "string"
            },
            "uploadId": {
              "description": "Identifier for the finalize job. Retained for backwards compatibility; the draft flow no longer requires the client to poll getUploadStatus.",
              "type": "string"
            }
          },
          "required": [
            "uploadId",
            "draftUri"
          ],
          "type": "object"
        }
      },
      "parameters": null,
      "type": "procedure"
    }
  },
  "id": "place.stream.media.finalizeLivestream",
  "lexicon": 1
}
