Intents
Intents
Section titled “Intents”Intent tokens provide account-scoped authorization for web components, allowing browsers to access Gateway APIs on behalf of a specific account.
Create Intent Token
Section titled “Create Intent Token”Generate a short-lived token for account-scoped operations:
POST /api/2.0/app/intent/{account:remote_id}Authorization: Bearer YOUR_APP_TOKENContent-Type: application/json
{ "scopes": [ "webcomponent:integration-read", "webcomponent:integration-event", "webcomponent:integration-install" ]}Path Parameters
Section titled “Path Parameters”| Parameter | Description |
|---|---|
account:remote_id | The account’s remote_id (e.g., myapp_tenant_12345) |
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
scopes | array | ✅ Yes | Array of webcomponent scopes |
Available Scopes
Section titled “Available Scopes”webcomponent:app-read- Read app infowebcomponent:integration-read- List/view integrationswebcomponent:integration-event- Execute integration eventswebcomponent:integration-create- Install integrationswebcomponent:integration-update- Update integrationswebcomponent:integration-install- Install/uninstall operationswebcomponent:integration-schedule- Manage schedules
Response
Section titled “Response”Status: 200 OK
{ "data": { "token": "intent_abc123xyz...", "expires_at": "2024-01-15T11:30:00.000000Z" }}Using Intent Tokens
Section titled “Using Intent Tokens”Intent tokens enable embedded web components to access account-specific data:
// In your web application, generate intent token server-sideconst intentToken = await fetch('/api/generate-intent', { method: 'POST', body: JSON.stringify({ accountId: 'myapp_tenant_12345' })});
// Pass token to frontend web component<gateway-integrations-component intent-token="${intentToken}" gateway-url="https://<GATEWAY_URL>"/>Complete Example
Section titled “Complete Example”// Server-side: Generate intent tokenpublic function generateIntentToken(Request $request){ $accountRemoteId = 'myapp_' . $request->user()->id;
$response = Http::withToken($this->gatewayAppToken) ->post("https://<GATEWAY_URL>/api/2.0/app/intent/{$accountRemoteId}", [ 'scopes' => [ 'webcomponent:integration-read', 'webcomponent:integration-event', ] ]);
return response()->json([ 'intent_token' => $response->json()['data']['token'] ]);}// Frontend: Use intent token with web componentasync function loadGatewayComponent(accountId) { // Get intent token from your backend const response = await fetch('/api/gateway/intent', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ account_id: accountId }) });
const { intent_token } = await response.json();
// Initialize web component with intent token const component = document.querySelector('gateway-integrations'); component.setAttribute('intent-token', intent_token); component.setAttribute('gateway-url', 'https://<GATEWAY_URL>');}Security Notes
Section titled “Security Notes”[!IMPORTANT] Intent tokens should be generated server-side and passed to the frontend. Never expose your app-level access token in browser code.
Token Lifecycle:
- User accesses your application
- Your backend generates intent token for their account
- Frontend receives intent token
- Web component uses intent token to access Gateway APIs
- Intent token expires (typically 1 hour)