The WorkOS API enables adding Enterprise Ready features to your application. This REST API provides programmatic access to AuthKit (user management), Single Sign-On, Directory Sync, and Audit Log resources.
Sign in to see code examples customized with your API keys and data.
https://api.workos.com
WorkOS offers native SDKs in several popular programming languages. Choose one language below to see our API Reference in your applicationβs language.
Don't see an SDK you need? Contact us to request an SDK!
Install the SDK using the command below.
npm install @workos-inc/node
You can test the API directly with cURL, or use the Postman collection for convenience.
Check out the guide about the WorkOS API Postman collection to learn more about it.
WorkOS authenticates your API requests using your accountβs API keys. API requests made without authentication or using an incorrect key will return a 401 error. Requests using a valid key but with insufficient permissions will return a 403 error. All API requests must be made over HTTPS. Any requests made over plain HTTP will fail.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789');
You can view and manage your API keys in the WorkOS Dashboard.
API keys can perform any API request to WorkOS. They should be kept secure and private! Be sure to prevent API keys from being made publicly accessible, such as in client-side code, GitHub, unsecured S3 buckets, and so forth. API keys are prefixed with sk_.
Your Staging Environment comes with an API key already generated for you. Staging API keys may be viewed as often as they are needed and will appear inline throughout our documentation in code examples if you are logged in to your WorkOS account. API requests will be scoped to the provided keyβs Environment.
Once you unlock Production access you will need to generate an API Key for it. Production API keys may only be viewed once and will need to be saved in a secure location upon creation of them.
WorkOS uses standard HTTP response codes to indicate the success or failure of your API requests.
2004004014034044224295xxMany top-level resources have support for bulk fetches via list API methods. For instance, you can list connections, list directory users, and list directory groups. These list API methods share a common structure, taking at least these four parameters: limit, order, after, and before.
WorkOS utilizes pagination via the after and before parameters. Both parameters take an existing object ID value and return objects in either descending or ascending order by creation time.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); let list = await workos.sso.listConnections({ limit: 100, order: 'desc' }); let connections = list.data; let after = list.listMetadata.after; while (after) { list = await workos.sso.listConnections({ limit: 100, after: after, order: 'desc', }); connections = connections.concat(list.data); after = list.listMetadata.after; }
Parameters WorkOS APIs are rate limited to ensure that they are fast for everyone. If you find yourself getting 429 errors, double check your integration to make sure you arenβt making unnecessaryΒ requests.
| Name | Path | Limit |
|---|---|---|
| All requests | * | 6,000Β requestsΒ perΒ 60Β seconds perΒ IPΒ address |
This rate limits applies to all environments, staging and production. Exceptions to the general rate limit are listed below.
| Name | Path | Limit |
|---|---|---|
| GetΒ AuthorizationΒ URL | /sso/authorize | 1,000Β requestsΒ perΒ 60Β seconds perΒ connection |
| Name | Path | Limit |
|---|---|---|
| Directory Users | /directory_users | 4Β requestsΒ perΒ second per directory |
| Name | Path | Limit |
|---|---|---|
| Delete Organization | /organizations/* | 50 requests per 60 seconds per API key |
Rate limiting for AuthKit APIs are enforced on a per environment basis.
| Name | Path | Limit |
|---|---|---|
| Reads | /user_management/* | 1,000Β requestsΒ perΒ 10Β seconds |
| Writes | /user_management/* | 500Β requestsΒ perΒ 10Β seconds |
| Authentication | /user_management/authenticate | 10Β requestsΒ perΒ 60Β seconds perΒ email orΒ challengeΒ ID |
| MagicΒ Auth | /user_management/magic_auth/send | 3Β requestsΒ perΒ 60Β seconds perΒ email |
| EmailΒ verification | /user_management/:id/email_verification/send | 3Β requestsΒ perΒ 60Β seconds perΒ user |
| PasswordΒ reset | /user_management/password_reset/send | 3Β requestsΒ perΒ 60Β seconds perΒ email |
| Name | Limits |
|---|---|
| Reads | 1,000Β requestsΒ perΒ 10Β seconds |
| Writes | 500Β requestsΒ perΒ 10Β seconds |
| SSO sign-ins | 3Β requestsΒ perΒ 60Β seconds perΒ IPΒ address |
| EmailΒ sign-ins | 10Β requestsΒ perΒ 60Β seconds perΒ email andΒ IPΒ address |
| MagicΒ AuthΒ sign-ins | 10Β requestsΒ perΒ 60Β seconds perΒ IPΒ address andΒ challengeΒ ID |
| MagicΒ AuthΒ codeΒ requests | 3Β requestsΒ perΒ 60Β seconds perΒ IPΒ address andΒ email |