{
  "openapi": "3.1.0",
  "info": {
    "title": "Goobi agent onboarding and core production API",
    "version": "2026-10-19",
    "description": "Core subset only. Discover all current operation-specific schemas through capabilities and MCP listTools. Checkout and top-ups may be unavailable. Hosting ingress can require additional access."
  },
  "servers": [
    {
      "url": "https://goobi.ai"
    },
    {
      "url": "https://staging.goobi.ai"
    },
    {
      "url": "http://localhost:3000"
    }
  ],
  "components": {
    "securitySchemes": {
      "ProductionKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "rtx_ production key"
      }
    },
    "schemas": {
      "ProductionObservation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "id",
          "version",
          "fingerprint"
        ],
        "properties": {
          "kind": {
            "enum": [
              "campaign",
              "ugc"
            ]
          },
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{16,100}$"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "fingerprint": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "description": "Exact current owner-selected server observation for a general built-in Agent send only. Metadata context, not action/consent/paid/tool-read authority. Original request replay retains its frozen observation."
      }
    }
  },
  "paths": {
    "/api/v1/agent": {
      "get": {
        "summary": "Public discovery; no spend.",
        "responses": {
          "200": {
            "description": "JSON result"
          },
          "401": {
            "description": "Missing or invalid key, scope or approved Studio access"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/v1/production/account": {
      "get": {
        "summary": "Exact authenticated key scope, subscription/preview status, checkout and top-up availability.",
        "responses": {
          "200": {
            "description": "JSON result"
          },
          "401": {
            "description": "Missing or invalid key, scope or approved Studio access"
          },
          "403": {
            "description": "Access denied"
          }
        },
        "security": [
          {
            "ProductionKey": []
          }
        ]
      }
    },
    "/api/v1/production/capabilities": {
      "get": {
        "summary": "Operation schemas and configured availability; supplier developer permission is checked separately.",
        "responses": {
          "200": {
            "description": "JSON result"
          },
          "401": {
            "description": "Missing or invalid key, scope or approved Studio access"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/v1/production/jobs": {
      "get": {
        "summary": "Owned jobs and recovery list.",
        "responses": {
          "200": {
            "description": "JSON result"
          },
          "401": {
            "description": "Missing or invalid key, scope or approved Studio access"
          },
          "403": {
            "description": "Access denied"
          }
        },
        "security": [
          {
            "ProductionKey": []
          }
        ]
      },
      "post": {
        "summary": "Quote or submit using the exact operation schema. Quotes are free; submissions require explicit approval, stable requestKey, current quote and maximum cost. No automatic retries. Commercial personal quotes include billing.credits and billing.pricingVersion; owner approval must send approvedCredits and pricingVersion. Read credits for actual balance. Unverified commercial rates fail closed.",
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "operation",
                  "input"
                ],
                "properties": {
                  "operation": {
                    "type": "string"
                  },
                  "input": {
                    "type": "object"
                  },
                  "estimateOnly": {
                    "type": "boolean"
                  },
                  "requestKey": {
                    "type": "string",
                    "minLength": 16,
                    "maxLength": 100
                  },
                  "approved": {
                    "type": "boolean"
                  },
                  "inputHash": {
                    "type": "string"
                  },
                  "maxReservationUsd": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote, no provider spend"
          },
          "201": {
            "description": "Job or recovered original job"
          },
          "400": {
            "description": "Validation, provider or allowance failure; inspect code/nextAction and recover original request"
          },
          "401": {
            "description": "Produce scope or approved Studio access required"
          },
          "402": {
            "description": "Current subscription required for new personal paid work in commercial mode"
          },
          "503": {
            "description": "Commerce or provider configuration unavailable"
          }
        }
      }
    },
    "/api/v1/production/jobs/{id}": {
      "get": {
        "summary": "Owned original job status.",
        "responses": {
          "200": {
            "description": "JSON result"
          },
          "401": {
            "description": "Missing or invalid key, scope or approved Studio access"
          },
          "403": {
            "description": "Access denied"
          }
        },
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{16,100}$"
            }
          }
        ]
      }
    },
    "/api/v1/models": {
      "get": {
        "summary": "Template model catalog; renderingAvailable is false for legacy generation.",
        "responses": {
          "200": {
            "description": "JSON result"
          },
          "401": {
            "description": "Missing or invalid key, scope or approved Studio access"
          },
          "403": {
            "description": "Access denied"
          }
        }
      }
    },
    "/api/v1/production/credits": {
      "get": {
        "summary": "Owned subscription balance, reserved and used credits; paginated history. Read only; top-ups unavailable.",
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "parameters": [
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 140
            },
            "description": "Opaque nextCursor returned by the previous response."
          }
        ],
        "responses": {
          "200": {
            "description": "Owned credit snapshot and usage page"
          },
          "401": {
            "description": "Production access required"
          },
          "400": {
            "description": "Invalid cursor or unsupported selector"
          }
        }
      }
    },
    "/api/v1/production/ugc": {
      "get": {
        "summary": "Read owned UGC runs and their canonical jobs. No provider submission.",
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Owned UGC result, current estimate or editable timeline"
          },
          "400": {
            "description": "Invalid, stale or unapproved action; recover original request after uncertainty"
          },
          "401": {
            "description": "Approved production access required"
          },
          "403": {
            "description": "Origin or access denied"
          }
        },
        "description": "Exact owned reads add finishing schema1: independent finishing version, proven canonical timeline/current edit fingerprint, explicit human review, original render state, matching private archives and completion. Reads never assemble, save, refresh providers or infer links from names. Legacy runs remain unlinked until deliberate assembly/recovery."
      },
      "post": {
        "summary": "Save/review one UGC run, explicitly approve one stage, recover an original request or create an editable assembly.",
        "description": "Same-origin produce access required. Maximum body 24KB. Provider and exact service-credit approval are enforced through canonical production jobs. Only submit/recover can admit an already explicitly approved provider request. Native dialogue is not supplied-audio lip sync. Final export requires configured rendering. See UGC_WORKFLOW.md. New runs pin owned reference bytes/settings; optional referenceProfiles selects exact owned profile origins. Echo quote.referenceHash for pinned runs. check-references makes owned reads only. Legacy unpinned runs remain labeled honestly. M4: assemble links an immutable exact-input receipt to the canonical timeline; retries preserve manual edits. recover-assembly reads/links only an existing original edit and cannot rebuild a missing one. review-edit requires explicit human reviewed:true, note, original UUID, exact run/timeline/finishing versions. complete verifies a current reviewed export and owned archived MP4 bytes. Neither action renders or spends. See UGC_WORKFLOW.md.",
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "brief"
                    ],
                    "properties": {
                      "action": {
                        "const": "save"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "brief": {
                        "type": "object",
                        "description": "Reviewed UgcBrief; see UGC_WORKFLOW.md and lib/realitix/ugc.ts."
                      },
                      "referenceProfiles": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "product": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "additionalProperties": false,
                            "required": [
                              "id",
                              "version"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "version": {
                                "type": "integer",
                                "minimum": 1
                              }
                            }
                          },
                          "presenter": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "additionalProperties": false,
                            "required": [
                              "id",
                              "version"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "version": {
                                "type": "integer",
                                "minimum": 1
                              }
                            }
                          },
                          "voice": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "additionalProperties": false,
                            "required": [
                              "id",
                              "version"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "version": {
                                "type": "integer",
                                "minimum": 1
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "stageId"
                    ],
                    "properties": {
                      "action": {
                        "const": "quote"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "stageId": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "stageId",
                      "requestId",
                      "approval"
                    ],
                    "properties": {
                      "action": {
                        "const": "submit"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "stageId": {
                        "type": "string"
                      },
                      "requestId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "approval": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "inputHash",
                          "maxReservationUsd"
                        ],
                        "properties": {
                          "inputHash": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{64}$"
                          },
                          "maxReservationUsd": {
                            "type": "number",
                            "minimum": 0
                          },
                          "approvedCredits": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "pricingVersion": {
                            "type": "string"
                          },
                          "referenceHash": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{64}$",
                            "description": "Required when the stage quote returned this binding to pinned reference bytes/settings."
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "requestId"
                    ],
                    "properties": {
                      "action": {
                        "const": "recover"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "requestId": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "stageId"
                    ],
                    "properties": {
                      "action": {
                        "const": "refresh"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "stageId": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "stageId"
                    ],
                    "properties": {
                      "action": {
                        "const": "accept"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "stageId": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "stageId"
                    ],
                    "properties": {
                      "action": {
                        "const": "retake"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "stageId": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "stageId",
                      "attemptId"
                    ],
                    "properties": {
                      "action": {
                        "const": "select"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "stageId": {
                        "type": "string"
                      },
                      "attemptId": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version"
                    ],
                    "properties": {
                      "action": {
                        "const": "assemble"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 0
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version"
                    ],
                    "properties": {
                      "action": {
                        "const": "check-references"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version"
                    ],
                    "properties": {
                      "action": {
                        "const": "recover-assembly"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "finishingVersion",
                      "timelineVersion",
                      "reviewed",
                      "note",
                      "requestId"
                    ],
                    "properties": {
                      "action": {
                        "const": "review-edit"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "finishingVersion": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "timelineVersion": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "reviewed": {
                        "const": true
                      },
                      "note": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      },
                      "requestId": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "id",
                      "version",
                      "finishingVersion",
                      "exportId"
                    ],
                    "properties": {
                      "action": {
                        "const": "complete"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "finishingVersion": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "exportId": {
                        "type": "string",
                        "minLength": 16,
                        "maxLength": 100
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Owned UGC result, current estimate or editable timeline"
          },
          "400": {
            "description": "Invalid, stale or unapproved action; recover original request after uncertainty"
          },
          "401": {
            "description": "Approved production access required"
          },
          "403": {
            "description": "Origin or access denied"
          }
        }
      }
    },
    "/api/v1/production/ugc-workspace": {
      "get": {
        "summary": "Read owned UGC profiles and current configuration readiness",
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Owned UGC result, current estimate or editable timeline"
          },
          "400": {
            "description": "Invalid, stale or unapproved action; recover original request after uncertainty"
          },
          "401": {
            "description": "Approved production access required"
          },
          "403": {
            "description": "Origin or access denied"
          }
        }
      },
      "post": {
        "summary": "Manage UGC profiles, reviewed draft variants and trusted product metadata intake",
        "description": "Requires produce access and same origin. No action submits generation. Product metadata is unverified and images are not downloaded. Variants are atomic, retain original request IDs after uncertainty, and carry no prior jobs/paid approval. Each new presenter batch requires permission confirmation. Exact trusted public store hosts must be configured by the operator.",
        "security": [
          {
            "ProductionKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "save-profile"
                      },
                      "profile": {
                        "oneOf": [
                          {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "version": {
                                "type": "integer",
                                "minimum": 0
                              },
                              "kind": {
                                "const": "product"
                              },
                              "name": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "data": {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "product": {
                                    "type": "string",
                                    "maxLength": 100
                                  },
                                  "facts": {
                                    "type": "string",
                                    "maxLength": 1600
                                  },
                                  "audience": {
                                    "type": "string",
                                    "maxLength": 200
                                  },
                                  "offer": {
                                    "type": "string",
                                    "maxLength": 200
                                  },
                                  "cta": {
                                    "type": "string",
                                    "maxLength": 160
                                  },
                                  "productImage": {
                                    "type": "string",
                                    "maxLength": 120
                                  }
                                },
                                "required": [
                                  "product",
                                  "facts",
                                  "audience",
                                  "offer",
                                  "cta",
                                  "productImage"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "version",
                              "kind",
                              "name",
                              "data"
                            ]
                          },
                          {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "version": {
                                "type": "integer",
                                "minimum": 0
                              },
                              "kind": {
                                "const": "creator"
                              },
                              "name": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "data": {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "provider": {
                                    "enum": [
                                      "xai",
                                      "minimax"
                                    ]
                                  },
                                  "voice": {
                                    "type": "string",
                                    "maxLength": 80
                                  },
                                  "language": {
                                    "type": "string",
                                    "maxLength": 40
                                  },
                                  "presenterImage": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "presenterConsent": {
                                    "const": true
                                  }
                                },
                                "required": [
                                  "provider",
                                  "voice",
                                  "language",
                                  "presenterImage",
                                  "presenterConsent"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "version",
                              "kind",
                              "name",
                              "data"
                            ]
                          }
                        ]
                      }
                    },
                    "required": [
                      "action",
                      "profile"
                    ]
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "delete-profile"
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      }
                    },
                    "required": [
                      "action",
                      "id",
                      "version"
                    ]
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "variants"
                      },
                      "sourceId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "requestId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "presenterConsent": {
                        "type": "boolean"
                      },
                      "variants": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 6,
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "label": {
                              "type": "string",
                              "maxLength": 80
                            },
                            "hook": {
                              "type": "string",
                              "maxLength": 700
                            },
                            "cta": {
                              "type": "string",
                              "maxLength": 160
                            },
                            "language": {
                              "type": "string",
                              "maxLength": 40
                            }
                          },
                          "required": [
                            "id",
                            "label",
                            "hook",
                            "cta",
                            "language"
                          ]
                        }
                      }
                    },
                    "required": [
                      "action",
                      "sourceId",
                      "version",
                      "requestId",
                      "presenterConsent",
                      "variants"
                    ]
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "action": {
                        "const": "import-product"
                      },
                      "url": {
                        "type": "string",
                        "format": "uri",
                        "maxLength": 2048
                      }
                    },
                    "required": [
                      "action",
                      "url"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Owned UGC result, current estimate or editable timeline"
          },
          "400": {
            "description": "Invalid, stale or unapproved action; recover original request after uncertainty"
          },
          "401": {
            "description": "Approved production access required"
          },
          "403": {
            "description": "Origin or access denied"
          }
        }
      }
    },
    "/api/v1/production/scene-revisions": {
      "get": {
        "operationId": "readProductionScenes",
        "summary": "Read exact owned saved scene text/version/hash; no provider refresh or write.",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ugc",
                "campaign"
              ]
            }
          },
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Private/no-store {source}; see UGC_WORKFLOW.md."
          }
        }
      },
      "post": {
        "operationId": "sceneRevisionAction",
        "summary": "Prepare an immutable scene revision, or explicitly apply its owner-reviewed ID. No generation, consent, acceptance or paid approval.",
        "description": "Production-write access, same origin, exact fields, maximum 5KB. One saved source/scene, exact version/hash; stale/in-flight/unknown originals refuse. UGC retains unchanged compiled stages; campaign creates a separate plan with verified accepted untouched work. Completed target footage retains the existing sampled-review/correction path. Retry the same original ID after uncertainty. See UGC_WORKFLOW.md.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "requestId",
                      "kind",
                      "id",
                      "version",
                      "sourceHash",
                      "sceneId",
                      "script",
                      "direction"
                    ],
                    "properties": {
                      "action": {
                        "const": "propose"
                      },
                      "requestId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "kind": {
                        "type": "string",
                        "enum": [
                          "ugc",
                          "campaign"
                        ]
                      },
                      "id": {
                        "type": "string"
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "sourceHash": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "sceneId": {
                        "type": "string"
                      },
                      "script": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 700
                      },
                      "direction": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 1500
                      }
                    }
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "action",
                      "proposalId"
                    ],
                    "properties": {
                      "action": {
                        "const": "apply"
                      },
                      "proposalId": {
                        "type": "string",
                        "pattern": "^scene-revision-[a-f0-9-]{36}$"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{proposal} (unapplied) or {result} (updated UGC identity/version or separate campaign plan/conversation)."
          }
        }
      }
    }
  },
  "x-selected-production-context": {
    "readRoutes": [
      "/api/v1/production/director/productions?id=ID",
      "/api/v1/production/ugc?id=ID"
    ],
    "sendRoute": "/api/v1/production/director",
    "sendAction": "send",
    "optionalField": "selectedProduction",
    "schema": {
      "$ref": "#/components/schemas/ProductionObservation"
    },
    "description": "See docs/agent-integration.md. Exact observations are revalidated on new general built-in turns; focused/custom/Goal/special-action turns reject. No new execution permission."
  },
  "x-realitix-reference-context": {
    "status": "local M3",
    "ugc": {
      "read": "run.references schema1 is server-authored; legacy runs may lack it",
      "save": "referenceProfiles optionally maps product/presenter/voice to exact owned {id,version}. New runs pin bytes/settings by default.",
      "check": {
        "action": "check-references",
        "id": "RUN_UUID",
        "version": "exact saved integer"
      },
      "approval": "Echo quote.referenceHash as approval.referenceHash in addition to canonical exact cost fields. Recover original IDs after uncertainty.",
      "voiceProfile": "kind voice stores provider/voice/language only; no consent/cloning; MiniMax presenter native voice cannot apply a speech preset."
    },
    "campaign": "Ordinary send campaignReferenceRoles:[{reference,usage:identity|product|setting|style,detail}] must match campaignReferences exactly; planner cannot drop/relabel/add. Frozen recipes carry source hashes.",
    "review": "Reference hashes/roles are metadata wiring, not visual/audio quality review. Use existing distinct-still continuity comparisons; human approvals remain separate.",
    "save": "referenceProfiles optionally maps product/presenter/voice to exact owned {id,version}; null explicitly keeps custom values and clears that saved profile origin. Omitted roles retain unchanged historical origins. New runs pin bytes/settings by default."
  },
  "x-realitix-ugc-finishing": {
    "status": "local M4",
    "association": "Owned ugc-assembly immutable receipt plus independent versioned ugc-finishing record; exact accepted source identity and deterministic canonical edit. Not writable via generic drafts.",
    "states": [
      "unlinked",
      "not-assembled",
      "assembled",
      "edit-changed",
      "reviewed",
      "rendering",
      "export-failed",
      "export-uncertain",
      "completed",
      "unavailable"
    ],
    "review": "Human review is bound to current timeline JSON, source hashes and caption document proof; changes invalidate it. Completion requires a matching current export and verified private MP4 blob/hash.",
    "agent": "General built-in Agent may read and prepare_ugc_edit{id,version,timelineVersion,prompt}; returns an owner-clicked exact-version Clip Agent draft. It cannot accept takes, manufacture consent, mark reviewed/complete, apply, save, render or generate music through this handoff."
  }
}
