Sentily API Documentation
This document covers two different things, and they don't share authentication:
- The external API (
/api/v1/...) — authenticated by a project-scoped API key, meant to be called from your own application. See External API (v1) below. - The internal JSON/AJAX endpoints the Sentily web frontend itself
uses (
/submit_feedback,/get_feedback, etc.) — session-cookie + CSRF authenticated, the same mechanism the website's own JS uses. These are documented further down for completeness, but they're not a stable contract the way/api/v1is meant to be — they're free to change shape alongside the dashboard.
External API (v1)
Authentication
Every /api/v1/... request needs an API key in the Authorization
header:
Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Each key belongs to one project: everything it creates or reads is in that project. There's no self-serve key management in the app yet — ask the Sentily team for a key for your project. A key is only ever shown once, when it's created, so store it somewhere safe (and treat it like a password: keep it on your server, never in browser or mobile app code). If a key leaks, ask for it to be revoked and replaced.
A missing, invalid, or revoked key gets 401. No CSRF token is needed on
these endpoints.
Quick start
curl -X POST https://YOUR-SENTILY-APP/api/v1/feedback \
-H "Authorization: Bearer sk_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"content": "Checkout was quick and painless."}'
The response is the stored entry, including its sentiment analysis if the project had credits available (see Create Feedback).
Errors
Every error response from /api/v1/... has the same shape — a
human-readable error plus a stable code you can branch on
programmatically instead of parsing the message text:
{"error": "Invalid or revoked API key", "code": "invalid_api_key"}
| Code | HTTP status | Meaning |
|---|---|---|
missing_api_key |
401 | No Authorization: Bearer ... header sent |
invalid_api_key |
401 | Key doesn't exist, or has been revoked |
validation_error |
400 | content missing/empty, or another field failed validation |
invalid_source |
400 | source_id doesn't match a real FeedbackSource |
not_found |
404 | The feedback id doesn't exist, or belongs to a different project than the key |
rate_limited |
429 | Too many requests for this key — see Rate limiting below |
Rate limiting
Per-key (not per-IP): 30/minute on the create endpoint, 60/minute on
the read endpoints. 429 past that, with code: "rate_limited".
Response times
Creating feedback runs AI analysis before responding, so expect it to take a few seconds. And while Sentily is in early access, the service sleeps when idle: the first request after a quiet period can take up to a minute while it wakes. Set your client's timeout to at least 90 seconds, and retry on a timeout rather than treating it as a failure.
1. Create Feedback
- URL:
POST /api/v1/feedback - Request Body (JSON):
json { "content": "string (required)", "source_id": "integer (optional) — a FeedbackSource id; defaults to the \"API\" source if omitted", "external_id": "string (optional)", "created_at": "string (optional, YYYY-MM-DD; defaults to now)" } - Response — analyzed (201):
json { "id": 123, "number": 12, "content": "...", "external_id": null, "source": {"id": 11, "name": "API"}, "created_at": "2026-09-09T16:55:49.539349", "processed": true, "sentiment_result": {"category": "positive", "score": 0.8, "magnitude": 1.2, "keywords": "[...]", "explanation": "..."} } - Response — not analyzed (still created; only true when the
project's credit balance can't cover it) (201):
json {"id": 123, "processed": false, "message": "Feedback saved. Not analyzed due to insufficient credits."} - Validation error (400):
{"error": "...", "code": "validation_error"}or"invalid_source"— see Errors ididentifies the entry in API URLs (/api/v1/feedback/{id}) and never changes.numberis the entry's number within its project (#1, #2, …, in the order entries were added) — the number users see in the app.
2. List Feedback
- URL:
GET /api/v1/feedback - Query params:
page,per_page(max 100),sentiment(positive/neutral/negative),source_id,status=pending— same semantics as the internal/get_feedbackendpoint below, scoped to the key's project instead of a session's selected project. - Response (200):
{"feedback_entries": [...], "pagination": {"page", "per_page", "total", "pages"}}
3. Get a Single Feedback Entry
- URL:
GET /api/v1/feedback/{id} - Response: the same object shape as in Create Feedback's response, or
404 {"error": "Feedback not found", "code": "not_found"}if the id doesn't exist or belongs to a different project than the key.
Internal Endpoints (web frontend's own AJAX)
The rest of this document describes the JSON/AJAX endpoints the Sentily web frontend itself uses for feedback management and analysis. Every endpoint below uses the same session-cookie login as the website, plus a CSRF token on anything that changes data — not the API-key scheme above. The one exception, Webhook Receiver, predates the external API and uses its own shared-secret-per-integration scheme.
Base URL
Relative to wherever Sentily is deployed, e.g. http://localhost:5000 in
local development. All paths below are relative to that.
Session Authentication
Sentily uses session-cookie authentication (Flask-Login), the same mechanism the website itself uses:
POST /loginwithusername(username or email) andpasswordform fields. On success, a signed session cookie is set; the browser (or your HTTP client, if it persists cookies) sends it automatically on subsequent requests.- Most endpoints also require a project to be selected in that
session (
POST /select_projectwith aproject_idform field, or simply having visited the dashboard before, which selects one automatically). Endpoints that need this return400 {"error": "No project selected"}if none is set.
These endpoints don't accept the /api/v1 API key described above —
requests without a valid session cookie get redirected to /login (HTML
routes) or 401/403 JSON (AJAX-style routes).
CSRF tokens
Every POST / PUT / PATCH / DELETE endpoint below additionally
requires a valid CSRF token, checked against the value stored in your
session. Get the current token either from the rendered page (a
<meta name="csrf-token" content="..."> tag, or Jinja's csrf_token()
template helper) and send it as:
- an
X-CSRF-TokenorX-CSRFTokenrequest header (what the frontend's own JS uses), or - a
csrf_tokenfield in the form body or JSON body.
A missing or mismatched token gets a 400 Bad Request before the endpoint's
own logic ever runs.
Rate limiting (internal endpoints)
Several endpoints are rate-limited per client (Flask-Limiter), noted per
endpoint below. Exceeding the limit returns 429 Too Many Requests.
Endpoints
1. Submit Feedback
Submit new feedback into your currently-selected project.
- URL:
/submit_feedback - Method:
POST - Auth: Session + CSRF required
- Rate limit: 30/minute
- Request Body: JSON or form-encoded (send
Content-Type: application/jsonfor JSON; otherwise it's read as form fields)json { "content": "string (required)", "source_id": "integer (required) — a FeedbackSource id", "external_id": "string (optional)", "feedback_date": "string (optional, YYYY-MM-DD; defaults to now)" }Note there is noproject_idfield — feedback is always created in your session's currently-selected project. - Response (JSON):
- Success, analyzed (200 OK):
json { "success": true, "message": "Feedback submitted and analyzed successfully with LLM", "feedback_id": 123 } - Success, but not analyzed — the entry is still created even
when there aren't enough credits or a previous request already
spent the balance; only sentiment analysis is skipped (200 OK):
json { "success": true, "message": "Feedback saved. Not analyzed due to insufficient credits.", "feedback_id": 123, "credits": 0 } - Validation error (400 Bad Request):
json { "success": false, "error": "Error message" }
- Success, analyzed (200 OK):
2. Retrieve Feedback Entries
Paginated, filterable list of feedback for the session's selected project.
- URL:
/get_feedback - Method:
GET - Auth: Session required
- Rate limit: 30/minute
- Query Parameters:
page:integer (optional, default: 1)per_page:integer (optional, default: 20, max: 100)sentiment:string (optional)—'positive','neutral', or'negative'source_id:integer (optional)status:string (optional)—'pending'filters to unanalyzed entries
- Response (JSON):
- Success (200 OK):
json { "feedback_entries": [ { "id": 1, "content": "Great product!", "source": { "id": 1, "name": "Direct Input", "icon": "keyboard" }, "created_at": "2026-07-18T10:00:00", "sentiment_result": { "category": "positive", "score": 0.8, "magnitude": 1.2, "keywords": "[\"great\", \"product\"]", "explanation": "The user expressed positive sentiment about the product." } } ], "pagination": { "page": 1, "per_page": 20, "total": 100, "pages": 5 } } - No project selected (400 Bad Request):
json { "error": "No project selected" }
- Success (200 OK):
3. Retrieve Single Feedback Entry
- URL:
/api/feedback/{feedback_id} - Method:
GET - Auth: Session required (must have access to the entry's project)
- Response (JSON):
- Success (200 OK):
json { "id": 1, "content": "Great product!", "source_id": 1, "created_at": "2026-07-18", "sentiment_result": { "category": "positive", "score": 0.8 } } - Error (403 Forbidden / 404 Not Found):
json { "error": "Error message" }
- Success (200 OK):
4. Update Feedback Entry
Update an existing entry's content, source, or date. If content changes
and credits are available, it's automatically re-analyzed.
- URL:
/feedback/{feedback_id} - Method:
PUTorPATCH - Auth: Session + CSRF required
- Rate limit: 10/minute
- Request Body (JSON):
json { "content": "string (optional)", "source_id": "integer (optional)", "feedback_date": "string (optional, YYYY-MM-DD format)" } - Response (JSON):
- Success (200 OK):
json { "message": "Feedback updated successfully" } - Error (400 Bad Request / 403 Forbidden / 404 Not Found):
json { "error": "Error message" }
- Success (200 OK):
5. Delete Feedback Entry
- URL:
/feedback/{feedback_id} - Method:
DELETE - Auth: Session + CSRF required
- Rate limit: 10/minute
- Response (JSON):
- Success (200 OK):
json { "message": "Feedback deleted successfully" } - Error (403 Forbidden / 404 Not Found):
json { "error": "Error message" }
- Success (200 OK):
6. Import Feedback via CSV
Bulk-create feedback from an uploaded CSV file.
- URL:
/projects/{project_id}/upload_csv - Method:
POST - Auth: Session + CSRF required (admin or analyst role on the project)
- Request Body:
multipart/form-datawith afilefield (.csvonly)- Must have a header row with a
contentortextcolumn. - Optional columns:
source_id,external_id,feedback_date(YYYY-MM-DD). - Rows are deduped against existing feedback by
external_idwithin the project, when provided.
- Must have a header row with a
- Response (JSON):
- Success (200 OK):
json { "message": "CSV processed successfully. Added 42 new entries.", "created": 42, "duplicates": 3, "errors": 0 } - Error (400 Bad Request / 403 Forbidden):
json { "error": "Error message" }
- Success (200 OK):
7. Export Feedback
Export the selected project's feedback (with the same filters as Retrieve Feedback Entries) as a file download.
- URL:
/export/feedback.csvor/export/feedback.pdf - Method:
GET - Auth: Session required
- Query Parameters:
sentiment,source_id,status— same as endpoint 2 - Response:
- Success (200 OK): The file (
text/csvorapplication/pdf) as an attachment. - No project selected: redirects to the Feedback page with a flash message rather than returning JSON (these are plain browser-navigation endpoints, not AJAX-only).
- Success (200 OK): The file (
A parallel /export/analytics.csv endpoint exports the project's overall
sentiment percentages (no per-entry filters) in the same way.
8. Webhook Receiver
An older way for another service to push feedback in, predating the External API. It authenticates with a per-integration shared secret, which there's currently no way to set up from the app — so for new integrations, use the External API instead.
- URL:
/webhooks/{integration_id} - Method:
POST - Auth: Not session-based. Authenticated via a shared secret set
per integration (
APIIntegration.webhook_secret), sent as anX-Webhook-Secretheader. No CSRF token is needed or checked here — that mechanism is for browser sessions, not this kind of caller. - Request Body (JSON):
json { "content": "string (required)", "external_id": "string (optional)", "created_at": "string (optional, ISO 8601)" } - Response (JSON):
- Success (200 OK):
json { "message": "Feedback received and processed", "feedback_id": 123 } - Missing/wrong secret (403 Forbidden):
json { "error": "Unauthorized webhook request" } - Integration not found (404 Not Found):
json { "error": "Integration not found" } - Bad payload (400 Bad Request):
json { "error": "Missing \"content\" field in payload" }
- Success (200 OK):
If credits are available in the integration's project, the feedback is analyzed automatically after being saved; if not, it's still saved unanalyzed (see Credits & the Periodic Allowance in the Developer Guide — there's no way to buy more credits via this endpoint or any other).