WorkOS Python Library
The WorkOS library for Python provides convenient access to the WorkOS API from applications written in Python, hosted on PyPI.
Documentation
See the API Reference for Python usage examples.
Installation
Requires Python 3.10+.
pip install workos
Quick Start
from workos import WorkOSClient
client = WorkOSClient(api_key="sk_1234", client_id="client_1234")
# List organizations
page = client.organizations.list_organizations()
for org in page.auto_paging_iter():
print(org.name)
# Create an organization
org = client.organizations.create_organization(name="Acme Corp")
print(org.id)
Async Client
Every HTTP API method has an identical async counterpart on AsyncWorkOSClient. (Pure-local utilities such as webhook signature verification, Actions helpers, and PKCE are synchronous on both clients.)
from workos import AsyncWorkOSClient
async_client = AsyncWorkOSClient(api_key="sk_1234", client_id="client_1234")
page = await async_client.organizations.list_organizations()
async for org in page.auto_paging_iter():
print(org.name)
Environment Variables
The client reads credentials from the environment when not passed explicitly:
| Variable | Description |
|---|---|
WORKOS_API_KEY |
WorkOS API key |
WORKOS_CLIENT_ID |
WorkOS client ID |
WORKOS_BASE_URL |
Override the API base URL (defaults to https://api.workos.com/) |
WORKOS_REQUEST_TIMEOUT |
HTTP timeout in seconds (defaults to 60) |
Available Resources
The client exposes the WorkOS API through typed namespace properties:
| Property | Description |
|---|---|
client.sso |
Single Sign-On connections and authorization |
client.organizations |
Organization management |
client.organization_domains |
Organization domain verification |
client.organization_membership |
Organization membership management |
client.user_management |
Users, identities, auth methods, invitations |
client.directory_sync |
Directory connections and directory users/groups |
client.groups |
Organization group management |
client.admin_portal |
Admin Portal link generation |
client.audit_logs |
Audit log events, exports, and schemas |
client.authorization |
Fine-Grained Authorization (FGA) resources, roles, permissions, and checks |
client.events |
Events API |
client.webhooks |
Webhook endpoint management and event verification |
client.feature_flags |
Feature flag management (list, enable/disable, targeting) |
client.api_keys |
Organization API key management |
client.client_api |
Client API token generation |
client.connect |
OAuth application management |
client.widgets |
Widget session tokens |
client.multi_factor_auth |
MFA enrollment and verification (also available as client.mfa) |
client.pipes |
Data Integrations |
client.pipes_provider |
Organization data integration configuration |
client.radar |
Radar risk scoring |
client.passwordless |
Passwordless authentication sessions |
client.vault |
Encrypted data vault |
client.actions |
AuthKit Actions signature verification and response signing |
client.pkce |
PKCE code verifier/challenge helpers |
Pagination
Paginated endpoints return SyncPage[T] (or AsyncPage[T]) with built-in auto-pagination:
# Iterate through all pages automatically
for user in client.user_management.list_users().auto_paging_iter():
print(user.email)
# Or work with a single page
page = client.user_management.list_users(limit=10)
print(page.data) # List of items on this page
print(page.has_more()) # Whether more pages exist
print(page.after) # Cursor for the next page
Error Handling
All API errors map to typed exception classes with rich context:
from workos import NotFoundError, RateLimitExceededError
try:
client.organizations.get_organization("org_nonexistent")
except NotFoundError as e:
print(f"Not found: {e.message}")
print(f"Request ID: {e.request_id}")
except RateLimitExceededError as e:
print(f"Retry after: {e.retry_after} seconds")
| Exception | Status Code |
|---|---|
BadRequestError |
400 |
AuthenticationError |
401 |
AuthorizationError |
403 |
NotFoundError |
404 |
ConflictError |
409 |
UnprocessableEntityError |
422 |
RateLimitExceededError |
429 |
ServerError |
5xx |
Retries
The client automatically retries requests up to 3 times (configurable via the max_retries request option) on 429 and 5xx responses, timeouts, and connection errors, using exponential backoff with jitter and honoring Retry-After. The SDK attaches an auto-generated Idempotency-Key (UUID v4) to every POST request and reuses the same key across its internal retries.
Per-Request Options
Every API method accepts request_options for per-call overrides (local helpers such as webhook/Actions signature verification and PKCE utilities do not make HTTP calls and don't take request_options):
result = client.organizations.list_organizations(
request_options={
"timeout": 10,
"max_retries": 5,
"extra_headers": {"X-Custom": "value"},
"idempotency_key": "my-key",
"base_url": "https://staging.workos.com/",
}
)
Type Safety
This SDK ships with full type annotations (py.typed / PEP 561) and works with mypy, pyright, and IDE autocompletion out of the box. All API resource models are @dataclass(slots=True) classes with from_dict() / to_dict() for serialization.
SDK Versioning
WorkOS follows Semantic Versioning. Breaking changes are only released in major versions. We strongly recommend reading changelogs before making major version upgrades.
Beta Releases
WorkOS has features in Beta that can be accessed via Beta releases. We would love for you to try these and share feedback with us before these features reach general availability (GA). To install a Beta version, please follow the installation steps above using the Beta release version.
Note: there can be breaking changes between Beta versions. We recommend pinning the package version to a specific version.
More Information
Metadata
Release files for workos 10.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| workos-10.0.1.tar.gz | 229.8 kB | Without provenance | Details for workos-10.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| workos-10.0.1-py3-none-any.whl | Python 3 | none | any | Details for workos-10.0.1-py3-none-any.whl |
Total release size: 901.5 kB
Release files / workos-10.0.1.tar.gz
| Download URL | workos-10.0.1.tar.gz |
|---|---|
| Size | 229.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4f0beed6e4c321fa05ff4cd0b0b527a188d19f5e8847e18e9bf9d7de930416a
|
|
BLAKE2b-256 checksum How to use checksums |
cacff8fcaad0f2a0e21750f01279f2261a97489f2819abac8a4148ce8e6606f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / workos-10.0.1-py3-none-any.whl
| Download URL | workos-10.0.1-py3-none-any.whl |
|---|---|
| Size | 671.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b149e5cfe36484dc87c9ec140840669ad8a202b0ad35dbe6551fcd4f26840e7d
|
|
BLAKE2b-256 checksum How to use checksums |
6ee0230adb498f2ef4d94930e8494bf66a54f27426a75f088f5a833e85b4503a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for workos 10.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.