Preview. The editors you mount with the UI SDK are new. The calls on this page are built and tested, and you can try them now, but small details can still change while this label is on. Tell us what you find at support@widgetic.com.
How it works
A session belongs to one managed user. Everything that session reads or makes is that managed user’s: a composition, widget, canvas or file that was made for another of your customers answers404, exactly as if it did not exist.
Make a session
Call this from your server, when the page that holds the editor opens.{id} is Widgetic’s id for the managed user (the UUID the create call gave you), not your own external_id.
The answer is
201:
- The token is shown once. It starts with
wgt_ses_, and the answer is sent withCache-Control: no-store. Widgetic keeps only a fingerprint of it, so a lost token cannot be read back: make another session. sessionIdis not a credential. It is only the handle you use to end the session.- Each call makes a new session. It does not take an
Idempotency-Key, because a retry cannot be given the token back. - A key that is limited to some scopes needs all of
partner:write,content:writeandgenerateto make a session, and is refused with403API_KEY_SCOPE_MISSINGwithout them (see Limit what a key can do). A key with full access needs nothing more. - A session is made only while your account is in force and your storage works. A paused account is refused with
403PARTNER_SUSPENDED, and an account without a storage destination with409PARTNER_STORAGE_REQUIRED(see Every session needs your own storage).
A server endpoint for your page
Your page needs one endpoint of yours that checks who is signed in, makes a session for that customer and returns the token. The UI SDK calls it again shortly before the token runs out, so the customer is never interrupted.Surfaces
A session can do only what its surfaces allow. The surfaces do not imply one another, so ask for every one the editor you mount needs.- File Browser:
["files"]. - Composition editor:
["editor", "files"]. - Widget creator:
["creator", "editor", "files"]. The creator saves the composition it is editing (editor) and attaches pictures to its chat (files). - Workflows:
["workflows"]. The screen uploads no file and opens no composition: it chains compositions by their ids. See Workflows.
createManagedUserEditorSession.
Every session needs your own storage
The files a customer uploads are yours to keep, so an editor session is made only when you have set up your own storage destination: a bucket you own, on any S3-compatible service. Widgetic never keeps a customer’s uploaded file in its own storage. Storage is not optional for a partner, and it does not depend on which surfaces a session asks for.- No storage, no session. The call that makes the session answers
409with the codePARTNER_STORAGE_REQUIRED, whatever the surfaces are. When a destination is saved but cannot be used (it is switched off, its credentials cannot be opened, or your account administers two partners that each have one) it answers503withSTORAGE_DESTINATION_UNAVAILABLE. No session is made, so you hear about it on your server and never from a customer’s browser. - There is no fallback. If you remove your storage after a session was made, that customer’s uploads are refused until you save a destination again. They are never written to Widgetic’s storage, and they never count against your storage allowance.
- The customer is told one plain sentence: “This is not available right now. Please try again later.” It names neither your storage nor a limit, because it is your setup and not theirs.
- It covers your customers’ uploads, and yours. What a session makes for itself, such as a widget’s code and its previews, stays with Widgetic. The uploads you send with your own key are kept in your storage too: without a destination they are refused with the same
409, and never stored with Widgetic instead. - An account that is not activated yet cannot make a session at all (
PARTNER_INACTIVE), and activation needs a storage destination that works. See Account Status.
What a session never does
Everything outside its surfaces is refused with403 and the code EDITOR_SESSION_ROUTE_NOT_ALLOWED. In particular a session cannot:
- read or change your account, your keys, your contract, your invoices or your credits;
- make more sessions, or list or end sessions;
- see another of your customers’ compositions, widgets, canvases, conversations, files or workflows (those answer
404); - delete a composition (create it yourself with your key, then open the editor on it);
- make a widget public: what a customer builds stays private to your account (publishing a version of the widget is allowed while your partner agreement is in force, whatever plan your account is on, and it does not make it public);
- file anything under a project or an organization, or set a field the editors do not set. A body with such a field is refused with
403andEDITOR_SESSION_FIELD_NOT_ALLOWED.
This is the difference between a session and your API key. Your key reaches everything on your account, whoever it was filed under. A session reaches only its own customer’s content.
Content the editors can open
A session reaches only content that was filed under its managed user:- Compositions: create them on your server with your key and name the customer (
managedUserIdormanagedUserExternalId, see Filing Content Under a Managed User), then mount the composition editor on the composition’sid. A composition you made without naming a customer is not reachable by any session. - Widgets, canvases and compositions made in the widget creator are filed under the session’s managed user automatically. List them from your server with the same
managedUserIdfilter. - Files a session uploads are filed under its managed user and listed back only for it.
- Workflows a session makes are filed under its managed user automatically, and a session can chain only that customer’s compositions. A workflow of yours that was made without a customer is not reachable by any session. See Workflows.
Bind it to your page
Giveallowed_origin the origin of the page that mounts the editor. The session is then refused from any other origin, and from a request that carries no Origin header, so a token copied out of your page is useless anywhere else. It is stored as scheme://host[:port]: https (or http for localhost, 127.0.0.1 and [::1]), no path, query or credentials, and no wildcard.
Leave it out only for a session that is used from a server.
Lifetime
- A session lasts from 60 seconds to four hours (
expires_in_seconds, default one hour). It cannot be extended. - A managed user can hold up to 100 live sessions. Another request answers
429withEDITOR_SESSION_LIMIT_REACHED; end the ones you no longer need. - Mint a session per page open and per customer, from an endpoint that checks who is signed in. Never give one customer’s token to another.
- Switching the managed user off or deleting it ends all of its sessions.
End a session
End one session, or all of a customer’s sessions, for example when they sign out of your platform. Both need your key and take effect on the next request (allow up to 15 seconds for every server of ours to notice).200 with the session’s id (and 404 EDITOR_SESSION_NOT_FOUND for one that was never yours; ending a session that already ended is fine). The second answers 200 with { "ended": 2 }, the number of sessions it ended, and is fine for a customer who has none.
Credits and limits
The AI is paid for by your account, as your own calls are: a generation a customer starts uses the same credit as one you start with your key (see Credits & Billing). A customer’s uploads do not use your account’s storage allowance: they are kept in your own storage (see Every session needs your own storage).- Each customer has an allowance of their own. What a customer does with the AI is counted per customer, not per account or per session: one busy customer cannot use up the others’ turns, a customer who opens many sessions still has one allowance, and your own calls with your key are counted separately. At the moment a customer can start about 26 generations or builds an hour and about 130 a day. A customer who uses it up is refused with
429, the codeCOST_LIMIT_EXCEEDEDand aRetry-Afterheader, and only that customer is. It also keeps a script in one browser from spending all your credits. Everybody starts with the same allowance, and Widgetic can set it for your account alone: tell us if your customers need more, and see Settings that can differ for your account. - Your credits and plan are yours. When your account cannot pay, every customer is refused:
402BILLING_INSUFFICIENT_CREDITS(credits) or403AUTHZ_PLAN_RESTRICTION(your plan does not include it). A customer is never told what your account holds: the message is one plain sentence, “This is not available right now. Please try again later.”, with no balance, cost or plan. The same calls made with your key keep the full messages. - The editors tell your page. The widget creator reports these as a
limitReachedevent, once per code in half a minute, so your page can offer more or tell its own team. See Canvas Embedding. - Workflows use no credits and have a limit of their own. Making, saving and publishing a workflow is not an AI call, so it takes nothing from your credits and is not counted against a customer’s allowance. A customer can hold up to 50 workflows, archived ones included. See Limits and cost.
- Ordinary rate limiting (
RATE_LIMIT_EXCEEDED) counts the address each request comes from, not your account, so your customers do not share it. It is not a limit your page needs to report. - You can hold one session to a number of credits, and see what each customer spent. See A limit for one session and What each customer spent.
A limit for one session
Sendmax_credits when you make a session, and that session can spend at most that many credits on the AI. Refunds are taken off: a generation that fails gives its credit back to the session as well as to your account.
- The call that would go past the limit is refused before anything is taken from your account. The answer is
402with the codeEDITOR_SESSION_CREDIT_LIMIT_REACHED. The customer reads the same plain sentence as for any other limit, never the limit or what was spent. The widget creator tells your page with alimitReachedevent whosecodeis this one, so you can tell it from an account that is out of credits (BILLING_INSUFFICIENT_CREDITS). - The limit belongs to the session. A new session starts again from zero. For a cap on what a customer may spend in a day or a month, read their usage on your server and stop making sessions at your own number.
- Only calls that take credits count. Building a widget takes none, so it is never counted or held back by
max_credits. - A limit that cannot be checked does not let the call through. If Widgetic cannot read what the session has spent, the call is refused with
503and the customer can try again in a moment.
Settings that can differ for your account
Editor sessions behave the same for every partner by default. If your account needs something different, Widgetic can set any of these three for your account alone, and nothing else about your account changes:
A change reaches every server within about a quarter of a minute. Ask partners@widgetic.com when you need one.
What each customer spent
Your account pays for the AI, so your credit ledger does not say which of your customers used what. Widgetic notes every call that a customer’s session paid for, and adds the notes up for one customer over a period:callsandcreditsare what the customer’s sessions spent and kept. A call that failed and was refunded is inrefundedCallsandrefundedCreditsinstead, so it never counts against the customer.- The period runs from
startDate(included) toendDate(not included). Give neither and it is the 30 days before now; it can be 366 days at most. A date without a time is midnight UTC, so for all of October give2026-10-01and2026-11-01. A date-time must say its offset (2026-10-01T08:00:00Z). - Only what a customer’s sessions spent is counted, from the day Widgetic first recorded it. What you spend with your own key is not in it, and neither is anything from before.
- It answers for your managed users only. One that is not yours answers
404withMANAGED_USER_NOT_FOUND, exactly like one that does not exist. A date that is not a date, astartDatethat is not beforeendDate, or a period over 366 days answers400.
Browsers
A browser may call the API with a session token from any origin. The API answers the preflight request for the calls a session may make, echoes the origin on the real call, and never sendsAccess-Control-Allow-Credentials: a session does not use cookies, only the Authorization header. It exposes the Retry-After, X-Idempotency-Cached and X-Correlation-Id headers to the page. Quote the X-Correlation-Id to Widgetic’s support when you report a problem.
If your page sends a Content-Security-Policy, see UI Components for what the editors need.
Errors
The browser side of a session answers with these. The editors handle them for you and tell your page (error event with sessionEnded: true when the token cannot be used again).
Making a session can also answer:
400 (a surface that does not exist, expires_in_seconds or max_credits out of range, or allowed_origin that is not an origin), 403 (the caller is not a partner), 404 MANAGED_USER_NOT_FOUND, 409 MANAGED_USER_INACTIVE (switched off managed users get no sessions), 409 PARTNER_STORAGE_REQUIRED (the files surface, and no storage destination of your own), 429 EDITOR_SESSION_LIMIT_REACHED, 503 STORAGE_DESTINATION_UNAVAILABLE (the storage you set up cannot be used) and 503 EDITOR_SESSIONS_DISABLED.
Security checklist
1
Keep the key on your server
Make sessions only from your server. Never send your
wgt_prt_ key to a browser: it carries the access of your whole account. Use an editor session instead.2
Check who is signed in
Your endpoint must make the session for the customer who is signed in, and for nobody else.
3
Bind it to your page
Send
allowed_origin so that a copied token is useless on any other web page.4
Keep tokens out of logs, storage and URLs
Hold the token in memory. The UI SDK does.
5
End sessions when customers leave
Call
DELETE /managed-users/{id}/editor-sessions when a customer signs out, and switch the managed user off when their plan on your platform ends.Next Steps
UI Components
Mount the editors in your page with the UI SDK
Canvas Embedding
The widget creator and the composition editor
Workflows
Let a customer chain their compositions into a path
Managed Users
File your customers’ content under them
Credits & Billing
How the AI is paid for