Authorization header with your API key or editor session token.
Authentication Methods
API Keys (Server-Side)
API keys are the recommended authentication method for server-side applications. They provide persistent access without expiration.Editor Sessions (For Customer Browsers)
To run Widgetic’s editors inside your own page for one of your customers, mint a short-lived editor session on your server and pass that session token to the browser.API Key Types and Access Levels
Your API key prefix determines your role and what endpoints you can access:Understanding Access Levels
Each API endpoint specifies anx-access-level that determines which roles can access it:
public: Any authenticated user can access (any key type)user: Requires user-level access or higherpartner: Requires partner-level access or higheradmin: Requires admin-level access only
The
x-access-level is a role gate, not a visibility gate. All public endpoints appear in the documentation, but your access depends on your key type.Limit What a Key Can Do
A key made without a limit has full access: it does everything its owner can, and so does every key made before limits existed. A key you put on a build server, or in a partner’s backend, needs only the part of the API it uses. Limit it, and a leaked key can do no more than that. You choose the limit when you make the key, in the dashboard (Workspace settings → API keys) or withPOST /users/{id}/keys (see Security). Send a preset or a list of scopes, never both:
When a preset is not enough, name the scopes you want:
- Writing includes reading. Naming
content:writegivescontent:readtoo, and the same goes for the otherwritescopes. A list that names every scope makes a key with full access. - Scopes only narrow. A limited key still needs what its owner needs: the role, the plan and, for a partner, an account in force.
- The limit is fixed when the key is made. To widen it, make a new key and delete the old one.
- A limited key cannot make itself a bigger one. Making, changing and deleting keys, exchanging tokens, signing in and the administration routes need full access.
- Changing the Brand Kit needs full access, because a change reshapes every widget the account makes from then on. A key with
account:readmay look at it. See Brand Kit. - The MCP server needs full access.
https://mcp.widgetic.comhands an assistant every tool your account has, so only a key made with full access opens it, and a limited key is refused with403. See Authentication for AI assistants. - A partner’s backend needs three scopes to start an editor session for a managed user:
partner:write,content:writeandgeneratetogether. See Editor Sessions.
403 and the code API_KEY_SCOPE_MISSING. error.details.missingScopes lists what a new key needs, and error.details.fullAccessRequired is true when no list of scopes would have been enough:
These scopes belong to the key and last as long as it does. To give a customer’s browser limited, short-lived access to only that customer’s content, mint an editor session on your server instead.
Validating Tokens
You can validate a token to check its status and associated permissions:Best Practices
Keep API Keys Secure
Keep API Keys Secure
- Never expose API keys in client-side code
- Use environment variables to store keys
- Rotate keys periodically
- Use the token exchange flow for browser applications
Use Appropriate Key Types
Use Appropriate Key Types
- Use
wgt_usr_keys for personal development - Use
wdg_org_keys for organization-wide applications - Use
wgt_prt_keys for partner integrations
Handle Token Expiration
Handle Token Expiration
- JWT tokens expire after a set period
- Implement token refresh logic in your application
- Use the SDK’s async token provider for automatic handling
Error Responses
When authentication fails, you’ll receive one of these responses:
Example error response:
Next Steps
Partner Authentication
Learn about partner-specific authentication flows
API Reference
Explore all available endpoints