{"openapi":"3.1.0","info":{"title":"Trichter API","version":"1","summary":"Self-hosted form backend. Form endpoint, read API for scripts and AI assistants.","description":"Trichter receives the forms of your websites (contact, order, application forms) without a\nbackend of your own: point a plain HTML `<form>` or a `fetch()` call at the form's endpoint.\nThis API reads the submissions back for scripts, BI tools and AI assistants.\n\n## The form endpoint\n\n`POST /f/{key}` takes `application/x-www-form-urlencoded` and `multipart/form-data` (plain\nHTML forms, no JavaScript needed, files with `enctype=\"multipart/form-data\"`) and\n`application/json`. Browsers that post a plain form are redirected (`303`) to `_next`, the\nform's redirect URL or the built-in thank-you page; AJAX clients (`Accept: application/json`\nor a JSON body) get JSON. CORS is limited to the form's allowed domains.\n\nSpecial fields, never stored: `_next`, `_subject`, `_replyto`, the honeypot `_gotcha` (keep\nit empty and hidden: bots fill it in), `altcha` and `cf-turnstile-response` (captchas).\n\n## Authentication\n\nCreate an **API key** in the Trichter app under *API & MCP* and send it as a bearer token:\n\n```\nAuthorization: Bearer trk_…\n```\n\nAPI keys are read-only: they work for every endpoint on this page except the form endpoint\n(which needs none); anything that changes data answers `403 forbidden`. A key belongs to one\norganisation and reads exactly the forms its owner sees there.\n\n## Access: organisations, sharing, groups and teams\n\nEvery form belongs to an organisation. A key reaches its organisation's forms plus the forms\nanother organisation shares with it, read-only (`shared_by` names the owner). A *restricted*\nmember sees only the forms their teams grant. A form the key may not see answers\n`404 not_found`, exactly like a form that does not exist.\n\n## Privacy\n\nSubmissions are personal data. Trichter stores them encrypted (AES-256-GCM) on its own\nservers in Switzerland, never stores IP addresses, user agents or cookies, and deletes them\nafter the form's retention period.\n\n## MCP (Model Context Protocol)\n\n`POST /mcp` is a stateless MCP server (Streamable HTTP, JSON responses) with the tools\n`list_forms`, `list_submissions` and `get_submission`:\n\n```bash\nclaude mcp add --transport http trichter https://trichter-api.rigilab.com/mcp \\\n  --header \"Authorization: Bearer trk_…\"\n```\n","contact":{"name":"Trichter","url":"https://trichter.rigilab.com"},"license":{"name":"Proprietary","url":"https://trichter.rigilab.com"}},"servers":[{"url":"https://trichter-api.rigilab.com","description":"Trichter"}],"security":[{"apiKey":[]}],"tags":[{"name":"Endpoint","description":"The public form endpoint your websites post to."},{"name":"Forms","description":"The forms the key's owner sees."},{"name":"Submissions","description":"The inbox of a form, file downloads and exports."},{"name":"MCP","description":"Model Context Protocol endpoint for AI assistants."}],"paths":{"/f/{key}":{"post":{"tags":["Endpoint"],"operationId":"submit","summary":"Submit a form","description":"No authentication. Plain HTML forms get a `303` redirect; JSON clients get JSON.\nSpam (honeypot, content checks) is answered exactly like a success and filed in the\nform's spam folder.\n","security":[],"parameters":[{"$ref":"#/components/parameters/FormKey"}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/SubmissionInput"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/SubmissionInput"}},"application/json":{"schema":{"$ref":"#/components/schemas/SubmissionInput"},"example":{"name":"Anna Muster","email":"anna@example.com","message":"Hallo!"}}}},"responses":{"200":{"description":"Accepted (JSON clients).","content":{"application/json":{"schema":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean","const":true},"next":{"type":"string","format":"uri","description":"Redirect URL, when the form or `_next` sets one."}}}}}},"303":{"description":"Accepted (plain form posts); `Location` is `_next`, the form's redirect URL or `/f/{key}/thanks`.","headers":{"Location":{"schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/SubmitError"},"403":{"$ref":"#/components/responses/SubmitError"},"404":{"$ref":"#/components/responses/SubmitError"},"413":{"$ref":"#/components/responses/SubmitError"},"415":{"$ref":"#/components/responses/SubmitError"},"422":{"$ref":"#/components/responses/SubmitError"},"429":{"$ref":"#/components/responses/SubmitError"}}},"get":{"tags":["Endpoint"],"operationId":"formPage","summary":"The hosted form page","description":"No authentication. With the hosted page switched on (built in the form builder), the\nform itself as a plain HTML page that posts to this address; otherwise a short info page.\n","security":[],"parameters":[{"$ref":"#/components/parameters/FormKey"}],"responses":{"200":{"description":"An HTML page.","content":{"text/html":{"schema":{"type":"string"}}}},"404":{"description":"No such form (an HTML page).","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/api/v1/forms":{"get":{"tags":["Forms"],"operationId":"listForms","summary":"List forms","responses":{"200":{"description":"The forms the key sees, by name.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Form"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/v1/forms/{id}":{"get":{"tags":["Forms"],"operationId":"getForm","summary":"Get a form","parameters":[{"$ref":"#/components/parameters/FormId"}],"responses":{"200":{"description":"The form.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Form"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/forms/{id}/stats":{"get":{"tags":["Forms"],"operationId":"getFormStats","summary":"Usage stats of a form","parameters":[{"$ref":"#/components/parameters/FormId"},{"name":"days","in":"query","description":"Days of the daily series (1-366, default 30), UTC days.","schema":{"type":"integer","minimum":1,"maximum":366,"default":30}}],"responses":{"200":{"description":"Totals and submissions per day.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Stats"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/forms/{id}/submissions":{"get":{"tags":["Submissions"],"operationId":"listSubmissions","summary":"List submissions","description":"Newest first. Page with `before` = `next_before` of the previous answer.","parameters":[{"$ref":"#/components/parameters/FormId"},{"name":"folder","in":"query","schema":{"type":"string","enum":["inbox","spam"],"default":"inbox"}},{"name":"q","in":"query","description":"Text to search in field names and values (case-insensitive).","schema":{"type":"string"}},{"name":"unread","in":"query","description":"Only unread submissions.","schema":{"type":"boolean"}},{"name":"before","in":"query","schema":{"type":"integer"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"One page.","content":{"application/json":{"schema":{"type":"object","required":["submissions","next_before"],"properties":{"submissions":{"type":"array","items":{"$ref":"#/components/schemas/Submission"}},"next_before":{"type":["integer","null"]}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/forms/{id}/submissions/{sid}":{"get":{"tags":["Submissions"],"operationId":"getSubmission","summary":"Get a submission","parameters":[{"$ref":"#/components/parameters/FormId"},{"$ref":"#/components/parameters/SubmissionId"}],"responses":{"200":{"description":"The submission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Submission"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/forms/{id}/submissions/{sid}/files/{fid}":{"get":{"tags":["Submissions"],"operationId":"downloadFile","summary":"Download an uploaded file","parameters":[{"$ref":"#/components/parameters/FormId"},{"$ref":"#/components/parameters/SubmissionId"},{"name":"fid","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"The file, as an attachment.","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/forms/{id}/export":{"get":{"tags":["Submissions"],"operationId":"exportSubmissions","summary":"Export submissions as CSV or JSON","parameters":[{"$ref":"#/components/parameters/FormId"},{"name":"format","in":"query","schema":{"type":"string","enum":["csv","json"],"default":"csv"}},{"name":"folder","in":"query","schema":{"type":"string","enum":["inbox","spam"],"default":"inbox"}}],"responses":{"200":{"description":"A download (oldest first). CSV columns are `id`, `created_at`, every field and `files`.","content":{"text/csv":{"schema":{"type":"string"}},"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/config":{"get":{"tags":["Forms"],"operationId":"getConfig","summary":"Hub configuration","security":[],"responses":{"200":{"description":"Version and URLs of this hub.","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"string"},"public_url":{"type":"string"},"app_url":{"type":"string"},"signup":{"type":"boolean"},"mail":{"type":"boolean"},"max_upload_mb":{"type":"integer"},"altcha_script_url":{"type":"string"}}}}}}}}},"/mcp":{"post":{"tags":["MCP"],"operationId":"mcp","summary":"MCP (JSON-RPC 2.0)","description":"Stateless Streamable HTTP. Methods `initialize`, `ping`, `tools/list`, `tools/call`.\nTools: `list_forms`, `list_submissions` (`form`, `folder`, `q`, `unread_only`, `limit`,\n`before`), `get_submission` (`form`, `id`). `form` is an id, key or name.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"},"example":{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_submissions","arguments":{"form":"Kontakt","limit":5}}}}}},"responses":{"200":{"description":"JSON-RPC answer.","content":{"application/json":{"schema":{"type":"object"}}}},"202":{"description":"Notification accepted (no answer)."},"400":{"description":"Not JSON.","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"An API key (`trk_…`) from the Trichter app, or a login token."}},"parameters":{"FormKey":{"name":"key","in":"path","required":true,"description":"The public key of the form (the last part of its endpoint URL).","schema":{"type":"string"}},"FormId":{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},"SubmissionId":{"name":"sid","in":"path","required":true,"schema":{"type":"integer"}}},"responses":{"BadRequest":{"description":"Invalid parameter.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"No or an invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"No such form or submission, or not visible to this key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"SubmitError":{"description":"Refused. JSON clients get `{\"ok\": false, \"error\", \"message\"}`, plain form posts an error\npage. Codes: `not_found`, `form_disabled`, `origin_not_allowed`, `captcha_failed`,\n`too_many_requests`, `empty`, `payload_too_large`, `files_not_allowed`,\n`file_type_not_allowed`, `file_rejected`, `unsupported_media_type`, `bad_request`,\n`invalid_fields` (the form's builder fields refused the submission; `fields` says which\nand why).\n","content":{"application/json":{"schema":{"type":"object","required":["ok","error","message"],"properties":{"ok":{"type":"boolean","const":false},"error":{"type":"string"},"message":{"type":"string"},"fields":{"type":"object","description":"`invalid_fields` only: field name → `required`, `invalid`, `too_short`, `too_long`, `too_small`, `too_large` or `not_a_choice`.","additionalProperties":{"type":"string"},"example":{"email":"invalid","consent":"required"}}}}}}}},"schemas":{"Error":{"type":"object","required":["error","message"],"properties":{"error":{"type":"string","examples":["not_found"]},"message":{"type":"string"}}},"SubmissionInput":{"type":"object","description":"Any fields. Repeated names (or `name[]`) become lists.","additionalProperties":true,"properties":{"_next":{"type":"string","format":"uri","description":"Redirect after a plain form post (must be an allowed domain when the form has any)."},"_subject":{"type":"string","description":"Subject of the notification mail."},"_replyto":{"type":"string","format":"email","description":"Reply-To of the notification; recipient of the autoresponder. Default the `email` field."},"_gotcha":{"type":"string","description":"Honeypot; leave empty."}}},"Form":{"type":"object","required":["id","key","name","enabled","endpoint","created_at","submissions","unread","spam"],"properties":{"id":{"type":"integer"},"key":{"type":"string","examples":["a7mx2kq9pz"]},"name":{"type":"string"},"enabled":{"type":"boolean"},"endpoint":{"type":"string","format":"uri"},"group_id":{"type":["integer","null"]},"shared_by":{"type":["string","null"],"description":"Owning organisation of a form shared with yours (read-only)."},"created_at":{"type":"string","format":"date-time"},"submissions":{"type":"integer","description":"Submissions in the inbox."},"unread":{"type":"integer"},"spam":{"type":"integer"},"last_submission_at":{"type":["string","null"],"format":"date-time"},"settings":{"type":"object","description":"The form's settings (docs/api.md \"Form settings\")."},"webhook_secret_set":{"type":"boolean"},"turnstile_secret_set":{"type":"boolean"}}},"Stats":{"type":"object","properties":{"total":{"type":"integer"},"unread":{"type":"integer"},"spam":{"type":"integer"},"period_days":{"type":"integer"},"period_submissions":{"type":"integer"},"period_spam":{"type":"integer"},"last_submission_at":{"type":["string","null"],"format":"date-time"},"days":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","format":"date"},"submissions":{"type":"integer"},"spam":{"type":"integer"}}}}}},"Submission":{"type":"object","required":["id","form_id","created_at","read","spam","fields","files"],"properties":{"id":{"type":"integer"},"form_id":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"read":{"type":"boolean"},"spam":{"type":"boolean"},"spam_reason":{"type":["string","null"],"examples":["honeypot","links","phrase","marked"]},"fields":{"type":"object","additionalProperties":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}},"files":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"field":{"type":"string"},"name":{"type":"string"},"content_type":{"type":"string"},"size":{"type":"integer"},"url":{"type":"string","format":"uri"}}}}}}}}}