API Integration

Errors

Every status the Senso API returns, what causes it, and what to do about it.

Senso signals failure with the HTTP status code, and explains it in a JSON body. Branch on the status first; the body tells you which case you hit.

The error body

Nearly every error comes back with the same two fields:

json
{ "status": 404, "message": "Node not found" }

status repeats the HTTP status. message is written for people: log it and show it, but do not match on its text.

A request whose body fails validation lists each problem instead:

json
{
  "status": 400,
  "errors": [
    { "field": "type", "message": "Must be one of: decision consideration awareness evaluation" }
  ]
}

A 402 carries a code you can branch on: insufficient_credits or spending_limit_reached.

Each operation's possible errors and their bodies are in the API Reference.

Every status

StatusMeansWhat to do
400The request was malformed, or a field failed validationCheck the message or errors
401The API key is missing or not validSend the key in the X-API-Key header. See below
402Out of credits, or over the spending limitCheck code, and your balance with GET /org/credits/balance
403The key is valid, but this request is not allowedSee below: it has a few different causes
404No such endpoint, or no such resource that you can seeSee below
409Conflicts with something that already exists or is still runningFor example, text identical to a document you already have, deleting a document that is still processing, or starting a website import while one is running. Read the message before retrying
422The request is valid but cannot be carried outFor example, an upload in which no file could be accepted (the body still lists each file's result), turning on auto-publish with no destination set up, or a website import with no website on file
429Too many requestsBack off and retry. See Limits
500Something failed on Senso's sideRetry once. For a request that changes something, check whether it took effect before retrying
502A service Senso depends on failedMost often while publishing or unpublishing. Check the content's status before retrying
503A service is temporarily unavailableRetry with backoff

401: the key is missing or not valid

json
{ "status": 401, "message": "Organization API key or valid JWT token required" }

The same answer covers a missing key, a key that is wrong or expired, and a key sent in the wrong header. Send it as X-API-Key: <your key>, not as Authorization: Bearer. Keys from senso login expire after seven days. API Keys shows how to get one.

403: the key is valid, but this is not allowed

The message says which case it is:

messageCause
This action requires user authenticationThe operation needs a person signed in to the Senso app. Creating, changing or revoking API keys, and approving a device sign-in, cannot be done with an API key
Your organization doesn't have access to this productYour organization does not have the Senso product this endpoint belongs to
No KB scope configured. An admin must grant access to KB content before searching.The key is restricted to knowledge base folders, and has none
You do not have permission to modify this resourceYou can see the file or folder, but your access to it does not include changing it
Industry does not match the organization's industryYou can import prompts only from your organization's own industry
A key restricted to some folders keeps working on every other endpoint, which is why a 403 or 404 from the knowledge base can be surprising. GET /org/api-keys shows whether each key is scoped, and GET /org/api-keys/{id}/kb-permissions lists its folders. Permissions explains roles and folder access.

404: no such endpoint, or nothing you can see

A 404 has two causes, and the body tells them apart:

What comes backWhat it means
Plain text: 404 page not foundThe path does not exist. Check the spelling and the /api/v1 prefix
JSON, such as {"status": 404, "message": "Node not found"}The path exists, but the id does not match anything you can see
A file or folder you do not have at least view access to answers 404, not 403. To you, it does not exist. Check the id, and check that your key belongs to the organization that owns it and can see that folder.

A knowledge base document and generated content have separate endpoints. A knowledge base document's id sent to /org/content/{id} is a 400, and is read through /org/kb/nodes/{id} instead.

Next steps