API Documentation
Niotio REST API. Base URL: /api
Authorization: Bearer <API_TOKEN> for API requests.Errors
Every /api/** error is JSON (Content-Type: application/json) with error, kind: "api" and status. Unauthenticated calls return {"error":"HTTP 401","kind":"api","status":401}. A wrong method on a known path returns 405 with an Allow header; an unsupported Content-Type returns 415; an unknown path returns 404 — each with the same shape. Invalid ids, query parameters or JSON return 400 {"error":"bad_request","kind":"api","status":400} and include the parameter name when it is known. A missing campaign or case returns 404 with a short error message; another account's campaign is indistinguishable from a missing one.
AI agents: use the MCP server
Give an agent the endpoint /mcp and this token, and it gets 35 tools that call these same endpoints — same auth, same permissions, same JSON. It creates campaigns, adds respondents, sends surveys, reads NPS and works the detractor cases to close, without a line of integration code.
Machine-readable spec
The same endpoints as an OpenAPI 3.1 document at a stable URL — auth scheme, path and query parameters, responses. It is generated from the endpoint list this page renders, so it cannot advertise an API we do not have. Everything (product, API, CLI, webhooks, MCP) is also available as one file for agents.
Generate authenticated examples
Paste your API token once and the copy buttons on the examples below insert it for you. Nothing is executed from this page.
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /api/campaigns | Bearer token | List campaigns (`?test=true|false`; `?trash=true` lists the caller's trash) |
GET | /api/campaigns/{id} | Bearer token | Get a campaign by id |
POST | /api/campaigns | Bearer token | Create a campaign |
PUT | /api/campaigns/{id} | Bearer token | Update a campaign |
DELETE | /api/campaigns/{id} | Bearer token | Move a campaign to the trash (204). It can be restored for 30 days; trashed campaigns are listed with ?trash=true. |
POST | /api/campaigns/{id}/restore | Bearer token | Restore a trashed campaign (204) |
POST | /api/campaigns/{id}/activate | Bearer token | Activate a campaign so it can send and collect responses; returns the campaign |
POST | /api/campaigns/{id}/deactivate | Bearer token | Close a campaign; returns the campaign |
POST | /api/campaigns/{id}/respondents | Bearer token | Add a respondent ({"email":"…","name":"…","language":"en|da"}; name and language are optional). 201 with the respondent. Owner or editor only. |
GET | /api/campaigns/{id}/respondents | Bearer token | List respondents, paged (?page=0&size=50, max 200; ?search=; ?status=UNSENT|SENT|RESPONDED|OPTED_OUT|ALL) |
POST | /api/campaigns/{id}/send | Bearer token | Send the survey to every respondent who has not had it yet: {"sent","failed","blocked","total"}. 409 {"error":"monthly_email_limit_reached","requested","used","limit","resetsOn","sent":0} when the monthly allowance would be exceeded (nothing is sent). |
GET | /api/campaigns/{id}/metrics | Bearer token | NPS, promoters, passives, detractors and response counts for one campaign |
GET | /api/campaigns/{id}/activity | Bearer token | The campaign's activity log (audit entries), newest first |
GET | /api/campaigns/{id}/segments | Bearer token | NPS per segment of one attribute (?attribute=company|customer_type|location|product): value, response count, NPS and whether the sample is big enough (min 5 responses) |
POST | /api/campaigns/{id}/simulate | Bearer token | Test campaigns only: generate simulated responses ({"counts":{"0":3,"10":7},"spreadDays":14,"danishPercent":50}); never sends mail. 400 on a real campaign. |
POST | /api/campaigns/{id}/simulate/clear | Bearer token | Test campaigns only: remove all simulated respondents ({"removedRespondents":n}) |
POST | /api/campaigns/{id}/stagger/start | Bearer token | Test campaigns only: trickle simulated responses into the live feed ({"intervalSeconds":10,"counts":{…}}); returns {"queued":n} |
POST | /api/campaigns/{id}/stagger/stop | Bearer token | Stop a staggered demo and discard what is still queued ({"discarded":n}) |
GET | /api/campaigns/{campaignId}/shares | Bearer token | People the campaign is shared with (owner and anyone it is shared with) |
POST | /api/campaigns/{campaignId}/shares | Bearer token | Share the campaign with an existing Niotio user ({"email":"…","role":"VIEWER|EDITOR"}, default VIEWER; owner only) |
DELETE | /api/campaigns/{campaignId}/shares/{shareId} | Bearer token | Remove a share (the owner, or the person it was shared with to leave) |
GET | /api/metrics | Bearer token | Get overall metrics (real campaigns included in the score; TEST campaigns are excluded, like the dashboard) |
GET | /api/search | Bearer token | Search campaigns, respondents, comments and cases you can reach (?q=…, at most 20 hits per group); the same results as the command palette |
GET | /api/v1/usage/email | Bearer token | Get survey email usage this month |
POST | /api/responses | Respondent token | Submit response (410 campaign_not_open if the campaign is in the trash) |
GET | /api/cases | Bearer token | The follow-up case inbox across every campaign you can reach (?status=OPEN|NEW|IN_PROGRESS|RESOLVED|NOT_POSSIBLE|ALL, ?assignee=MINE|ALL|UNASSIGNED, ?overdue=true, ?campaignId=). When follow-up cases are off (plan or campaign switch), this returns 200 with an empty list, not 403. |
GET | /api/cases/counts | Bearer token | Open, overdue, mine and unassigned case counts. When follow-up cases are off, this returns 200 with zeros, not 403. |
GET | /api/cases/{id} | Bearer token | One case: respondent, rating, comment, assignee, status, outcome, due date |
GET | /api/cases/{id}/notes | Bearer token | A case's internal notes, oldest first |
POST | /api/cases/{id}/notes | Bearer token | Append an internal note ({"body":"..."}, max 2000 characters). 403 {"error":"followup_cases_disabled"} when the campaign has cases switched off. |
POST | /api/cases/{id}/assign | Bearer token | Assign ({"assigneeId":7}) or unassign ({"assigneeId":null}) — the assignee is notified. An empty body ({}) is 400; only an explicit null unassigns. 403 {"error":"followup_cases_disabled"} when the campaign has cases switched off. |
POST | /api/cases/{id}/status | Bearer token | Change status ({"status":"RESOLVED","outcome":"RETAINED"}); closing stores the outcome. 403 {"error":"followup_cases_disabled"} when the campaign has cases switched off. |
GET | /api/comment-tags | Bearer token | Your account's comment tag vocabulary with counts, a 30-day trend, a reliable flag (false = too little data) and up to three quoted source comments. Tags are added by hand, or proposed by the browser's built-in AI and then accepted by a person; each tag carries a `source` of HUMAN or AI and an `aiCount`, so the two can be told apart. Filter with ?q= (name contains) and ?source=HUMAN|AI. |
POST | /api/comment-tags | Bearer token | Create a comment tag. {"name":"Pris","color":"#6c757d"} — name is 1-40 characters and unique per account, case-insensitively. 400 when invalid or already used. |
PUT | /api/comment-tags/{id} | Bearer token | Rename and/or recolour a tag. {"name":"Pricing","color":"#0d6efd"}; existing tag assignments follow the rename. |
DELETE | /api/comment-tags/{id} | Bearer token | Delete a tag and remove it from every comment that carried it. |
GET | /api/comments/{responseId}/tags | Bearer token | Tags on one comment (your account's tags only). Each tag carries a `source` of HUMAN or AI: who applied it to this comment, so an AI-applied tag is visible without a second lookup. |
PUT | /api/comments/{responseId}/tags | Bearer token | Replace the whole tag set on one comment: {"tagIds":[1,4]}. Empty list clears the tags. Needs editor access to the campaign; a viewer or stranger gets 404. |
GET | /api/comments | Bearer token | Search comments across every campaign you can reach: ?q= free text, ?tag=Name or ?tagId= (not both), ?source=HUMAN|AI (comments carrying a human- or model-applied tag), ?minRating= and ?maxRating= (0-10), ?categories=promoter,passive,detractor, ?campaignId=, ?dateFrom= and ?dateTo= (YYYY-MM-DD, inclusive), paged with ?page= (0-based) and ?size= (default 50, max 200). Every comment carries its tags[] with each tag's own source. An unknown tag name or a foreign tag id is an empty page, like a campaign you cannot see. |
POST | /api/comments/{responseId}/tags/{tagId} | Bearer token | Add one tag to a comment and keep the rest: POST /api/comments/{responseId}/tags/{tagId}. Returns the comment's resulting tag set. Needs editor access to the campaign; a viewer or stranger gets 404, and tagging twice is a no-op. |
DELETE | /api/comments/{responseId}/tags/{tagId} | Bearer token | Remove one tag from a comment and leave the others: DELETE /api/comments/{responseId}/tags/{tagId}. 204, also when the comment did not carry that tag. Same editor access rule as adding. |
POST | /api/comment-tags/ai-apply | Bearer token | Save a tagging run produced in the user's browser: {"model":"Gemini Nano","browser":"Chrome/148","assignments":[{"responseId":12,"tagIds":[5]}],"newTags":[{"name":"Onboarding","color":"#0d6efd","commentIds":[12,14]}]}. Comments you may no longer edit are skipped and counted in the response; a tag id outside your account is a 404. Saved assignments are marked as AI and never overwrite human ones. |
DELETE | /api/comment-tags/ai | Bearer token | Remove every AI-applied tag assignment for this account, then any AI-created tag left without comments. Human tags and human assignments are untouched. |
DELETE | /api/comment-tags/ai/runs/{runId} | Bearer token | Undo one AI save: remove the tag assignments that run applied, then any AI-created tag left without comments. Human tags, human assignments and other runs are untouched. 404 if the run is not yours. |
PUT | /api/comment-tags/translations | Bearer token | Set a tag's name in other languages: {"tags":[{"tagId":7,"names":{"da":"Priser"},"source":"AI"}]}. `name` stays the base name and is the fallback for any language without an entry; an empty name removes that language. Names must be unique per account within one language, case-insensitively — a clash is 400 and nothing is written; a tag id outside your account is 404. Same as editing the names on a tag in the app. |
POST | /api/comments/languages | Bearer token | Store the language a comment was written in: {"detections":[{"responseId":12,"language":"da","confidence":0.93}]}. Detection normally runs in the browser (on-device); this endpoint only stores the result. An empty language clears a previous detection. Codes are BCP-47 primary subtags ("da", "en"), normalised to lower case; a code that is not 2-3 letters is 400 and writes nothing. Needs editor access to the campaign per comment — comments that are gone or no longer editable are skipped and counted, not an error. `GET /api/comments` returns each comment's detectedLanguage. |
How to get a user API token
- Log in to Niotio.
- Go to Settings.
- In API Tokens, enter a token name and click Generate New Token.
- Copy the token immediately (it is only shown once).
How to use the API
Include your token in the Authorization header:
Authorization: Bearer YOUR_API_TOKEN
List campaigns (`?test=true|false`; `?trash=true` lists the caller's trash)
curl -X GET "https://niotio.dk/api/campaigns" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Get a campaign by id
curl -X GET "https://niotio.dk/api/campaigns/1" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Create a campaign
A campaign is either a real campaign (real respondents, no simulated data) or a test campaign (simulation only, never sends real mail, excluded from your NPS score). Say so with "campaignType": "REAL" | "TEST" (or the legacy boolean "test": true). The type is fixed at creation; sending a different one to PUT /api/campaigns/<id> returns 400.
curl -X POST "https://niotio.dk/api/campaigns" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Q1 NPS",
"description": "First quarter survey",
"campaignType": "REAL"
}'
Filter campaigns by type
curl -X GET "https://niotio.dk/api/campaigns?test=true" \
-H "Authorization: Bearer YOUR_API_TOKEN"
List trashed campaigns
curl -X GET "https://niotio.dk/api/campaigns?trash=true" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Update a campaign
PUT /api/campaigns/{id} keeps omitted fields (description, closeOn, auto-anonymize). Name is required. Sending closeOn: null clears the close date. Campaign type is fixed at creation.
curl -X PUT "https://niotio.dk/api/campaigns/1" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Q1 NPS"}'
Submit a response (public survey token). 410 {"error":"campaign_not_open","kind":"api","status":410} if the campaign is in the trash. Unknown token is 404.
curl -X POST "https://niotio.dk/api/responses?token=RESPONDENT_TOKEN&rating=10&comment=Great"
Get overall metrics (real campaigns included in the score; TEST campaigns are excluded, like the dashboard)
curl -X GET "https://niotio.dk/api/metrics" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Get survey email usage this month
Same count as the monthly quota (Europe/Copenhagen calendar month). Unlimited plans: limit and remaining are null. Free: limit 100. Add ?include=campaigns for a per-campaign breakdown (this month only, test campaigns excluded).
curl -X GET "https://niotio.dk/api/v1/usage/email?include=campaigns" \
-H "Authorization: Bearer YOUR_API_TOKEN"
{"plan":"PRO",
"period":{"start":"2026-10-01","end":"2026-10-31","resetsOn":"2026-11-01","timezone":"Europe/Copenhagen"},
"emails":{"limit":1000,"used":412,"remaining":588,"percent":41},
"campaigns":[{"id":12,"name":"Q4 NPS","used":300}]}
Comment tags and comment search
Search comments across every campaign you can reach: ?q= free text, ?tag=Name or ?tagId= (not both), ?source=HUMAN|AI (comments carrying a human- or model-applied tag), ?minRating= and ?maxRating= (0-10), ?categories=promoter,passive,detractor, ?campaignId=, ?dateFrom= and ?dateTo= (YYYY-MM-DD, inclusive), paged with ?page= (0-based) and ?size= (default 50, max 200). Every comment carries its tags[] with each tag's own source. An unknown tag name or a foreign tag id is an empty page, like a campaign you cannot see.
# the account's tag vocabulary, model-created tags only
curl -X GET "https://niotio.dk/api/comment-tags?source=AI" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# comments carrying a tag, filtered by who applied it (HUMAN or AI)
curl -X GET "https://niotio.dk/api/comments?tag=Pris&source=AI&minRating=0&maxRating=6" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# add one tag to comment 431 without touching its other tags, then remove it again
curl -X POST "https://niotio.dk/api/comments/431/tags/7" \
-H "Authorization: Bearer YOUR_API_TOKEN"
curl -X DELETE "https://niotio.dk/api/comments/431/tags/7" \
-H "Authorization: Bearer YOUR_API_TOKEN"