Widgets are React components that provide complete functionality for common enterprise app workflows.
Generate a widget token scoped to an organization and user with the specified scopes.
curl --request POST \ --url "https://api.workos.com/widgets/token" \ --header "Authorization: Bearer sk_example_123456789" \ --header "Content-Type: application/json" \ -d @- <<'BODY' { "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", "scopes": [ "widgets:users-table:manage" ] } BODY
{ "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InNlc3Npb24..." }
| curl --request POST \ | |
| --url "https://api.workos.com/widgets/token" \ | |
| --header "Authorization: Bearer sk_example_123456789" \ | |
| --header "Content-Type: application/json" \ | |
| -d @- <<'BODY' | |
| { | |
| "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", | |
| "scopes": [ | |
| "widgets:users-table:manage" | |
| ] | |
| } | |
| BODY |
| import { WorkOS } from '@workos-inc/node'; | |
| const workos = new WorkOS('sk_example_123456789'); | |
| const { token } = await workos.widgets.getToken({ | |
| organizationId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', | |
| userId: 'user_01EHZNVPK3SFK441A1RGBFSHRT', | |
| scopes: ['widgets:users-table:manage'], | |
| }); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.widgets.create_token(organization_id: "org_01EHZNVPK3SFK441A1RGBFSHRT") |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.widgets.create_token(organization_id="org_01EHZNVPK3SFK441A1RGBFSHRT") |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.Widgets().CreateToken(context.Background(), &workos.WidgetsCreateTokenParams{ | |
| OrganizationID: "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| }) | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos | |
| ->widgets() | |
| ->createToken(organizationId: "org_01EHZNVPK3SFK441A1RGBFSHRT"); |
| import com.workos.WorkOS; | |
| import com.workos.widgets.WidgetsApi.CreateTokenOptions; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| CreateTokenOptions options = | |
| CreateTokenOptions.builder().organizationId("org_01EHZNVPK3SFK441A1RGBFSHRT").build(); | |
| workos.widgets.createToken(options); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.Widgets.CreateTokenAsync(new WidgetsCreateTokenOptions { | |
| OrganizationId = "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| }); |
| use workos::Client; | |
| use workos::widgets::CreateTokenParams; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .widgets() | |
| .create_token( | |
| CreateTokenParams { | |
| organization_id: "org_01EHZNVPK3SFK441A1RGBFSHRT".into(), | |
| ..Default::default() | |
| } | |
| ) | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InNlc3Npb24..." | |
| } |
POST/widgets /tokenReturns