{
    "openapi": "3.1.0",
    "info": {
        "title": "API de Processamento de Mídia",
        "version": "v1",
        "description": "Processamento assíncrono de vídeo, imagem e áudio: redimensionar, comprimir, marca d'água, miniaturas, vídeos de curso e faixas de áudio, com callbacks assinados."
    },
    "servers": [
        {
            "url": "https://api.flowdata.one/v1",
            "description": "FlowData API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "pipelines",
            "description": "Pipelines e presets"
        },
        {
            "name": "jobs",
            "description": "Jobs"
        },
        {
            "name": "assets",
            "description": "Marcas d'água"
        },
        {
            "name": "callbacks",
            "description": "Callbacks (webhooks)"
        }
    ],
    "paths": {
        "/media/presets": {
            "get": {
                "operationId": "presets-list",
                "summary": "Listar presets",
                "description": "Todas as pipelines do sistema (system: true) e os presets da sua equipe.",
                "tags": [
                    "pipelines"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "key": "ugc_video",
                                            "system": true,
                                            "pipeline": "ugc_video",
                                            "outputs": [
                                                "watermarked",
                                                "clean",
                                                "thumbnail"
                                            ]
                                        },
                                        {
                                            "key": "ugc_hd",
                                            "system": false,
                                            "name": "UGC in HD",
                                            "pipeline": "ugc_video",
                                            "options": {
                                                "width": 720,
                                                "height": 1280
                                            },
                                            "outputs": {
                                                "clean": {
                                                    "crf": 20
                                                }
                                            },
                                            "updated_at": "2026-09-28T10:00:00Z"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "presets-store",
                "summary": "Criar ou substituir preset",
                "description": "Cria um preset da equipe (201) ou substitui um com a mesma chave (200). Nomes do sistema são reservados.",
                "tags": [
                    "pipelines"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "key": "ugc_hd",
                                    "system": false,
                                    "name": "UGC in HD",
                                    "pipeline": "ugc_video",
                                    "options": {
                                        "width": 720,
                                        "height": 1280,
                                        "watermark": {
                                            "asset": "brand_white",
                                            "opacity": 0.3
                                        }
                                    },
                                    "outputs": {
                                        "clean": {
                                            "crf": 20
                                        }
                                    },
                                    "updated_at": "2026-09-28T10:00:00Z"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "1 a 64 caracteres de a-z, 0-9, _ e -"
                                    },
                                    "name": {
                                        "type": "string",
                                        "description": "Rótulo, no máximo 191 caracteres"
                                    },
                                    "pipeline": {
                                        "type": "string",
                                        "description": "Pipeline base, por exemplo ugc_video"
                                    },
                                    "options": {
                                        "type": "object",
                                        "description": "Opções para todas as saídas, inclusive watermark"
                                    },
                                    "outputs": {
                                        "type": "object",
                                        "description": "Sobrescritas por nome de saída"
                                    }
                                },
                                "required": [
                                    "key",
                                    "pipeline"
                                ]
                            },
                            "example": {
                                "key": "ugc_hd",
                                "name": "UGC in HD",
                                "pipeline": "ugc_video",
                                "options": {
                                    "width": 720,
                                    "height": 1280,
                                    "watermark": {
                                        "asset": "brand_white",
                                        "opacity": 0.3
                                    }
                                },
                                "outputs": {
                                    "clean": {
                                        "crf": 20
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/presets/{key}": {
            "delete": {
                "operationId": "presets-delete",
                "summary": "Excluir preset",
                "description": "Exclui um preset da equipe. Jobs já criados não são afetados, pois têm uma cópia das configurações.",
                "tags": [
                    "pipelines"
                ],
                "parameters": [
                    {
                        "name": "key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "deleted": true,
                                    "key": "ugc_hd"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/jobs": {
            "post": {
                "operationId": "jobs-create",
                "summary": "Criar job",
                "description": "Cria um job e responde com 202 e queue_position. Exatamente um entre pipeline e preset, exatamente um entre input.url e input.upload_id, para cada saída exatamente um entre put_url e managed: true. Todas as URLs devem ser https e apontar para endereços públicos.",
                "tags": [
                    "jobs"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4RD",
                                    "status": "queued",
                                    "pipeline": "ugc_video",
                                    "reference": "orderfile:12345",
                                    "priority": "normal",
                                    "outputs": {
                                        "watermarked": {
                                            "status": "pending",
                                            "target": "put"
                                        },
                                        "clean": {
                                            "status": "pending",
                                            "target": "managed",
                                            "download_url": null,
                                            "expires_at": null
                                        },
                                        "thumbnail": {
                                            "status": "pending",
                                            "target": "put"
                                        }
                                    },
                                    "error": null,
                                    "queue_position": 1
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "pipeline": {
                                        "type": "string",
                                        "description": "Pipeline do sistema (ver tabela), alternativa ao preset"
                                    },
                                    "preset": {
                                        "type": "string",
                                        "description": "Chave de um preset da equipe, alternativa à pipeline"
                                    },
                                    "reference": {
                                        "type": "string",
                                        "description": "Sua referência própria (no máximo 191 caracteres), consultável em GET /jobs?reference="
                                    },
                                    "priority": {
                                        "type": "string",
                                        "description": "high, normal (padrão) ou low; course_video é low por padrão"
                                    },
                                    "input": {
                                        "type": "object",
                                        "properties": {
                                            "url": {
                                                "type": "string",
                                                "description": "URL https pública da origem, até 3 redirecionamentos"
                                            },
                                            "upload_id": {
                                                "type": "string",
                                                "description": "ID de POST /uploads, usável uma vez"
                                            },
                                            "filename": {
                                                "type": "string",
                                                "description": "Nome original do arquivo (apenas exibição)"
                                            },
                                            "size": {
                                                "type": "integer",
                                                "description": "Tamanho em bytes; verificado antes contra o limite e melhora a reserva de custo"
                                            }
                                        }
                                    },
                                    "outputs": {
                                        "type": "object",
                                        "properties": {
                                            "<name>.put_url": {
                                                "type": "string",
                                                "description": "URL de PUT pré-assinada para o resultado"
                                            },
                                            "<name>.managed": {
                                                "type": "boolean",
                                                "description": "true: guardamos o resultado por 7 dias"
                                            },
                                            "<name>.content_type": {
                                                "type": "string",
                                                "description": "Content-Type do PUT, padrão conforme o formato"
                                            },
                                            "<name>.*": {
                                                "type": "object",
                                                "description": "Sobrescritas como width, height, fit, crf, format, quality, watermark"
                                            }
                                        }
                                    },
                                    "options": {
                                        "type": "object",
                                        "description": "Opções para todas as saídas, inclusive watermark.asset"
                                    },
                                    "callback": {
                                        "type": "object",
                                        "properties": {
                                            "endpoint_id": {
                                                "type": "string",
                                                "description": "ID de um endpoint de webhook registrado"
                                            },
                                            "url": {
                                                "type": "string",
                                                "description": "URL https livre; assinada com o segredo do endpoint padrão, senão sem assinatura"
                                            },
                                            "events": {
                                                "type": "array",
                                                "items": [],
                                                "description": "job.finished e/ou job.failed (padrão: ambos)"
                                            }
                                        }
                                    },
                                    "metadata": {
                                        "type": "object",
                                        "description": "Qualquer JSON até 4 KB, volta inalterado no callback"
                                    }
                                }
                            },
                            "example": {
                                "pipeline": "ugc_video",
                                "reference": "orderfile:12345",
                                "input": {
                                    "url": "https://files.example.com/in/abc.mov?X-Amz-Signature=…",
                                    "filename": "abc.mov"
                                },
                                "outputs": {
                                    "watermarked": {
                                        "put_url": "https://uploads.example.com/out/wm.mp4?X-Amz-Signature=…"
                                    },
                                    "clean": {
                                        "managed": true
                                    },
                                    "thumbnail": {
                                        "put_url": "https://uploads.example.com/out/thumb.jpg?X-Amz-Signature=…"
                                    }
                                },
                                "options": {
                                    "watermark": {
                                        "asset": "brand_white"
                                    }
                                },
                                "callback": {
                                    "endpoint_id": "01J8Z6Q4T0M3S1V7B2X9K5N4WH"
                                },
                                "metadata": {
                                    "entity": "order_file"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "operationId": "jobs-by-reference",
                "summary": "Buscar jobs por referência",
                "description": "Os até 20 jobs mais recentes com esta reference.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "reference",
                        "in": "query",
                        "required": true,
                        "description": "Sua referência de POST /jobs",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": "01J8Z6Q4T0M3S1V7B2X9K5N4RD",
                                            "status": "finished",
                                            "pipeline": "ugc_video",
                                            "preset": null,
                                            "reference": "orderfile:12345",
                                            "priority": "normal",
                                            "created_at": "2026-09-28T10:00:00Z",
                                            "started_at": "2026-09-28T10:00:02Z",
                                            "finished_at": "2026-09-28T10:00:31Z",
                                            "input": {
                                                "size": 48211234,
                                                "duration": 27.4,
                                                "width": 1080,
                                                "height": 1920,
                                                "video_codec": "hevc",
                                                "has_audio": true
                                            },
                                            "outputs": {
                                                "watermarked": {
                                                    "status": "uploaded",
                                                    "target": "put",
                                                    "size": 6123456,
                                                    "width": 540,
                                                    "height": 960,
                                                    "duration": 27.4,
                                                    "sha256": "9f2c…"
                                                },
                                                "clean": {
                                                    "status": "uploaded",
                                                    "target": "managed",
                                                    "size": 6101234,
                                                    "width": 540,
                                                    "height": 960,
                                                    "duration": 27.4,
                                                    "sha256": "4b1a…",
                                                    "download_url": "https://…",
                                                    "expires_at": "2026-10-05T10:00:31Z"
                                                }
                                            },
                                            "options": {
                                                "watermark": {
                                                    "asset": "brand_white",
                                                    "asset_sha256": "c0ff…"
                                                }
                                            },
                                            "error": null,
                                            "processing_seconds": 28.6,
                                            "cancel_requested": false
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/jobs/{job_id}": {
            "get": {
                "operationId": "jobs-show",
                "summary": "Consultar job",
                "description": "Retorna o job no mesmo formato do callback. Em saídas managed, download_url traz um link assinado válido até expires_at.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "job_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4RD",
                                    "status": "finished",
                                    "pipeline": "ugc_video",
                                    "preset": null,
                                    "reference": "orderfile:12345",
                                    "priority": "normal",
                                    "created_at": "2026-09-28T10:00:00Z",
                                    "started_at": "2026-09-28T10:00:02Z",
                                    "finished_at": "2026-09-28T10:00:31Z",
                                    "input": {
                                        "size": 48211234,
                                        "duration": 27.4,
                                        "width": 1080,
                                        "height": 1920,
                                        "video_codec": "hevc",
                                        "has_audio": true
                                    },
                                    "outputs": {
                                        "watermarked": {
                                            "status": "uploaded",
                                            "target": "put",
                                            "size": 6123456,
                                            "width": 540,
                                            "height": 960,
                                            "duration": 27.4,
                                            "sha256": "9f2c…"
                                        },
                                        "clean": {
                                            "status": "uploaded",
                                            "target": "managed",
                                            "size": 6101234,
                                            "width": 540,
                                            "height": 960,
                                            "duration": 27.4,
                                            "sha256": "4b1a…",
                                            "download_url": "https://…",
                                            "expires_at": "2026-10-05T10:00:31Z"
                                        }
                                    },
                                    "options": {
                                        "watermark": {
                                            "asset": "brand_white",
                                            "asset_sha256": "c0ff…"
                                        }
                                    },
                                    "error": null,
                                    "processing_seconds": 28.6,
                                    "cancel_requested": false
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "jobs-cancel",
                "summary": "Cancelar job",
                "description": "Um job em espera vira cancelled imediatamente (sem callback, a reserva é liberada). Um job em andamento recebe um pedido de cancelamento (cancel_requested: true), o worker para em poucos segundos e informa job.failed com error.code = cancelled. Um job encerrado gera 409 conflict.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "job_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4RD",
                                    "status": "cancelled",
                                    "error": null,
                                    "cancel_requested": false
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/uploads": {
            "post": {
                "operationId": "uploads-create",
                "summary": "Criar upload direto",
                "description": "Para origens sem URL pública: retorna uma URL de PUT pré-assinada no nosso armazenamento. Envie o arquivo para lá e depois use como input.upload_id. Válido por 24 horas, usável uma vez. Por equipe, no máximo oito uploads diretos e 10 GB de tamanho declarado ficam abertos ao mesmo tempo. Um upload continua contando depois de atribuído a um job, até a linha ser removida.",
                "tags": [
                    "jobs"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4UP",
                                    "upload_url": "https://…",
                                    "method": "PUT",
                                    "headers": {
                                        "Content-Type": "video/mp4",
                                        "Content-Length": "734003200"
                                    },
                                    "expires_at": "2026-09-29T10:00:00Z"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "filename": {
                                        "type": "string",
                                        "description": "Nome do arquivo, no máximo 255 caracteres"
                                    },
                                    "size": {
                                        "type": "integer",
                                        "description": "Tamanho em bytes, obrigatório. A URL de PUT pré-assinada assina exatamente este Content-Length; um corpo maior é rejeitado pelo armazenamento."
                                    },
                                    "content_type": {
                                        "type": "string",
                                        "description": "Content-Type que deve ser enviado no PUT"
                                    }
                                },
                                "required": [
                                    "size"
                                ]
                            },
                            "example": {
                                "filename": "kurs-01.mp4",
                                "size": 734003200,
                                "content_type": "video/mp4"
                            }
                        }
                    }
                }
            }
        },
        "/media/usage": {
            "get": {
                "operationId": "usage",
                "summary": "Consultar uso",
                "description": "Jobs, falhas, tempo de processamento e volume de entrada no período (padrão: mês atual). Custos e saldo aparecem no dashboard em Faturamento.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "required": false,
                        "description": "Data inicial AAAA-MM-DD",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "required": false,
                        "description": "Data final AAAA-MM-DD",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "from": "2026-09-01",
                                    "to": "2026-09-30",
                                    "jobs": 2143,
                                    "failed": 12,
                                    "processing_seconds": 61234.5,
                                    "input_bytes": 98765432100,
                                    "by_pipeline": {
                                        "ugc_video": 2051,
                                        "ugc_image": 92
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/health": {
            "get": {
                "operationId": "health",
                "summary": "Status",
                "description": "Sem autenticação. ok, degraded (manutenção ou processamento de imagem limitado) ou down, além do tamanho da fila.",
                "tags": [
                    "jobs"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "status": "ok",
                                    "queue": {
                                        "pending": 3,
                                        "processing": 4
                                    },
                                    "version": "1.0.0"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/assets/{key}": {
            "put": {
                "operationId": "assets-put",
                "summary": "Enviar marca d'água",
                "description": "Corpo como PNG bruto (Content-Type: image/png) ou multipart com o campo file. Responde 201 para uma chave nova, 200 para uma nova versão.",
                "tags": [
                    "assets"
                ],
                "parameters": [
                    {
                        "name": "key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "key": "brand_white",
                                    "sha256": "c0ffee…",
                                    "width": 800,
                                    "height": 200,
                                    "size": 18234,
                                    "updated_at": "2026-09-28T10:00:00Z"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "PNG com canal alfa, no máximo 2 MB"
                                    }
                                },
                                "required": [
                                    "file"
                                ]
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "assets-post",
                "summary": "Enviar marca d'água (POST)",
                "description": "Igual ao PUT, para clientes que só enviam multipart com POST.",
                "tags": [
                    "assets"
                ],
                "parameters": [
                    {
                        "name": "key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "key": "brand_white",
                                    "sha256": "c0ffee…",
                                    "width": 800,
                                    "height": 200,
                                    "size": 18234,
                                    "updated_at": "2026-09-28T10:00:00Z"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "PNG com canal alfa, no máximo 2 MB"
                                    }
                                },
                                "required": [
                                    "file"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/media/assets": {
            "get": {
                "operationId": "assets-list",
                "summary": "Listar marcas d'água",
                "description": "Todas as marcas d'água da sua equipe com a versão atual.",
                "tags": [
                    "assets"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "key": "brand_white",
                                            "sha256": "c0ffee…",
                                            "width": 800,
                                            "height": 200,
                                            "size": 18234,
                                            "updated_at": "2026-09-28T10:00:00Z"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/webhook-endpoints": {
            "get": {
                "operationId": "webhook-endpoints-list",
                "summary": "Listar endpoints",
                "description": "Todos os endpoints da sua equipe, sem o segredo.",
                "tags": [
                    "callbacks"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": "01J8Z6Q4T0M3S1V7B2X9K5N4WH",
                                            "url": "https://example.com/hooks/media",
                                            "description": null,
                                            "events": [
                                                "job.finished",
                                                "job.failed"
                                            ],
                                            "is_default": true,
                                            "active": true,
                                            "previous_secret_expires_at": null,
                                            "created_at": "2026-09-28T10:00:00Z"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "webhook-endpoints-create",
                "summary": "Criar endpoint",
                "description": "Cria um endpoint e retorna o segredo uma única vez no campo secret. is_default: true retira a marcação de outro endpoint.",
                "tags": [
                    "callbacks"
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4WH",
                                    "url": "https://example.com/hooks/media",
                                    "events": [
                                        "job.finished",
                                        "job.failed"
                                    ],
                                    "is_default": true,
                                    "active": true,
                                    "secret": "whsec_BEISPIEL00000000000000000000000"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "description": "URL https pública"
                                    },
                                    "events": {
                                        "type": "array",
                                        "items": [],
                                        "description": "job.finished e/ou job.failed (padrão: ambos)"
                                    },
                                    "description": {
                                        "type": "string",
                                        "description": "No máximo 191 caracteres"
                                    },
                                    "is_default": {
                                        "type": "boolean",
                                        "description": "Também assina callback.url livre"
                                    }
                                },
                                "required": [
                                    "url"
                                ]
                            },
                            "example": {
                                "url": "https://example.com/hooks/media",
                                "events": [
                                    "job.finished",
                                    "job.failed"
                                ],
                                "is_default": true
                            }
                        }
                    }
                }
            }
        },
        "/media/webhook-endpoints/{endpoint_id}/rotate-secret": {
            "post": {
                "operationId": "webhook-endpoints-rotate",
                "summary": "Renovar segredo",
                "description": "Cria um novo segredo e o retorna uma vez. O antigo continua assinando por 24 horas (previous_secret_expires_at).",
                "tags": [
                    "callbacks"
                ],
                "parameters": [
                    {
                        "name": "endpoint_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4WH",
                                    "previous_secret_expires_at": "2026-09-29T10:00:00Z",
                                    "secret": "whsec_…"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/media/webhook-endpoints/{endpoint_id}": {
            "delete": {
                "operationId": "webhook-endpoints-delete",
                "summary": "Excluir endpoint",
                "description": "Exclui o endpoint. Entregas abertas para ele são abandonadas.",
                "tags": [
                    "callbacks"
                ],
                "parameters": [
                    {
                        "name": "endpoint_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resposta bem-sucedida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                },
                                "example": {
                                    "deleted": true,
                                    "id": "01J8Z6Q4T0M3S1V7B2X9K5N4WH"
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "Resposta de erro",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Chave FlowData como Authorization: Bearer fd_…"
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            },
                            "details": {
                                "type": "object"
                            }
                        }
                    }
                }
            }
        }
    }
}