{
  "openapi": "3.1.0",
  "info": {
    "title": "AI Video Detector API",
    "version": "1.0.0",
    "description": "Pass a publicly accessible video URL to create an asynchronous video_ai detection. The original URL is used directly; source videos are not stored. Up to ten tokens per account. All /api/v1 calls share one admitted request per second, independent of task concurrency. Registered users can create jobs; subscription, gifted and purchased credits are eligible, consumed in that order. API results have no storage-count quota and do not consume website video capacity. Results are retained for six calendar months after a task ends. The dashboard displays the latest 10,000 records, defaulting to 100 per page; older unexpired results remain readable by ID. Request logs only include submissions, cancellations and authenticated failures; successful reads are not logged. Each account retains at most 200 entries from the past three days, with 50 per page; charge, refund and deduplication records are retained independently long term."
  },
  "servers": [
    {
      "url": "https://videodetector.org/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/account": {
      "get": {
        "summary": "Read account eligibility, credits, concurrency and API history policy",
        "operationId": "get_account",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "default": {
            "description": "API error; inspect error.code and request_id. 429 includes Retry-After seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/video-detections": {
      "post": {
        "summary": "Create an asynchronous detection from a video URL",
        "operationId": "post_video_detections",
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Detection"
                }
              }
            }
          },
          "default": {
            "description": "API error; inspect error.code and request_id. 429 includes Retry-After seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Video URL inaccessible, missing byte-range support or validator, changed content, or invalid video format/duration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{1,128}$"
            },
            "description": "Reuse exactly the same key and payload after a timeout. Keys are scoped to account, service and operation, survive token rotation, and cannot recreate expired resources."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DetectionInput"
              },
              "example": {
                "input": {
                  "type": "url",
                  "url": "https://media.example.com/video.mp4"
                },
                "client_reference": "order-123"
              }
            }
          }
        }
      },
      "get": {
        "summary": "Read up to 25 owned detections",
        "operationId": "get_video_detections",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Detection"
                      }
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "API error; inspect error.code and request_id. 429 includes Retry-After seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated detection UUIDs, maximum 25."
          }
        ]
      }
    },
    "/video-detections/{id}": {
      "get": {
        "summary": "Read one retained detection",
        "operationId": "get_video_detections_id",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Detection"
                }
              }
            }
          },
          "default": {
            "description": "API error; inspect error.code and request_id. 429 includes Retry-After seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/video-detections/{id}/cancel": {
      "post": {
        "summary": "Cancel a queued job; release reservation once",
        "operationId": "post_video_detections_id_cancel",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Detection"
                }
              }
            }
          },
          "default": {
            "description": "API error; inspect error.code and request_id. 429 includes Retry-After seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/video-detections/{id}/evidence": {
      "get": {
        "summary": "Read up to 50 evidence entries; times are in seconds",
        "operationId": "get_video_detections_id_evidence",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Evidence"
                }
              }
            }
          },
          "default": {
            "description": "API error; inspect error.code and request_id. 429 includes Retry-After seconds.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,6}$"
            },
            "description": "Use next_cursor from the previous response."
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Permanent avd_ token, available in /developer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retry_after_ms": {
                "type": "integer"
              }
            }
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": ["error", "request_id"]
      },
      "DetectionInput": {
        "type": "object",
        "properties": {
          "input": {
            "type": "object",
            "properties": {
              "type": {
                "const": "url"
              },
              "url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048,
                "description": "Public HTTP(S) direct video URL with public IPv4 DNS and standard port; no redirects or custom headers. Range 206, Content-Length and strong ETag or Last-Modified required. Keep URL valid and contents unchanged until completion. Maximum 400,000,000 bytes and 1,800 seconds."
              }
            },
            "required": ["type", "url"],
            "additionalProperties": false
          },
          "client_reference": {
            "type": "string",
            "maxLength": 128
          }
        },
        "required": ["input"],
        "additionalProperties": false
      },
      "Detection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "service": {
            "const": "video_ai"
          },
          "status": {
            "enum": [
              "queued",
              "processing",
              "succeeded",
              "failed",
              "timed_out",
              "cancelled"
            ]
          },
          "client_reference": {
            "type": ["string", "null"]
          },
          "input": {
            "type": "object",
            "properties": {
              "duration_seconds": {
                "type": "number"
              }
            }
          },
          "billing": {
            "type": "object",
            "properties": {
              "state": {
                "enum": ["held", "charged", "released"]
              },
              "held_credits": {
                "type": "integer"
              },
              "charged_credits": {
                "type": "integer"
              }
            }
          },
          "result": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Result"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "started_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "completed_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "expires_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": ["id", "service", "status", "billing", "result"]
      },
      "Result": {
        "type": "object",
        "properties": {
          "schema_version": {
            "const": "1"
          },
          "verdict": {
            "type": "string",
            "enum": ["suspected_ai", "not_detected", "unknown"]
          },
          "visual": {
            "type": "object",
            "properties": {
              "verdict": {
                "type": "string",
                "enum": ["suspected_ai", "not_detected", "unknown"]
              },
              "returned_frame_count": {
                "type": "integer"
              },
              "matched_returned_frame_count": {
                "type": "integer"
              }
            }
          },
          "audio": {
            "type": "object",
            "properties": {
              "verdict": {
                "type": "string",
                "enum": ["suspected_ai", "not_detected", "unknown"]
              },
              "reason": {
                "type": "string"
              }
            }
          },
          "metadata": {
            "type": "object",
            "properties": {
              "ai_marker_detected": {
                "type": ["boolean", "null"]
              }
            }
          }
        }
      },
      "Evidence": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "const": "frame"
                    },
                    "offset_seconds": {
                      "type": ["number", "null"]
                    },
                    "labels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "provider_label": {
                            "type": "string"
                          },
                          "provider_confidence": {
                            "type": ["number", "null"]
                          }
                        }
                      }
                    }
                  }
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "const": "audio"
                    },
                    "start_seconds": {
                      "type": ["number", "null"]
                    },
                    "end_seconds": {
                      "type": ["number", "null"]
                    },
                    "provider_labels": {
                      "type": ["string", "null"]
                    }
                  }
                }
              ]
            }
          },
          "next_cursor": {
            "type": ["string", "null"]
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "entitled_until": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "qps": {
            "const": 1
          },
          "token_expires_at": {
            "type": "null"
          },
          "credits": {
            "type": "object",
            "properties": {
              "subscription": {
                "type": "integer"
              },
              "gift": {
                "type": "integer"
              },
              "purchased": {
                "type": "integer"
              },
              "available": {
                "type": "integer"
              },
              "held": {
                "type": "integer"
              }
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "concurrency": {
                "type": "integer"
              },
              "unfinished": {
                "type": "integer"
              },
              "max_unfinished": {
                "type": "integer"
              },
              "storage_limit": {
                "type": "null",
                "description": "No API storage-count quota. API results do not consume website video slots."
              },
              "history_display_limit": {
                "type": "integer",
                "const": 10000
              },
              "result_retention_months": {
                "type": "integer",
                "const": 6
              },
              "request_log_retention_days": {
                "type": "integer",
                "const": 3
              },
              "request_log_limit": {
                "type": "integer",
                "const": 200
              },
              "request_log_page_size": {
                "type": "integer",
                "const": 50
              }
            }
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      }
    }
  }
}
