{
  "openapi": "3.1.0",
  "info": {
    "title": "AutoPersonify Developer API",
    "version": "1.0.0",
    "description": "Make AI presenter videos with a stock presenter or your own digital twin. Full guide: https://autopersonify.com/developers.md"
  },
  "servers": [
    {
      "url": "https://autopersonify.com/api/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "summary": "Account, plan and remaining minutes",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/presenters": {
      "get": {
        "summary": "List presenters",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/twins": {
      "get": {
        "summary": "List the account's twins",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/voices": {
      "get": {
        "summary": "List the user's own starred voices",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/videos": {
      "get": {
        "summary": "List recent videos",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50
            }
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create a video",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "script"
                ],
                "properties": {
                  "script": {
                    "type": "string",
                    "maxLength": 3000
                  },
                  "presenter_id": {
                    "type": "string"
                  },
                  "twin_id": {
                    "type": "string"
                  },
                  "voice_id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "webhook_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "idempotency_key": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Video"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/videos/{id}": {
      "get": {
        "summary": "Get a video",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Video"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "summary": "Delete a video",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "ap_live_… key"
      }
    },
    "schemas": {
      "Video": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "rendering",
              "ready",
              "failed"
            ]
          },
          "progress": {
            "type": "integer"
          },
          "presenter": {
            "type": [
              "string",
              "null"
            ]
          },
          "duration_seconds": {
            "type": [
              "number",
              "null"
            ]
          },
          "thumbnail_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "video_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Signed, valid 1 hour"
          },
          "error": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_api_key",
                  "key_revoked",
                  "allowance_exceeded",
                  "plan_required",
                  "twin_not_ready",
                  "not_found",
                  "invalid_request",
                  "script_too_long",
                  "rate_limited",
                  "concurrency_limit",
                  "daily_limit",
                  "render_failed",
                  "service_unavailable"
                ]
              },
              "message": {
                "type": "string"
              },
              "user_message": {
                "type": "string",
                "description": "Show this to the end user"
              },
              "action": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              },
              "upgrade_url": {
                "type": "string"
              },
              "fields": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}