Skip to content
API Reference
Admin
Configure Provider APIs

Configure Anthropic

Set up credential brokering so workloads authenticate to Claude API with Keycard-issued tokens instead of static API keys

Configure Workload Identity Federation (WIF) between Keycard and Anthropic. Your applications get Keycard OIDC tokens that Anthropic exchanges for short-lived API credentials — no static API keys anywhere.

Before starting:

  1. Create the Anthropic resource

    In Keycard Console, navigate to ResourcesAdd Resource.

    FieldValue
    Resource Identifierhttps://api.anthropic.com
    Credentials ProviderYour zone provider
    Credential Lifetime1h (under Advanced Settings)
  2. Create an application

    Navigate to ApplicationsAdd Application.

    FieldValue
    Namee.g. anthropic-workload

    Note the Application ID from the browser URL bar after creating.

  3. Link the resource

    Open the application → DependenciesAdd Dependency → select https://api.anthropic.com.

  4. Create application credentials (local development only)

    Open the application → Application CredentialsAdd CredentialClient ID & Secret.

    Note the Client ID and Client Secret — the secret is shown once.

  5. Note the zone issuer URL

    Find your zone URL on the zone settings page. Anthropic needs this as the issuer URL:

    https://<zone-id>.keycard.cloud
  1. Create a service account

    In Anthropic Platform Console, go to Settings → Service accounts → Create service account.

    FieldValue
    Namee.g. keycard-workload

    Note the service account ID (svac_...).

  2. Create a workspace

    The Default Workspace has no ID and can’t be used with WIF.

    Go to Settings → Workspaces → Create workspace.

    FieldValue
    Namee.g. keycard-workloads

    Note the workspace ID (wrkspc_...) from the workspaces list.

  3. Link the service account to the workspace

    Select the workspace from the top navigation dropdown → Manage → Service accounts → Add service account → select the service account from step 1.

  4. Register Keycard as an issuer

    In Workload Identity Federation settings, on the Issuers tab → Create issuer.

    FieldValue
    Namee.g. keycard-prod
    Issuer URLhttps://<zone-id>.keycard.cloud
    JWKS sourcediscovery
  5. Create a federation rule

    On the Rules tab → New Rule.

    FieldValue
    IssuerSelect your Keycard issuer
    Match → Subject prefixYour Keycard Application ID
    TargetYour service account
    WorkspacesSelect the workspace from step 2
    Scopeworkspace:developer
    Token lifetime3600 seconds

    Note the rule ID (fdrl_...).

Get a Keycard OIDC token and pass it to the Anthropic SDK for automatic WIF exchange.

from keycardai.oauth import Client, BasicAuth
from anthropic import Anthropic, WorkloadIdentityCredentials
# 1. Get a Keycard OIDC token scoped to Anthropic.
with Client(
"https://<zone-id>.keycard.cloud",
auth=BasicAuth("<your-client-id>", "<your-client-secret>"),
) as kc:
token = kc.exchange_token(
grant_type="client_credentials",
resource="https://api.anthropic.com",
)
# 2. Use it with the Anthropic SDK — WIF exchange happens automatically.
client = Anthropic(
credentials=WorkloadIdentityCredentials(
identity_token_provider=lambda: token.access_token,
federation_rule_id="<fdrl_...>",
organization_id="<anthropic-org-id>",
service_account_id="<svac_...>",
workspace_id="<wrkspc_...>",
),
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello from a Keycard workload"}],
)
print(message.content[0].text)

In Keycard Console — open Audit Log. Look for:

EventDescription
credentials:issueOIDC token issued for https://api.anthropic.com

In Anthropic Platform Console — go to Settings → Workload identity → Authentication events. You should see the exchange with your zone’s issuer URL and matched federation rule.

Token exchange returns “service account not a member of workspace” The service account must be explicitly added to the workspace. Go to the workspace → Manage → Service accounts and add it.

“Invalid issuer” error The issuer URL in Anthropic must match the Keycard zone URL exactly, including the protocol (https://) and no trailing slash.

Federation rule doesn’t match Check that the Subject prefix in the rule matches your Keycard Application ID. The sub claim in the Keycard-issued JWT contains this value.