Backend integration (any language)
Cariosan is plain REST. Wire it from Node, Python, PHP, Ruby, Java, .NET, Bash — anything with an HTTP client.
Cariosan ships official SDKs for Go (cariosan-go) and TypeScript (@cariosan/client), but you don't have to use them. The wire surface is plain REST + WebSocket. Any backend that can speak HTTP can integrate.
This page shows you the minimum integration in five popular backends so you can copy and adapt.
What your backend needs to do
In the typical Cariosan setup, your backend has exactly one job: hand your frontend a short-lived user JWT, which it gets from Cariosan with your workspace's API key and secret. The frontend talks directly to Cariosan after that, and asks your endpoint again whenever it needs a new token.
The request your backend makes to Cariosan for each token ({external_id} is your user's id, created with POST /v1/users first):
The response:
Hand that token to your frontend. That's it.
ttl_seconds sets the lifetime (ttl_hours also works; omit both for the server default, CARIOS_JWT_TTL_HOURS). Prefer short tokens, about 10 minutes, together with a token provider on the frontend. The SDK then asks your endpoint for a new token shortly before each one expires, so a leaked token is only useful for minutes and nothing needs to be stored on the device.
Keep api_secret on the server
The sk_* secret must never reach a browser. Storing it in env vars on your server is the standard pattern. If it leaks, rotate it.
Examples
The flow in every backend is the same: upsert the user → issue a JWT → return it to the frontend. Only the syntax changes. Each endpoint is called by the frontend's token provider, both for the first token and for every renewal, so it must authenticate the caller with your own session (cookie or app token).
Node.js (Express + built-in fetch)
Python (Flask + requests)
PHP (Laravel)
Ruby (Rails)
Bash (curl, for quick CI / scripting)
The frontend side: a token provider
Give the SDK a function that calls your endpoint instead of a fixed token. It is called for the first token, shortly before each token expires, and when Cariosan rejects one; the open WebSocket moves to each new token without reconnecting.
Return a freshly issued token each time: the SDK times renewal from the token's lifetime, counted from when it arrives. Create the client once per signed-in user. Details: Tokens.
When to use an official SDK
The official SDKs (cariosan-go, @cariosan/client) give you typed responses, automatic retries, and convenience methods for non-JWT operations (uploading attachments, building channel queries). If your backend is already in Go or TypeScript, the SDK is the easier path.
For everything else, raw HTTP is fully supported and never going to go away. The REST surface is documented in the API reference.
Optional: webhooks
If you want to react to events (a new message arrived, a channel was created, a user joined), point Cariosan at a URL on your backend and verify the X-Cariosan-Signature header. See Webhooks guide.
This is also language-agnostic: the signature is HMAC-SHA256 of the raw body using your api_secret as the key.
Optional: server-side operations
Anything you can do via the SDK, you can do via raw HTTP:
- Create channels:
POST /v1/channels - Add/remove members:
POST /v1/channels/{id}/members - Issue user tokens:
POST /v1/users/{external_id}/token, and revoke them all:POST /v1/users/{external_id}/revoke-tokens
Sending messages and presigning attachments are user actions: they take a user JWT, not the API key.
Browse the full surface in the API reference.
Minimum-viable backend without any framework
If you don't have a backend yet and don't want to spin up Express / Flask / Rails just for this, use a serverless function:
- Vercel / Netlify functions — single
.jsor.tsfile, deploys withgit push. - Cloudflare Workers — same shape, runs at the edge.
- AWS Lambda + API Gateway — slightly more setup but free tier is generous.
The Node example above is a complete Vercel function with no edits needed (just rename to api/cariosan-token.js).
Next steps
- API keys — what each credential type is, how to rotate
- Webhooks guide — receive events from Cariosan
- WebSocket protocol — what the frontend SDK actually wraps
- API reference — full REST surface
Was this page helpful?