Overview
A managed user is:- A record with a Widgetic
id(a UUID), your ownexternalId(unique among your managed users, for example your customer number), a free-formmetadataobject and anisActiveswitch. - Visible only to you. A record that belongs to another partner answers
404, never403, so nothing about other partners can be learned. - A label you can put on compositions, widgets and uploads, to list them by customer, and change or take off later. See Filing Content Under a Managed User and Moving Content to Another Managed User. A customer’s editor session, and your key with the customer’s header, put the same label on the workflows they make, and your key with the customer’s header puts it on the A/B tests and translations you make for them.
- A login. It has no password and no API key, and you cannot sign in as a managed user. The one thing that acts for a managed user is an editor session: a short-lived token your server makes, so that the customer’s browser can use Widgetic’s editors on what is filed under them and nothing else.
- An owner. Compositions, widgets, uploads, workflows, A/B tests, translations, credits, storage and the list of allowed websites belong to your partner’s workspace, and an unscoped call with your key can read, change and delete all of them. To restrict a composition, workflow, A/B test or translation call made with your server key so it reaches only one customer’s, send
X-Managed-User-IdorX-Managed-User-External-Idon the request (see Scoping a Composition Call to One Customer, Scoping a Workflow Call to One Customer and Scoping an A/B Test or Translation Call to One Customer), or mint an editor session for the customer’s browser, for what a session has a screen for. - A billing unit. There are no per-customer credits, storage or invoices. You are invoiced once, for the contract. What a customer’s editor sessions spent on the AI can be read per customer, so you can bill them for it yourself (see What a Managed User Spent). See Credits & Billing.
WIDGETIC_PARTNER_KEY.
Creating Managed Users
A partner makes a managed user for each of its platform’s customers, with an active partner API key: no other key can. Send theIdempotency-Key header, and write the body in camelCase, like every answer. The snake_case spellings (external_id, manager_id, is_active) are read too, but send one spelling of a field, not both:
201on success.409if you already have a managed user with thatexternalId.400ifexternalIdis missing.403if the key is not an active partner API key.managerIdis optional and defaults to you. Leave it out: you can only use your own, and another account’s id is refused with403.- Use camelCase keys inside
metadata. The API converts every key in every answer to camelCase, socompany_namewould come back ascompanyName.
POST /managed-users and PUT /managed-users/{id} need an Idempotency-Key header (see Idempotency). In the @widgetic/api-sdk-ts package, send it as idempotencyKey in the request object of createManagedUser and updateManagedUser, and send the same one when you retry.Listing Managed Users
GET /managed-users returns your managed users, newest first. The query takes:
The answer has
data, a list, and meta with page, size, hasNextPage, hasPreviousPage and nextCursor (null on the last page), and total for a page you read by number. Every row carries lastActivityAt: the last time something was filed under that customer (a widget, an embed, a file, a workflow or a canvas). It is written at most once in a few minutes, so read it as “about when”, never as the second. Customers that existed before the field did start at the day it was added.
Finding a Customer by Your Own Id
To find the managed user you registered with your own id, send it asexternalId. The list then holds that one managed user, or nothing (meta.total is 0) when none of yours has that id:
externalId once and not empty. A repeated or an empty value is 400, and is never read as a list of everyone. It combines with page, size and sort.
Page by cursor when you have many customers and sort them by lastActivityAt: the order changes while you read, and a page number would then show one customer twice and another never. The nextCursor names a place in the order, so the next page begins exactly after it:
Find the work of one customer
A request for help names a person, not a widget: “user 4821 cannot find their quiz”. So Widgetic goes from your own id for the customer to what was made for them:- Find the customer with your own id:
GET /managed-users?search=4821. The record has Widgetic’sid, yourexternalIdandlastActivityAt. - List what they made. The calls of Filing Content Under a Managed User take
managedUserIdormanagedUserExternalIdin the query (GET /compositions,GET /widgets,GET /uploads), and so does the list of workflows of your workspace (one of the two, never both). The lists of A/B tests and translations take the customer’s header instead. - Read whose a row is. In your partner workspace, the rows of the lists that are not filed by customer say whose they are, with
managedUserIdandmanagedUserExternalId(bothnullfor what belongs to no customer in particular): the widgets, canvases and compositions of a project, the workflows, the A/B tests, the translations and the uploads. A list in any other workspace is sent as it always was, and an id that is not one of your customers has no label, so a list never shows another partner’s customer. An A/B test or a translation that you made with a customer’s header carries that customer’s label itself. One made without it names the customer of the first of its versions that was filed under one, or of its original composition.
Getting a Specific User
GET /managed-users/{id} returns one record:
externalId to GET /managed-users (see Finding a Customer by Your Own Id). You do not need it to file or list a customer’s work: the calls below accept your own id for the customer (managedUserExternalId) and find the managed user for you.
Filing Content Under a Managed User
When you create a composition, a widget or an upload for one of your customers, name the managed user in the request. Widgetic records it on the new item, and you can list only that customer’s items afterwards. Name the managed user in one of two ways. Send one, never both (400):
Both are optional. A request that names no managed user creates an item that belongs to your account alone, exactly as before. An empty value (
null or "") counts as naming no one.
Compositions and widgets
Add the field to the body ofPOST /compositions or POST /widgets:
managedUserId, Widgetic’s id for the customer, or null for an item that belongs to your account alone. To list one customer’s items, send the same field in the query of GET /compositions or GET /widgets:
widget_id on compositions, canvasId on widgets). Spell the two fields exactly as shown, in camelCase: managed_user_id on these calls is refused with a 400, not ignored, so a mistyped filter can never hand you every customer’s items.
Uploads
POST /uploads is a multipart form, so its fields are snake_case like the rest of that call: send managed_user_id or managed_user_external_id as a form field next to file. GET /uploads takes the same two names in its query, and every upload in an answer says managed_user_id (null when there is none).
POST /uploads is refused with 409 PARTNER_STORAGE_REQUIRED. A file that came through a customer’s editor session is filed under that customer by itself.
A file filed under a managed user carries managedUserId, is found with the managed_user_id filter of GET /uploads, and is counted for that customer in the storage report.
What Widgetic checks
- The managed user must be one of yours. One that does not exist, and one that belongs to another partner, get the same answer,
404with the codeMANAGED_USER_NOT_FOUND, so nothing about other partners can be learned. Nothing is created or listed. - A managed user that has been switched off (see Updating) cannot be given anything new:
409 MANAGED_USER_INACTIVE. Its existing items stay and can still be listed. - A value that is not a UUID (for
managedUserId), is not text, or is longer than 255 characters (formanagedUserExternalId) is refused with400 MANAGED_USER_REFERENCE_INVALID. So is a field spelled the other way (managed_user_idwhere the call readsmanagedUserId, ormanagedUserIdon/uploads): it is refused, never ignored, so an item is never filed under no one, and a list is never unfiltered, without you knowing. Sending both fields is400 MANAGED_USER_REFERENCE_AMBIGUOUS. - The label is set from your request only. A
PUTorPATCHthat updates the item does not change it. To move an item to another managed user, or to take the label off, use the calls in Moving Content to Another Managed User. - A copy of a composition that you duplicate is filed under the same managed user as the original.
- A workflow is filed under a managed user when a customer’s editor session makes it, or when you make it with your key and the customer’s header (see Scoping a Workflow Call to One Customer), and in no other way. A workflow you make or copy without the header is your account’s own, not the customer’s.
- An A/B test or a translation is filed under a managed user when you make it with your key and the customer’s header (see Scoping an A/B Test or Translation Call to One Customer), and in no other way. One you make without the header is your account’s own, not the customer’s.
Filing under a managed user does not change who owns the item: the item belongs to your account and the credits it spends are your account’s. What filing decides is what an editor session for that managed user can open, and what a server call carrying
X-Managed-User-Id or X-Managed-User-External-Id may reach.Scoping a Composition Call to One Customer
When your backend handles a composition request on behalf of one signed-in customer, sendX-Managed-User-Id (Widgetic’s UUID for the managed user) or X-Managed-User-External-Id (your own externalId for the customer) on the call—one of the two, never both:
@widgetic/api-sdk-ts, pass xManagedUserId or xManagedUserExternalId in the request object (or set the header once on new Configuration({ accessToken, headers: { 'X-Managed-User-External-Id': 'your-platform-user-123' } }) for a per-request client):
GET /compositionslists only that customer’s compositions, andPOST /compositionsfiles the new composition under that customer.- Any call to
/compositions/{id}or its sub-routes (content, design, entries, database records, duplicate, publish, delete) succeeds only if the composition is filed under that customer; another customer’s composition or an unfiled composition returns404. - Calling an account-wide route with either header returns
403MANAGED_USER_SCOPE_ROUTE_NOT_AVAILABLE, and an empty or malformed header returns400MANAGED_USER_SCOPE_INVALID. - Only a partner’s API key can send either header, because only a partner has managed users. A key that is not a partner’s finds no managed user and returns
404MANAGED_USER_NOT_FOUND, and a call that is not made with an API key (a signed-in person, say) returns403MANAGED_USER_SCOPE_NOT_ALLOWED.
Scoping a Workflow Call to One Customer
The same two headers work on the calls of Workflows, which are made in your partner workspace, named by its id ({workspaceId} below: the workspaceId that the answer of an editor session carries):
GET /workspaces/{workspaceId}/workflowslists only that customer’s workflows, andPOST /workspaces/{workspaceId}/workflowsfiles the new workflow under that customer, as does duplicating one of theirs.- Any call on
/workspaces/{workspaceId}/workflows/{workflowId}or its sub-routes (save, delete, publish, discard, versions, restore, pause, resume, archive, unarchive, counts) succeeds only if the workflow is filed under that customer. Another customer’s workflow, one you made without a header, another account’s and one that does not exist all return404RESOURCE_WORKFLOW_NOT_FOUND. - The id of any other workspace, a team you belong to included, returns
404RESOURCE_WORKSPACE_NOT_FOUND. A word where the id belongs (me, say) returns403MANAGED_USER_SCOPE_ROUTE_NOT_AVAILABLE. - A customer you switched off keeps its workflows and you can still read and change them, but making or copying one for it returns
409MANAGED_USER_INACTIVE.
Scoping an A/B Test or Translation Call to One Customer
The same two headers work on the calls of A/B Tests and Translations, which are made in your partner workspace, named by its id as in the workflow calls above:GET /workspaces/{workspaceId}/ab-testsandGET /organizations/{orgId}/translationslist only that customer’s tests and translations, andPOSTon either files the new one under that customer. Every composition a test compares, and the original of a translation, has to be one of that customer’s.- Any call on one test (
/workspaces/{workspaceId}/ab-tests/{testId}and its sub-routes) or on one translation (/translations/{id}and its sub-routes) succeeds only if it is filed under that customer. Another customer’s, one you made without a header, another account’s and one that does not exist all return404,RESOURCE_AB_TEST_NOT_FOUNDfor a test andRESOURCE_TRANSLATION_NOT_FOUNDfor a translation. - A customer you switched off keeps its tests and translations and you can still read and change them, but making one for it, or adding a language to a translation, returns
409MANAGED_USER_INACTIVE. - A customer may hold up to 50 A/B tests and 25 translations: another one returns
422BUSINESS_OPERATION_INVALID.
Moving Content to Another Managed User
The label on an item is not fixed. After a composition, a widget, an upload or a workflow was made, you can file it under another managed user, or take the label off so it is your own again. These calls are for your server, with your own partner key.
The
PUT names the managed user as when you file content: managedUserId or managedUserExternalId, one of the two. The body is JSON for all four calls, so it is camelCase even for an upload, whose form fields are snake_case. The DELETE takes no body.
managedUserId is null once the label is off:
What Widgetic checks on a move
- The item must be yours. Only the account that made a composition, a widget or an upload can move it. One that another account made and one that does not exist get the same
404, so nothing about other accounts can be learned. A workflow is moved in your partner workspace, and the call names the workspace the same way the other workflow calls do. - The call is not made for one customer. Send it with your own key and without
X-Managed-User-IdorX-Managed-User-External-Id. A call made for one customer, whether by an editor session or by that header, is refused with403MANAGED_USER_SCOPE_MISMATCH. Only you, with your own key, decide which customer an item belongs to. - The managed user is checked as when you file content. It must be one of yours (
404MANAGED_USER_NOT_FOUND) and switched on (409MANAGED_USER_INACTIVE), you name it one way (400MANAGED_USER_REFERENCE_AMBIGUOUSfor both) and in camelCase (400MANAGED_USER_REFERENCE_INVALID). Taking a label off a switched-off customer’s item is allowed. - A
PUThas to name a managed user. One that names none is400MANAGED_USER_REFERENCE_REQUIRED. It is never read as taking the label off, so a misspelled field cannot quietly unfile your work. Use theDELETEfor that. - Repeating is safe. Filing an item under the managed user it already has, or taking the label off an item that has none, answers
200and changes nothing. These calls need noIdempotency-Key. - A key you limited needs two scopes. A key made with only part of the access needs both
partner:writeandcontent:write(see Limit what a key can do): the Content preset alone is refused with403API_KEY_SCOPE_MISSING.
What moves, and what a move changes
From the moment of the move, a call or a list for the new customer reaches the item, and one for the previous customer finds
404. That covers an editor session, a call with the customer header and a list filtered by managedUserId or managedUserExternalId. The reports that group by customer (what each customer keeps and the analytics by customer) read the label when you ask, so they follow it too.
A move does not change who owns the item, which is still your account. It does not rewrite what was spent either: the credits an editor session took are noted for the customer who spent them (see What a Managed User Spent).
Taking a workflow’s label off makes it one of your own, and it is refused with 422 BUSINESS_OPERATION_INVALID and reason: "too_many_workflows" when your own workflows already fill your workspace. Archive or delete some, then ask again.
Thumbnails of Widgets and Compositions
To draw a tile for each of a customer’s widgets and compositions, you do not have to make a picture yourself. Every widget has a thumbnail, a picture of what it looks like, and Widgetic makes it for you: a little after the last build of a widget that has none, Widgetic opens the widget in a browser of its own and saves what it shows. A few minutes after the last build, Widgetic also draws a small line drawing of the widget, which stays clear in a small tile. A composition has no thumbnail of its own. It shows the thumbnail of the widget it is built on, so every composition made from one widget shows the same picture and the same drawing.A customer’s widgets
Ask for the widgets with the customer’s id, as in Compositions and widgets. Each widget in the answer carries its thumbnail (shortened here):A customer’s compositions
List the customer’s compositions. Each one carries thewidgetId of its widget:
widgetId once, up to 50 in a call, to POST /widgets/batch. The widget of a composition does not have to be filed under the customer, so ask for it by id:
data.widgets, each with its id and thumbnailUrl. Match them to the compositions by widgetId:
What to know about a thumbnail
- It can be
null. A widget that was never built has no thumbnail, and one that was just built gets it about a minute later. Draw a tile of your own untilthumbnailUrlis there, and read the widget again later. A widget made from one of your presets starts with the preset’s thumbnail. - The address is a public image. Use it as the
srcof animg. It changes when the picture is replaced, for example when the widget is published, so read it again rather than keeping it, and keep the widget’s id instead. thumbnailSvgis a drawing for small tiles. It is a small line drawing of the widget, as SVG text on a 32 by 32 canvas, and it has no colour of its own. Widgetic draws it a few minutes after the widget’s last build, so it isnulluntil then, and a widget need not have one. Where a picture is too small to read, show it as a mask, 32 pixels wide, in the middle of a tile in a colour of your choice, and showthumbnailUrlwhen it isnull.- Only your own widgets are answered. In
POST /widgets/batch, an id that is not one of your widgets comes back inerrors, like an id that does not exist, and the other widgets still come back. See Batch Fetch Widgets.
Preset Widgets
A preset is a widget of your own that you offer your customers as a ready-made starting point: a rating, a quiz, a poll. You choose which of your widgets are presets and give each one a short key that your code uses. Your server reads the list, your page draws its own picker, and your server makes what the customer picked. A workflow of yours can be offered as a starting point too, as long as every widget it chains is one of these presets: see Starting points.These are your presets, kept in your account. They are not the starter widgets that Widgetic puts on every new Widgetic account when it is made. Those belong to Widgetic and are copied at sign-up.
Register a preset
A preset is one of the widgets your own account made: a widget you built in the dashboard or with the Widget Creator, the onesGET /widgets lists. A widget id that is not in that list (another account’s, or one that does not exist) is refused with 404 PRESET_WIDGET_NOT_FOUND. Send PUT /partners/{partnerId}/presets/{key}:
Sending the same key again replaces the preset, so the call is safe to repeat and needs no
Idempotency-Key. It replaces the whole preset: a title, description or position you leave out goes back to its default. A widget can be a preset under one key only, and an account can have 100 presets.
DELETE /partners/{partnerId}/presets/{key} takes a widget off the list and answers { "removed": true }, or false (not an error) when there was no such preset. It leaves the widget, its copies and its compositions alone. Deleting the widget removes its preset. A workflow you offer as a starting point can chain only widgets that are presets, so taking a widget off the list makes the starting points that chain it unavailable until you offer the widget again (unavailableReason is widget_not_preset).
List the presets
GET /partners/{partnerId}/presets returns your presets, ordered by position and then by key. It is the same list for every customer, so call it from your server whenever your picker opens.
Make what the customer picked
There are two ways. The first needs no copy.- A composition, for the Composition Editor. Create it on the preset’s widget with
POST /compositions, naming the customer as in Filing Content Under a Managed User. The widget stays yours and the composition is the customer’s own content. The widget needs a published version before the composition can be shown on a page. - A copy to build on, for the Widget Creator.
POST /managed-users/{id}/presets/{key}/copygives the customer a widget of their own on a new canvas, filed under them. It needs anIdempotency-Key. The optionalname(up to 120 characters) names the copy; without it the copy takes the preset’s title, then the widget’s own name. Make it from your server when a customer picks a preset on your own page, and give the copy’scanvasIdandwidgetIdto the Widget Creator. The creator itself never lists your presets: with nocanvasIdit opens on the customer’s latest canvas, or on a blank one (see Where the creator starts).
canvasId and widgetId, with the customer’s editor session.
What a copy is:
- It is a draft widget in your account, filed under that customer, and no other customer’s editor can reach it.
- It carries the preset’s code, its Content and Design schemas, its content and its thumbnail, and it starts from a fork of the code, so the customer’s chat edits begin where yours left off. It does not carry the preset’s database, its compositions or its chat history. It is private and a draft, and it is not a preset itself.
- There is no limit on copies. A customer can have as many copies of a preset as you give them, and each one is its own draft. Call again with a new
Idempotency-Keyfor another copy; the same key gives you the first answer back. - A change you make to a preset’s widget later reaches the compositions you make from it and the copies you make afterwards. Copies made earlier are not touched.
- Read
warnings. When the preset’s code could not be forked, the copy opens as a preview and its code history starts empty, andwarningssays so.
Updating Managed Users
PUT /managed-users/{id} changes the externalId, the metadata and/or isActive. It needs an Idempotency-Key. The metadata is replaced as a whole, so send all of it:
true or false, not text:
"isActive": true to switch it back on.
Deleting Managed Users
DELETE /managed-users/{id} removes the record and answers 200 with {"message": "...", "id": "..."}. It does not delete anything else, but it does remove the label: the compositions, widgets, uploads and workflows that were filed under the managed user stay in your account, with managedUserId back to null. Its editor sessions end. So when a customer leaves, list their items first (GET /compositions?managedUserId=...), delete what you want gone (DELETE /compositions/{id}), and only then delete the managed user.
A customer’s workflows stay too, and keep running on every page that shows them. Pause or delete the ones that should stop before you delete the managed user: a session made for that customer, or your key with their header, lists theirs, and your own sign-in lists every customer’s (see Workflows).
The same goes for a customer’s A/B tests and translations: they stay in your account, and a test that is running or a translation that is active keeps being shown. Pause or delete them first, with your key and the customer’s header (see A/B Tests and Translations).
Managed User Entitlements
Entitlements are read only: Widgetic sets them and you cannot change them through the API.GET /entitlements/managed-users/{managedUserId}lists the entitlements of one managed user. The answer hasdata.managedUserIdanddata.entitlements.GET /entitlements/partners/{partnerId}lists what your partner record is entitled to.- Both accept
feature,sourceandincludeExpiredas filters. - Each entitlement has a
feature, avalue, asource(subscription,contract,manual,marketplaceoraddon) andexpiresAt.
What a Managed User Spent
Your account pays for the AI, so your credit ledger does not say which customer used what. For what a customer does in an editor session, Widgetic keeps a note of each call that took credits, and adds the notes up for one customer over a period:What a Managed User Keeps
The files a customer keeps are counted for them too.GET /partners/{partnerId}/storage/usage says how many files and how many bytes each of your managed users has, split into what is in your own storage and what is with Widgetic, with the heaviest first. A file counts for a customer when it was filed under them (an upload that names the managed user, or one that came through their editor session). The answer is counted when you ask, so it is always current. See What Each Customer Keeps for the answer and an example.
Keep Your Own Mapping
Widgetic records which managed user a composition, a widget or an upload was filed under, but it does not know your customers’ permissions: which of them may open which composition is decided by your platform. Keep a small mapping of your own, and use the filter for listing:- A customers table: your customer id, and the Widgetic managed-user
id. - A widgets table (optional): your customer id, the Widgetic composition
id, and the WidgeticwidgetIdit is built on. Handy when you show a customer a page of their compositions without calling Widgetic, and when you decide who may open one. - Put the customer in the composition name as well, for example
your-platform-user-123 / homepage slider, so a person looking in the Widgetic dashboard can tell whose it is.
User Metadata Schema
Themetadata field is flexible, but we recommend including:
role here does not change what anyone can do in Widgetic.
Best Practices
Use Meaningful External IDs
Use Meaningful External IDs
Use your platform’s user ID as the
externalId for easy correlation:Handle User Deletion
Handle User Deletion
When a user leaves your platform, list their compositions with
managedUserId, delete what you want gone, then delete their managed user. Deleting a managed user does not delete anything else, but the items that were filed under it lose the label and become your account’s own. That includes the customer’s workflows, A/B tests and translations, which keep running until you pause or delete them.Always Send the Filter From Your Server
Always Send the Filter From Your Server
List a customer’s items with
managedUserId or managedUserExternalId on every call, from your own backend. A call without the filter lists everything on your account, for every customer.Error Handling
Common errors when working with managed users. Branch onerror.code in the answer (see Errors):
Next Steps
Editor Sessions
Let a customer use Widgetic’s editors in your page
Credits & Billing
How you pay and how credits work
API Reference
Find entitlement endpoints and access levels