Codex workload identity federation (WIF) is in an invite-only beta. If your organization is interested in participating, contact your OpenAI account representative.
Overview
This guide brings together Codex runtime setup and programmatic administration for managed ChatGPT workspaces.
Before you begin, confirm with your OpenAI account representative that WIF is enabled for your organization and the workspace you plan to use.
If your workload calls the OpenAI API directly, follow the API Platform federation guide.
Choose your setup path
Admin Portal: Follow Part 1 to connect a workload, then configure and verify the Codex process.
Infrastructure tooling or CI: Use Part 2 to create the provider and federation rule through the Admin API, then complete the runtime steps in Part 1.
Reference and operations: Part 3 covers matching rules, where to configure WIF, audit attribution, access changes, and limits.
Troubleshooting: Find fixes for common setup and authentication issues.
Part 1. Set up and run Codex
How it works
Codex obtains a short-lived identity token from a protected file or requests a SPIFFE JWT-SVID from a local SPIRE Agent socket. OpenAI verifies the token against the configured provider and federation rule, then issues a short-lived access token for one existing ChatGPT principal in the selected workspace.
Workload identity token
-> provider verification
-> federation rule
-> one ChatGPT principal in one managed workspace
-> short-lived OpenAI access tokenIn file mode, a trusted host process keeps the token current. In socket mode, the SPIRE Agent supplies a JWT-SVID on demand. Token exchange uses an existing principal and workspace membership.
Prerequisites
A managed ChatGPT workspace with WIF enabled.
Permission to manage workload identity in the OpenAI Admin Portal.
An active ChatGPT user or service account in that workspace, or permission to create one during portal setup. Creating a human user consumes a workspace seat and follows the workspace's membership rules.
Codex 0.148.0 or later for file mode. For SPIRE, see the socket setup.
An OIDC token or SPIFFE JWT-SVID with known issuer, audience, subject, and identifying claims.
A protected token file refreshed by a trusted process, or a local SPIRE Agent socket.
An effective Codex authentication policy that permits ChatGPT authentication and the workspace selected by the rule.
On native Windows, use the elevated Windows sandbox. Other Windows sandbox modes cannot protect the identity-token file from model-controlled commands. For Linux, macOS, and WSL, configure the managed read denial described below.
1. Obtain an upstream identity token
Decode a sample token locally and record its iss, aud, sub, iat, exp, and any claims you intend to match. Decoding does not verify the signature.
| Provider or environment | How to obtain a token |
|---|---|
| Kubernetes, AKS, EKS, or GKE | Mount a projected service-account token. Point Codex at the file that the platform rotates. |
| Microsoft Entra managed identity | Use a trusted host process or sidecar to request a token from Azure IMDS and replace the file before expiry. |
| AWS outbound identity federation | Use a trusted host process to call regional STS GetWebIdentityToken and replace the file before expiry. |
| Google Cloud | Use a trusted host process to request an identity token from the metadata server and refresh the file. |
| Oracle Cloud Infrastructure | Use a trusted host process with an instance principal to request an IDCS access token and refresh the file. |
| GitHub Actions | Request the job's OIDC token and write it to a protected file. Request a new token before a later exchange. |
| SPIFFE | Use the local SPIRE socket setup below, or write a current JWT-SVID to a file. |
| Custom OIDC provider | Use the issuer's workload flow and refresh the protected file before the JWT expires. |
Provider-specific token issuance guides are linked in Related resources.
Do not paste production tokens into a website or write them to logs.
2. Connect the workload in the Admin Portal
Skip this section if you provision the provider and rule using Part 2.
If you use a SPIRE Agent socket, skip the configuration download. After you create the rule, copy the federation rule ID and go to Use a local SPIRE Agent socket.
Go to Workload identity in the OpenAI Admin Portal.
Select Connect workload. Reuse a provider configured for Codex, or create a provider for the issuer and trust boundary.
Select Codex and the managed workspace the workload may use.
Add the narrowest identity conditions that identify the workload: a subject, exact claims, a CEL condition, or a combination. Add accepted audiences. Every configured check must pass.
Map the rule to one existing ChatGPT user or service account, or create one during setup.
Review the provider, conditions, workspace, principal, scopes, and access-token lifetime.
Select Connect workload, then Download config.
The downloaded configuration contains a non-secret federation rule ID and the identity-token file path. It does not contain a credential.
3. Configure and protect the Codex process
For file mode, set both variables in the environment of the process that starts Codex:
export OPENAI_FEDERATION_RULE_ID="idpm_..."
export OPENAI_IDENTITY_TOKEN_FILE="/var/run/secrets/openai.com/identity-token"The rule ID is not secret. The token file is. Use an absolute path in a dedicated directory owned by the workload account with mode 0700. Keep it outside repositories and other locations available to Codex tools. Only trusted host processes should write there.
For managed Linux, macOS, and WSL deployments, deny reads of the entire token directory in managed requirements:
[permissions.filesystem]
deny_read = ["/var/run/secrets/openai.com"]This protects the active token and temporary replacements from model-controlled commands while the Codex host process can still read the token for exchange. For projected-token volumes, deny the whole mount and any backing or resolved target paths outside it. File modes and environment-variable scrubbing alone do not protect a credential from another process running as the same user.
For token sources that do not project a file, use a trusted host-owned refresh process. Provision the protected directory first, then adapt this example to the provider's token command:
set -eu
TOKEN_DIR="/var/run/secrets/openai.com"
TOKEN_FILE="$TOKEN_DIR/identity-token"
umask 077
TOKEN_TEMP="$(mktemp "$TOKEN_DIR/.identity-token.XXXXXX")"
trap 'rm -f -- "$TOKEN_TEMP"' EXIT
trap 'exit 1' HUP INT TERM
your-identity-provider-command > "$TOKEN_TEMP"
test -s "$TOKEN_TEMP"
mv -f -- "$TOKEN_TEMP" "$TOKEN_FILE"The provider command above is a placeholder, not a runnable token issuer. Run the refresh process outside shells or tools controlled by Codex. Write replacements inside the denied directory and rename them atomically so Codex cannot read a partial token. Keep the read denial in place during refresh and cleanup, including after a forced stop.
Do not put workload identity settings in config.toml. Keep credentials out of logs, shell history, repositories, and build artifacts.
4. Verify authentication
Load the downloaded environment file, using its actual filename, then check the authentication method:
. ./workload-identity-idpm_example.env
codex login statusIn PowerShell:
$env:OPENAI_FEDERATION_RULE_ID = "idpm_..."
$env:OPENAI_IDENTITY_TOKEN_FILE = "C:\run\openai\identity-token"
codex login statusA successful check prints:
Logged in using workload identityThis confirms a token exchange through the configured rule. Confirm the workspace, principal, and rule in the Admin Portal before running the workload. If another authentication method appears, check that the WIF environment reached the process.
If replay protection is enabled and the assertion has a jti claim, the status check consumes that jti. Write a newly issued assertion with a new jti before starting another Codex process.
Run a small request from the same environment:
codex exec "Reply with only: workload identity is working"Codex holds the OpenAI access token in memory. It does not write either credential to auth.json, the system keyring, or config.toml.
5. Keep tokens current in file mode
Refresh the upstream token file before the token expires. Codex rereads the file when it needs a new OpenAI access token.
The OpenAI token expires at the earlier of the upstream token's expiry and the rule's configured lifetime. It never lasts longer than one hour.
With replay protection, a non-empty JWT jti can be used only once for that provider until the assertion expires. Obtain a new assertion with a new jti before each exchange, including retries after an exchange with an unknown outcome.
Assertions without jti do not receive replay protection. Empty, null, or non-string jti values are invalid.
Concurrent requests inside one Codex host process share an in-memory exchange session and refresh. Separate processes perform separate exchanges and need assertions the provider permits them to use.
6. Move an existing workload to WIF using a token file
In file mode, either required variable selects WIF ahead of other credentials. An incomplete setup fails. OPENAI_WORKLOAD_IDENTITY_CONTEXT alone does not select WIF.
Configure and validate the provider and rule while the existing credential remains available.
Start a new Codex process with both required WIF variables. WIF takes precedence even if the old credential is still present.
After the workload succeeds with WIF, remove the old credential from the runtime and secrets store, then revoke it.
Before revoking the old credential, you can roll back by removing both required WIF variables and starting a new process.
An SDK apiKey option becomes CODEX_API_KEY, but WIF still takes precedence. Omit apiKey when using WIF so the workload does not carry an unused long-lived credential. When neither required WIF variable is present, normal credential rules apply: CODEX_API_KEY takes precedence on API-key-capable exec, review, TypeScript SDK, and remote exec-server surfaces; other surfaces can use CODEX_ACCESS_TOKEN or a stored login.
Use a local SPIRE Agent socket
Use this alternative when Codex runs on a Unix host with a local SPIRE Agent. Codex obtains a JWT-SVID directly from the SPIFFE Workload API and exchanges it for an OpenAI access token. Use an approved Codex build that includes socket support, such as 0.171.0-alpha.2.
1. Register the workload and configure the rule
Register the Codex host process with SPIRE so the agent can attest it and issue its JWT-SVID. In the Admin Portal or API, configure a SPIFFE JWT-SVID provider for the trust domain and a Codex rule that matches the workload’s SPIFFE ID. Add the exact audience you want Codex to request to the rule’s accepted audiences.
2. Configure the Codex process
Set these variables where the process that owns authentication runs. For a remote app-server, configure the server host. Use your agent’s actual absolute Unix socket path with the unix:// scheme.
unset OPENAI_IDENTITY_TOKEN_FILE
export OPENAI_FEDERATION_RULE_ID="idpm_..."
export OPENAI_IDENTITY_TOKEN_SOURCE="spiffe"
export SPIFFE_ENDPOINT_SOCKET="unix:///run/spire/agent.sock"
export OPENAI_SPIFFE_AUDIENCE="openai-codex"
export OPENAI_SPIFFE_ID="spiffe://example.org/workload"Replace the audience with a value accepted by your rule. OPENAI_SPIFFE_ID selects the identity when the agent can return multiple JWT-SVIDs. You can omit it if the agent returns exactly one identity. Codex supports local Unix sockets in this mode.
3. Protect the socket and verify
Treat access to the socket as access to the workload credential. Use workload attestation and process isolation so model-controlled commands and tools cannot connect to the socket or obtain the same identity. The standard SPIFFE_ENDPOINT_SOCKET variable can still reach child processes.
codex login statusA successful check prints Logged in using workload identity. Codex reconnects to the agent and requests a JWT-SVID for each exchange, including on refresh. It keeps the assertion and access token in memory. If the agent reuses a JWT-SVID and replay protection is enabled, make sure each exchange uses an unused jti when present.
If login fails, verify that the agent socket is reachable from the Codex process, SPIRE attests that process, and the selected identity and audience match your rule.
For details on socket requirements and environment variables, see the Codex SPIFFE configuration reference.
Part 2. Automate setup with the Admin API
Use these APIs to configure Codex access to managed ChatGPT workspaces. Confirm WIF enablement and the available API origins with your OpenAI contact. Keep administrator credentials in a secrets manager and separate from the Codex runtime.
Choose the API and credential
| API | When to use it | Required credential |
|---|---|---|
| Workspace API | Manage providers owned by your workspace and their federation rules. | A workspace-bound personal access token (PAT) with the chatgpt.workspace.workload_identity.write scope. The token owner must be an active workspace owner or admin. |
| Tenant API | Manage a tenant-owned provider across linked workspaces, with a separate rule for each target workspace and principal. | A Tenant Admin Key with tenant.workload_identity.read for reads or tenant.workload_identity.write for writes. The key identifies the tenant. Confirm that Tenant Admin Keys are enabled for your tenant. |
| Organization Admin API | Use this API for workspaces in your organization’s linked tenant if OpenAI has enabled it for your organization. | An organization Admin API key. The key owner must be an active organization administrator and a member of the linked tenant with the required WIF permissions. |
Provider ownership controls who can change trust settings or disable or archive the provider. Workspace admins can view the rules that apply to their workspace under a tenant-owned provider. Only admins with tenant-level permissions can edit those rules.
API endpoints
Workspace API
Base path on your enabled workspace API origin. Use the workspace PAT as a bearer token.
/v1/workspaces/{workspace_id}/workload-identity| HTTP method | Relative path | Action |
|---|---|---|
| GET | /providers | List providers and bindings |
| POST | /providers | Create a workspace provider |
| GET | /providers/{provider_id} | Get a provider and its inventory |
| PATCH | /providers/{provider_id} | Update or disable |
| DELETE | /providers/{provider_id} | Archive |
| POST | /providers/{provider_id}/bindings | Bind the provider to this workspace |
BINDING_PATH = /providers/{provider_id}/bindings/{binding_id}| HTTP method | Relative path | Action |
|---|---|---|
| POST | {BINDING_PATH}/mappings | Create a federation rule |
| GET | {BINDING_PATH}/mappings/{mapping_id} | Get a rule |
| PATCH | {BINDING_PATH}/mappings/{mapping_id} | Update or disable a rule |
| DELETE | {BINDING_PATH}/mappings/{mapping_id} | Archive a rule |
Set WORKSPACE_API_ORIGIN to your approved workspace API origin. Use the binding_id from the binding response and the ID of an existing workspace principal.
export WORKSPACE_WIF_PAT="<workspace-wif-pat>"
WORKSPACE_WIF_BASE="$WORKSPACE_API_ORIGIN/v1/workspaces/$WORKSPACE_ID/workload-identity"
curl --fail-with-body --silent --show-error \
"$WORKSPACE_WIF_BASE/providers/$PROVIDER_ID/bindings/$BINDING_ID/mappings" \
-H "Authorization: Bearer $WORKSPACE_WIF_PAT" \
--json '{"principal_id":"<principal-id>","external_subject":"<workload-subject>"}'Use the returned mapping_id as OPENAI_FEDERATION_RULE_ID in Part 1.
Tenant API
Use the Tenant Admin Key as a bearer token. The provider collection is the base URL. Use the collection URL directly for list and create.
export OPENAI_TENANT_ADMIN_KEY="<tenant-admin-key>"
TENANT_WIF_BASE="https://api.openai.com/v1/tenant/workload_identity_providers"| HTTP method | Relative path | Action |
|---|---|---|
| GET | (base URL) | List tenant-owned providers |
| POST | (base URL) | Create a tenant-owned provider |
| GET | /{provider_id} | Get a provider |
| POST | /{provider_id} | Update or disable a provider |
| DELETE | /{provider_id} | Archive a provider |
| GET | /{provider_id}/federation_rules | List rules across targets |
| POST | /{provider_id}/federation_rules | Create a rule |
RULE_PATH = /{provider_id}/federation_rules/{federation_rule_id}| HTTP method | Relative path | Action |
|---|---|---|
| GET | {RULE_PATH} | Get a rule |
| POST | {RULE_PATH} | Update or disable a rule |
| DELETE | {RULE_PATH} | Archive a rule |
For Codex, set target_type to chatgpt_workspace and target_id to a linked workspace ID. Supply an active principal ID from that workspace. Creating the rule establishes the workspace binding as needed.
curl --fail-with-body --silent --show-error \
"$TENANT_WIF_BASE/$PROVIDER_ID/federation_rules" \
-H "Authorization: Bearer $OPENAI_TENANT_ADMIN_KEY" \
--json '{
"target_type": "chatgpt_workspace",
"target_id": "<workspace-id>",
"principal_id": "<principal-id>",
"external_subject": "<workload-subject>"
}'Use the returned id as OPENAI_FEDERATION_RULE_ID in Part 1. Provider and rule lists paginate. When has_more is true, pass last_id as after on the next request. To list rules for one workspace, filter by both target_type and target_id.
Organization Admin API walkthrough
The walkthrough and field references that follow use the organization Admin API. Use a key from an active organization administrator with workload identity access. These routes call rules mappings, use POST for updates, and return unpaginated lists.
Manage your organization’s Admin API keys in the API Platform.
export OPENAI_ADMIN_KEY="<organization-admin-api-key>"
WIF_BASE="https://api.openai.com/v1/organization/workload_identity"1. Create an OIDC provider
Use a separate provider for each issuer and trust boundary you need to manage independently. Replace the example issuer and audience with exact values from your token.
Choose max_assertion_lifetime_seconds using the token's full exp - iat duration, not its remaining validity. The accepted range is 1 through 176,400 seconds. This is a provider verification limit, separate from the lifetime of the OpenAI access token issued by a rule.
For Microsoft Entra, do not assume a one-hour assertion. Access-token lifetimes vary, and managed-identity token lifetimes are not configurable. Inspect actual iat and exp values and select an approved limit.
MAX_ASSERTION_LIFETIME_SECONDS="<accepted-issuer-lifetime-seconds>"
jq -n \
--argjson lifetime "$MAX_ASSERTION_LIFETIME_SECONDS" \
'{
name: "entra-production",
type: "oidc",
issuer: "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/v2.0",
audience: "api://openai-codex-production",
description: "Production Codex workloads in Microsoft Azure",
max_assertion_lifetime_seconds: $lifetime,
check_jti: true
}' > provider.json
curl --fail-with-body --silent --show-error \
"$WIF_BASE/providers" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json" \
--data @provider.json \
--output provider-response.json
PROVIDER_ID="$(jq -r .id provider-response.json)"
printf 'Created provider %s\n' "$PROVIDER_ID"Expected ID prefix: idp_. This example enables replay protection. Ensure the runtime can supply fresh assertions for later exchanges when the token contains jti.
OIDC discovery uses the issuer URL by default. Alternative verification modes are a public discovery document at custom_url, a public JWKS at jwks_uri, or uploaded public keys using jwks_local: true and jwks. Do not upload private key material.
Alternative: create a SPIFFE JWT-SVID provider
Use the same create-provider endpoint with type set to spiffe_jwt. Set issuer to the canonical trust domain and provide a public bundle URL or an uploaded SPIFFE bundle. SPIFFE rules must set accepted audiences.
{
"name": "spiffe-production",
"type": "spiffe_jwt",
"issuer": "spiffe://example.com",
"jwks_uri": "https://spiffe.example.com/bundle.json",
"max_assertion_lifetime_seconds": 3600,
"check_jti": true
}To upload a bundle, set jwks_local to true, replace jwks_uri with the jwks object, and include at least one public key whose use is jwt-svid.
2. Create a federation rule
A rule selects one existing workspace and principal. This example accepts one Azure managed identity subject and requests a 10-minute OpenAI access-token lifetime. Replace the placeholder IDs, subject, and audience.
export WORKSPACE_ID="<managed-chatgpt-workspace-id>"
export PRINCIPAL_ID="<existing-openai-user-id>"
jq -n \
--arg workspace_id "$WORKSPACE_ID" \
--arg principal_id "$PRINCIPAL_ID" \
'{
name: "entra-payments-production",
description: "Production payments workload",
workspace_id: $workspace_id,
principal_id: $principal_id,
external_subject: "11111111-2222-3333-4444-555555555555",
audiences: ["api://openai-codex-production"],
access_token_lifetime_seconds: 600,
enabled: true
}' > rule.json
curl --fail-with-body --silent --show-error \
"$WIF_BASE/providers/$PROVIDER_ID/mappings" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json" \
--data @rule.json \
--output rule-response.json
FEDERATION_RULE_ID="$(jq -r .id rule-response.json)"
printf 'Created federation rule %s\n' "$FEDERATION_RULE_ID"Expected ID prefix: idpm_. Supply this value as OPENAI_FEDERATION_RULE_ID to the Codex runtime. Complete the protected token-file setup and verification in Part 1; creating a rule alone does not configure or start Codex.
To accept a set of subjects in one rule, omit external_subject and use a CEL condition:
{
"condition": "assertion.sub in [\"workload-a\", \"workload-b\"]"
}Set at least one of external_subject, claims, or condition. All configured checks must pass. An accepted audience alone is not an identity check.
3. List and reconcile
Read current state before creating resources or applying changes:
curl --fail-with-body --silent --show-error \
"$WIF_BASE/providers" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" | jq .
curl --fail-with-body --silent --show-error \
"$WIF_BASE/providers/$PROVIDER_ID/mappings" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" | jq .Store returned IDs in approved configuration state, compare each resource to the intended state, and update by ID. Reuse existing resources on subsequent runs.
4. Update or disable
Send only the fields you intend to change. The following example updates the rule's token lifetime:
RULE_URL="$WIF_BASE/providers/$PROVIDER_ID/mappings/$FEDERATION_RULE_ID"
curl --fail-with-body --silent --show-error \
-X POST "$RULE_URL" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"access_token_lifetime_seconds": 300}' | jq .To stop access immediately, disable the rule:
curl --fail-with-body --silent --show-error \
-X POST "$RULE_URL" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"enabled": false}' | jq .To stop all rules under a provider, POST enabled: false to the provider path. Disablement blocks new exchanges and revokes tokens already issued through the resource. Re-enable only when its principal, workspace, binding, and provider are active.
Ordinary rule edits affect new exchanges only; existing tokens can remain valid until their TTL ends. Provider trust edits revoke issued tokens before the new trust configuration takes effect.
5. Archive
DELETE archives a provider or rule rather than erasing it. Archival blocks new exchanges, revokes issued tokens, hides the resource from normal list results, and cannot be undone. Use disablement for a temporary pause.
# Archive the rule. This cannot be undone.
curl --fail-with-body --silent --show-error \
-X DELETE "$RULE_URL" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"
# Archive the provider. This cannot be undone.
curl --fail-with-body --silent --show-error \
-X DELETE "$WIF_BASE/providers/$PROVIDER_ID" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"Before archiving a provider, remove any non-Codex product mapping under it. This prevents the archive operation from disrupting existing OpenAI API workload identity configuration.
Part 3. Reference and operations
Rule matching and authorization
Codex names one federation rule by ID. OpenAI evaluates that rule; it does not search other rules for a match. A rule always targets one principal in one workspace, although it may accept many external identities. Multiple rules may target the same principal.
Provider verification runs first. A rule cannot override issuer, signing-key, expiry, assertion-lifetime, replay, or provider-level CEL checks.
Set at least one subject, exact-claim, or CEL check. If multiple check types are configured, all must pass. A matching audience does not compensate for a failed identity check.
Prefer an exact subject. A subject prefix may contain one trailing *, following a non-empty prefix. A bare * and wildcards in the middle are not accepted.
Exact claims compare top-level scalar values without type conversion. Use the subject field or CEL for sub; use CEL for nested values and list membership.
CEL expressions operate on the verified claim map named assertion and must return a boolean. Supported helpers include has, size, contains, startsWith, and endsWith. Regex matching, collection iteration macros such as all or exists, arbitrary functions, and other identifiers are unsupported.
Missing claims, unsupported operations, non-boolean results, and evaluation errors reject the exchange.
A rule audience list accepts a token if at least one token audience appears in the list. SPIFFE rules require audiences. OIDC rules also require them when the provider does not define a provider-level audience.
Scopes can only narrow the target principal's existing permissions; they cannot grant new workspace permissions. Choose the least-privilege principal and workspace permissions first. If scopes are omitted, the default set is:
openid
profile
email
chatgpt.workspace.feature.allow-codex-local-access.accessIf you specify scopes, use only those four supported values and include chatgpt.workspace.feature.allow-codex-local-access.access.
Provider field reference
Create requires name and issuer. Updates accept mutable fields except type; enabled is update-only.
| Field | Description |
|---|---|
| name | Required non-empty display name. |
| type | oidc by default, or spiffe_jwt. Immutable after creation. |
| issuer | Required exact OIDC iss URL or canonical SPIFFE trust domain. |
| audience | Optional provider-level audience. Rules need an audience when this is absent. |
| description | Optional administrator description. |
| custom_url | Optional public HTTPS discovery URL for OIDC. |
| jwks_uri | Optional public HTTPS JWKS or SPIFFE bundle URL. |
| jwks_local | Set to true when supplying jwks. |
| jwks | Uploaded public JWKS object. Maximum 100 keys and 1 MiB. Never include private keys. |
| custom_ca_certificate | Optional PEM CA bundle for JWKS HTTPS. Maximum 256 KiB. |
| attribute_conditions | Optional bounded CEL condition over assertion, evaluated before rule matching. |
| max_assertion_lifetime_seconds | Accepted upstream assertion lifetime: 1 to 176,400 seconds; default 3,600. OIDC uses the full exp - iat duration. |
| check_jti | Reject repeated non-empty JWT jti values when true. Default false. |
| enabled | Update-only control that permits or blocks exchanges. |
Discovery, explicit key URLs, and uploaded keys are alternative verification modes. See the workload identity overview for issuer, discovery, JWKS URL validation, and key rotation.
Federation rule field reference
Create requires workspace_id and principal_id, plus at least one identity check. You cannot change the workspace or principal after creation.
| Field | Description |
|---|---|
| workspace_id | Existing managed ChatGPT workspace ID. Create-only. |
| principal_id | Existing active OpenAI user or service-account ID in that workspace. Create-only. |
| external_subject | Exact sub or one trailing-* prefix. Maximum 4,096 bytes. |
| claims | Up to 32 exact top-level scalar claims; do not include sub. The exact-claim map is bounded to 16 KiB. |
| audiences | 1 to 32 unique accepted audience strings. Required for SPIFFE and when the provider has no audience. |
| condition | Bounded CEL boolean expression over assertion. Maximum 16 KiB. |
| scopes | Optional subset of the four supported Codex scopes. Omit for the default set; explicit scopes must include Codex local access. |
| access_token_lifetime_seconds | 60 to 3,600 seconds. Default 3,600. |
| name | Optional display name. |
| description | Optional administrator description. |
| enabled | Whether the rule accepts exchanges. Default true. |
Provider response objects use workload_identity_provider; rule response objects use workload_identity_mapping. Both include id, enabled, created_at, and updated_at. Timestamps are Unix seconds.
Where to configure WIF for Codex
For the setups below, configure WIF on the machine that runs the Codex process. Follow the setup instructions in Part 1.
| How you run Codex | Where to configure WIF |
|---|---|
| Interactive CLI, including resume and fork | Start the CLI in the environment you configured for WIF. |
| codex exec, codex exec resume, and codex review | Run these commands in the environment you configured for WIF. |
| TypeScript SDK | Set the required WIF environment variables in the parent process. You can also supply attribution context there. |
| codex app-server | Configure WIF on the machine running the app-server. |
| codex exec-server --remote | Configure WIF on the machine running the exec-server. WIF is used only to authenticate to the remote environment registry. |
Remote app-server and exec-server clients do not send the upstream identity token to the server.
Local exec-server process operations use the local exec-server protocol and do not require WIF.
Optional audit attribution
When runtime instances share a rule, use OPENAI_WORKLOAD_IDENTITY_CONTEXT to distinguish instances in token-issuance audit events. Set it to a JSON object encoded as a string:
export OPENAI_WORKLOAD_IDENTITY_CONTEXT='{
"instance_id": "runner-42",
"display_name": "payments-prod",
"labels": {
"environment": "production",
"region": "us-west-2"
}
}'instance_id is required. display_name and labels are optional.
Maximum encoded object size: 1,024 bytes. Maximum labels: eight.
instance_id and display_name: up to 128 characters each. Label keys: up to 64 characters. Label values: up to 256 characters.
Identifiers start with an ASCII letter or number. Values can then use letters, numbers, periods, underscores, colons, slashes, @, and hyphens. Label keys support letters, numbers, periods, underscores, and hyphens.
This is client-reported audit context, not verified workload identity. It does not change authentication, authorization, matching, scopes, rate limits, revocation, feature gates, or metrics. Do not include credentials, secrets, personal data, prompts, model output, or other Customer Content.
OpenAI derives a stable attribution ID scoped to the tenant, provider, rule, and instance_id. The access token contains that ID, not the context. A successful token-issuance audit event contains the ID and normalized context. Invalid or oversized context causes invalid_grant.
Codex reads context at process start. It does not pass the context, rule ID, or token-file path to model-controlled shells, hooks, or MCP servers. Restart Codex after changing the context.
Access changes and audit events
Ordinary rule edits: Changes to identity checks, audiences, scopes, or lifetime affect new exchanges. Existing access tokens can remain valid until their TTL ends.
Disablement: Blocks new exchanges and revokes access tokens issued through the provider or rule. Use it for an emergency stop or temporary pause.
Archival: Has the same access effect as disablement, hides the resource from normal lists, and cannot be undone.
Provider trust changes: Revoke issued tokens before the new issuer, keys, or other trust settings take effect.
Provider and rule creation, updates, and archival generate audit events. Export the events your workspace supports through the Compliance API and correlate them with identity-provider issuance logs. Never log upstream assertions or OpenAI access tokens. Successful token-issuance events also include attribution when valid workload context is supplied.
Limits and API errors
An organization may have up to 1000 non-archived providers. Each provider may have up to 1000 non-archived federation rules. Disabled resources still count as non-archived.
| HTTP status code | Description |
|---|---|
| 400 | Invalid request fields, provider trust settings, rule conditions, scopes, or inactive principal membership. Correct the request or state before retrying. |
| 403 | The Admin API key owner cannot manage workload identity. Check the administrator's permissions. |
| 404 | No organization-to-tenant association, or a requested resource outside the organization and tenant boundary. This response does not disclose another organization's or tenant's resources. |
| 409 | Provider or rule limits, subject conflicts, inactive bindings, or lifecycle conflicts. |
| 429 and 5xx | Retry transient failures with bounded delays that increase after each attempt. Do not retry validation or permission failures without changing the request or administrator state. |
Troubleshooting
Incomplete WIF configuration
Set the rule ID and variables for your chosen source in the same process. Check the token file or local SPIRE socket as applicable.
Login policy does not permit WIF
Allow ChatGPT authentication in the effective policy and permit the rule's workspace.
Another authentication method is reported
Start a new process with the WIF settings for your chosen source and rerun codex login status.
Workload context is rejected
Check JSON shape, byte size, character restrictions, and field limits. Remove sensitive or Customer Content.
The identity token is rejected
Check iss, aud, expiry, signature key, and full assertion lifetime against the provider configuration.
The rule does not match
Verify the rule ID and every configured subject, audience, exact-claim, and CEL check.
The principal is rejected
Confirm the user or service account is active and has active membership in the selected workspace.
An assertion is rejected as a replay
Obtain a new JWT with a new jti. Do not retry the consumed replay-protected assertion.
A long-running process stops refreshing
Check that the host is replacing the token file before expiry or that the SPIRE Agent can still issue a JWT-SVID.
Still need help?
For help, contact your OpenAI representative. Include a sanitized error and the Codex version; do not send identity tokens, OpenAI access tokens, or Admin API keys.
Related resources
Follow the steps for your provider to obtain an identity token, then return to this article to configure Codex. The service account mapping and SDK examples in these guides apply to the OpenAI API.