{"openapi":"3.0.3","info":{"title":"document-anonymizer API","description":"REST API for anonymizing and pseudonymizing PDF documents.","version":"1.0.0","contact":{"name":"document-anonymizer support","email":"tamogatas@navu.hu"}},"servers":[{"url":"/api/v1","description":"Production API"}],"tags":[{"name":"Document Processing","description":"Operations for processing PDF documents"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API key for authentication. Must be a valid, non-deleted API key."},"BearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token authentication using API key"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"Error message"}},"required":["error"]},"ExtractedData":{"type":"object","description":"Extracted structured data from the PDF","additionalProperties":true}}},"paths":{"/anonymize":{"post":{"summary":"Anonymize or extract data from PDF documents","description":"This endpoint processes PDF documents to either anonymize sensitive information or extract structured data based on the specified mode and parameters. Requires API key authentication and sufficient token balance.","tags":["Document Processing"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["pdf_file","filename"],"properties":{"pdf_file":{"type":"string","format":"binary","description":"The PDF file to process"},"filename":{"type":"string","description":"Original filename of the PDF","example":"document.pdf"},"strings_to_remove":{"type":"string","description":"JSON array of strings to remove/anonymize","example":"[\"John Doe\", \"123-45-6789\"]"},"mode":{"type":"string","enum":["anonymize","extract"],"default":"anonymize","description":"Processing mode - anonymize sensitive data or extract structured data"},"schema_id":{"type":"string","description":"Hierarchy ID for data extraction schema","example":"1"}}}}}},"responses":{"200":{"description":"Successfully processed document","content":{"application/pdf":{"schema":{"type":"string","format":"binary","description":"Anonymized PDF file"}},"application/json":{"schema":{"$ref":"#/components/schemas/ExtractedData"}}},"headers":{"Content-Disposition":{"schema":{"type":"string"},"description":"Attachment filename"}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"no_file":{"summary":"No PDF file provided","value":{"error":"No PDF file provided"}},"no_filename":{"summary":"Filename missing","value":{"error":"Filename is required"}},"no_schema":{"summary":"Schema required for extract mode","value":{"error":"Schema JSON is required for extract mode"}}}}}},"401":{"description":"Unauthorized - Invalid or missing API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"no_key":{"summary":"API key missing","value":{"error":"API key required. Use Authorization: Bearer <key> or X-API-Key: <key> header."}},"invalid_key":{"summary":"Invalid API key","value":{"error":"Invalid API key or key has been deleted"}}}}}},"403":{"description":"Insufficient tokens","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Insufficient tokens. Need 5, have 2"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Anonymization service is not available"}}}}}}},"/pseudonymize":{"post":{"summary":"Pseudonymize PDF documents using CSV mapping","description":"This endpoint processes PDF documents to pseudonymize sensitive information using a CSV mapping file. Requires API key authentication and sufficient token balance.","tags":["Document Processing"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["pdf_file","csv_file"],"properties":{"pdf_file":{"type":"string","format":"binary","description":"The PDF file to process"},"csv_file":{"type":"string","format":"binary","description":"CSV file containing pseudonymization mapping"},"truncate":{"type":"string","default":"true","description":"Whether to truncate the pseudonymization data","example":"true"}}}}}},"responses":{"200":{"description":"Successfully pseudonymized document","content":{"application/pdf":{"schema":{"type":"string","format":"binary","description":"Pseudonymized PDF file"}}},"headers":{"Content-Disposition":{"schema":{"type":"string"},"description":"Attachment filename"}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"no_pdf":{"summary":"No PDF file provided","value":{"error":"pdf_file missing"}},"no_csv":{"summary":"No CSV file provided","value":{"error":"csv_file missing"}}}}}},"401":{"description":"Unauthorized - Invalid or missing API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"no_key":{"summary":"API key missing","value":{"error":"API key required. Use Authorization: Bearer <key> or X-API-Key: <key> header."}},"invalid_key":{"summary":"Invalid API key","value":{"error":"Invalid API key or key has been deleted"}}}}}},"403":{"description":"Insufficient tokens","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Insufficient tokens. Need 5, have 2"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Pseudonymization service is not available"}}}}}}}}}