{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/kinopipe-com/json-schema/kinopipe-com-job-request-schema.json",
  "title": "JobRequest",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/kinopipe-com-openapi.json#/components/schemas/JobRequest",
  "type": "object",
  "required": [
    "inputs"
  ],
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 120,
      "default": "Untitled job"
    },
    "inputs": {
      "type": "array",
      "minItems": 1,
      "maxItems": 6,
      "description": "Named HTTP(S) media inputs. Use a public URL or mediaUrl from the direct upload endpoint. The first input must use the ID main and every ID must be unique.",
      "items": {
        "$ref": "#/$defs/MediaInput"
      }
    },
    "operations": {
      "type": "array",
      "maxItems": 12,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/TrimOperation"
          },
          {
            "$ref": "#/$defs/ResizeOperation"
          },
          {
            "$ref": "#/$defs/ThumbnailOperation"
          },
          {
            "$ref": "#/$defs/SubtitlesOperation"
          },
          {
            "$ref": "#/$defs/ConcatOperation"
          },
          {
            "$ref": "#/$defs/WatermarkOperation"
          },
          {
            "$ref": "#/$defs/PictureInPictureOperation"
          },
          {
            "$ref": "#/$defs/AddAudioOperation"
          },
          {
            "$ref": "#/$defs/CropOperation"
          },
          {
            "$ref": "#/$defs/GifOperation"
          },
          {
            "$ref": "#/$defs/RemoveAudioOperation"
          },
          {
            "$ref": "#/$defs/SplitOperation"
          },
          {
            "$ref": "#/$defs/OverlayPosition"
          }
        ]
      },
      "default": []
    },
    "output": {
      "$ref": "#/$defs/Output"
    },
    "webhook": {
      "$ref": "#/$defs/Webhook"
    },
    "maxCredits": {
      "type": "integer",
      "minimum": 1,
      "maximum": 720,
      "description": "Optional hard ceiling for billable credits. An edit is billed the greater of rounded-up worker seconds or rounded-up 6 MiB output units. An analysis is billed one credit per started minute of the media it reads, so the ceiling caps how long the input may be and is checked before the work starts. The full amount is reserved before enqueue and unused credits are refunded after success."
    }
  },
  "$defs": {
    "AddAudioOperation": {
      "type": "object",
      "required": [
        "type",
        "input"
      ],
      "properties": {
        "type": {
          "const": "add_audio"
        },
        "input": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]*$",
          "maxLength": 40
        },
        "mode": {
          "type": "string",
          "enum": [
            "mix",
            "replace"
          ],
          "default": "mix"
        },
        "musicVolume": {
          "type": "number",
          "minimum": 0,
          "maximum": 2,
          "default": 0.3
        },
        "sourceVolume": {
          "type": "number",
          "minimum": 0,
          "maximum": 2,
          "default": 1
        },
        "loop": {
          "type": "boolean",
          "default": true
        }
      }
    },
    "ConcatOperation": {
      "type": "object",
      "required": [
        "type",
        "inputs"
      ],
      "properties": {
        "type": {
          "const": "concat"
        },
        "inputs": {
          "type": "array",
          "minItems": 2,
          "maxItems": 6,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]*$",
            "maxLength": 40
          }
        },
        "width": {
          "type": "integer",
          "minimum": 16,
          "maximum": 4096,
          "default": 1280
        },
        "height": {
          "type": "integer",
          "minimum": 16,
          "maximum": 4096,
          "default": 720
        }
      }
    },
    "CropOperation": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "crop"
        },
        "aspectRatio": {
          "type": "string",
          "enum": [
            "9:16",
            "1:1",
            "4:5",
            "16:9"
          ],
          "default": "9:16"
        },
        "focus": {
          "type": "string",
          "enum": [
            "center",
            "top",
            "bottom",
            "left",
            "right"
          ],
          "default": "center"
        }
      }
    },
    "GifOperation": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "gif"
        },
        "fps": {
          "type": "integer",
          "minimum": 5,
          "maximum": 30,
          "default": 15
        },
        "width": {
          "type": "integer",
          "minimum": 160,
          "maximum": 1280,
          "default": 640
        },
        "maxColors": {
          "type": "integer",
          "minimum": 32,
          "maximum": 256,
          "default": 256
        }
      }
    },
    "MediaInput": {
      "type": "object",
      "required": [
        "id",
        "url"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]*$",
          "maxLength": 40,
          "description": "A stable name used by operations to reference this input."
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "A public HTTP(S) URL or the mediaUrl returned by POST /api/v1/uploads."
        },
        "filename": {
          "type": "string",
          "maxLength": 180
        }
      }
    },
    "Output": {
      "type": "object",
      "properties": {
        "format": {
          "type": "string",
          "enum": [
            "mp4",
            "webm",
            "mp3",
            "wav",
            "jpg",
            "webp",
            "gif"
          ],
          "default": "mp4"
        },
        "quality": {
          "type": "string",
          "enum": [
            "fast",
            "balanced",
            "quality"
          ],
          "default": "balanced"
        }
      }
    },
    "OverlayPosition": {
      "type": "string",
      "enum": [
        "top-left",
        "top-right",
        "bottom-left",
        "bottom-right",
        "center"
      ],
      "default": "bottom-right"
    },
    "PictureInPictureOperation": {
      "type": "object",
      "required": [
        "type",
        "input"
      ],
      "properties": {
        "type": {
          "const": "picture_in_picture"
        },
        "input": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]*$",
          "maxLength": 40
        },
        "position": {
          "$ref": "#/$defs/OverlayPosition"
        },
        "width": {
          "type": "integer",
          "minimum": 64,
          "maximum": 2048,
          "default": 360
        },
        "margin": {
          "type": "integer",
          "minimum": 0,
          "maximum": 512,
          "default": 24
        }
      }
    },
    "RemoveAudioOperation": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "remove_audio"
        }
      }
    },
    "ResizeOperation": {
      "type": "object",
      "required": [
        "type",
        "width",
        "height"
      ],
      "properties": {
        "type": {
          "const": "resize"
        },
        "width": {
          "type": "integer",
          "minimum": 16,
          "maximum": 4096
        },
        "height": {
          "type": "integer",
          "minimum": 16,
          "maximum": 4096
        },
        "fit": {
          "type": "string",
          "enum": [
            "cover",
            "contain"
          ],
          "default": "cover"
        }
      }
    },
    "SplitOperation": {
      "type": "object",
      "required": [
        "type",
        "segmentDuration"
      ],
      "properties": {
        "type": {
          "const": "split"
        },
        "segmentDuration": {
          "type": "number",
          "minimum": 1,
          "maximum": 3600
        },
        "maxSegments": {
          "type": "integer",
          "minimum": 2,
          "maximum": 50,
          "default": 50
        }
      }
    },
    "SubtitlesOperation": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "subtitles"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "A public HTTP(S) SRT or WebVTT URL."
        },
        "input": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]*$",
          "maxLength": 40,
          "description": "ID of a named SRT or WebVTT input."
        }
      },
      "oneOf": [
        {
          "required": [
            "url"
          ]
        },
        {
          "required": [
            "input"
          ]
        }
      ]
    },
    "ThumbnailOperation": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "thumbnail"
        }
      }
    },
    "TrimOperation": {
      "type": "object",
      "required": [
        "type",
        "start"
      ],
      "properties": {
        "type": {
          "const": "trim"
        },
        "start": {
          "type": "number",
          "minimum": 0,
          "maximum": 86400
        },
        "end": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 86400
        }
      }
    },
    "WatermarkOperation": {
      "type": "object",
      "required": [
        "type",
        "input"
      ],
      "properties": {
        "type": {
          "const": "watermark"
        },
        "input": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]*$",
          "maxLength": 40
        },
        "position": {
          "$ref": "#/$defs/OverlayPosition"
        },
        "width": {
          "type": "integer",
          "minimum": 16,
          "maximum": 2048,
          "default": 240
        },
        "opacity": {
          "type": "number",
          "minimum": 0.05,
          "maximum": 1,
          "default": 0.85
        },
        "margin": {
          "type": "integer",
          "minimum": 0,
          "maximum": 512,
          "default": 24
        }
      }
    },
    "Webhook": {
      "type": "object",
      "required": [
        "url",
        "secret"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "A public HTTPS endpoint using the default port."
        },
        "secret": {
          "type": "string",
          "minLength": 16,
          "maxLength": 256,
          "writeOnly": true,
          "description": "Used to sign X-KinoPipe-Signature with HMAC-SHA256."
        },
        "events": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2,
          "items": {
            "type": "string",
            "enum": [
              "job.succeeded",
              "job.failed"
            ]
          },
          "default": [
            "job.succeeded",
            "job.failed"
          ]
        }
      }
    }
  }
}