{
    "openapi": "3.0.3",
    "info": {
        "title": "ComtroniX DocuDex API",
        "version": "1",
        "description": "Upload PDFs and images, poll the job, fetch the result."
    },
    "servers": [
        {
            "url": "https://docudex.comtronix.nl/api/v1"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "Job": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "info",
                            "text",
                            "ocr",
                            "extract",
                            "tables",
                            "pdf_edit",
                            "redact",
                            "ai_extract"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "queued",
                            "processing",
                            "done",
                            "failed"
                        ]
                    },
                    "filename": {
                        "type": "string"
                    },
                    "pages": {
                        "type": "integer"
                    },
                    "error": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            }
        }
    },
    "security": [
        {
            "bearer": []
        }
    ],
    "paths": {
        "/me": {
            "get": {
                "summary": "Plan, limits and usage",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/jobs": {
            "get": {
                "summary": "List jobs",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "post": {
                "summary": "Create a job",
                "requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "file"
                                ],
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "files": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "format": "binary"
                                        },
                                        "description": "extra PDFs/images for pdf_edit op=merge"
                                    },
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "info",
                                            "text",
                                            "ocr",
                                            "extract",
                                            "tables",
                                            "pdf_edit",
                                            "redact",
                                            "ai_extract"
                                        ]
                                    },
                                    "params": {
                                        "description": "JSON object. pdf_edit: {op: rotate|delete|extract|split|merge|compress|watermark|metadata|to_images, pages, angle, every, ranges, text, title, author, dpi, format}. redact: {terms: [..], patterns: [iban,email,phone,postcode,bsn,url,date_of_birth]}. tables: {pages}.",
                                        "type": "string"
                                    },
                                    "webhook_url": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created"
                    },
                    "402": {
                        "description": "Monthly limit"
                    },
                    "403": {
                        "description": "Not in plan"
                    },
                    "429": {
                        "description": "Rate limit"
                    }
                }
            }
        },
        "/jobs/{id}": {
            "get": {
                "summary": "Job status",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "delete": {
                "summary": "Delete job and files",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    }
                }
            }
        },
        "/jobs/{id}/result": {
            "get": {
                "summary": "Result as json, text or file (PDF/ZIP; the OCR PDF needs the export feature)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "json",
                                "text",
                                "file"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "409": {
                        "description": "Not ready"
                    }
                }
            }
        },
        "/search": {
            "get": {
                "summary": "Full-text search in your processed documents (search feature)",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    }
}