Skip to main content
The Widgetic API uses Bearer token authentication. All requests must include an 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 an x-access-level that determines which roles can access it:
  • public: Any authenticated user can access (any key type)
  • user: Requires user-level access or higher
  • partner: Requires partner-level access or higher
  • admin: 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 with POST /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:write gives content:read too, and the same goes for the other write scopes. 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:read may look at it. See Brand Kit.
  • The MCP server needs full access. https://mcp.widgetic.com hands an assistant every tool your account has, so only a key made with full access opens it, and a limited key is refused with 403. See Authentication for AI assistants.
  • A partner’s backend needs three scopes to start an editor session for a managed user: partner:write, content:write and generate together. See Editor Sessions.
A request outside the scopes of the key is refused with 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:
Response:

Best Practices

  • 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 wgt_usr_ keys for personal development
  • Use wdg_org_ keys for organization-wide applications
  • Use wgt_prt_ keys for partner integrations
  • 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