Choose an authentication method

MethodUse caseWhen to use
API keyDevelopment, scripts, testingLocal development, CI pipelines, one-off automation. Never use in a long-running production service.
OAuth 2.0 client credentialsProduction server-to-serverMicroservices, backend applications, and any integration running in production. Tokens expire automatically — no manual rotation required.

API key authentication

An API key is a static bearer token you include in the Authorization header of every request. The SDK handles this automatically when you set CASEFORGE_API_KEY.

Generate an API key

  1. Go to Dashboard → Settings → API Keys.
  2. Select Create API key. Give the key a descriptive name (for example, local-dev-2026-03).
  3. Choose a key type: Sandbox (prefix cf_sand_) for development, or Live (prefix cf_live_) for production data.
  4. Copy the key immediately. The full key value is shown only once — if you close the dialog, you need to generate a new key.
  5. Store the key in your environment: set CASEFORGE_API_KEY in your shell, .env file, or secrets manager.

Use the key in the SDK

Python
import caseforge

# The SDK reads CASEFORGE_API_KEY from the environment automatically
client = caseforge.Client()

# To supply the key programmatically (e.g. from a vault)
client = caseforge.Client(api_key=get_secret("caseforge/api-key"))
Node.js
import CaseForge from '@caseforge/sdk';

// Reads CASEFORGE_API_KEY from process.env automatically
const client = new CaseForge();

// Or supply it from your secrets provider
const apiKey = await getSecret('caseforge/api-key');
const client = new CaseForge({ apiKey });
cURL
curl https://api.caseforge.io/v2/cases \
  -H "Authorization: Bearer cf_sand_your_key_here"

OAuth 2.0 client credentials

For production integrations, use OAuth 2.0 client credentials. Your application exchanges a client ID and client secret for a short-lived access token. When the token expires, the SDK can automatically request a new one.

Register an application

  1. Go to Dashboard → Settings → Applications.
  2. Select Create application. Enter a name and description.
  3. Under Grant types, select Client credentials.
  4. Select the scopes your application needs. See the scopes reference below.
  5. Save the application. The dashboard shows your client_id and client_secret. Store both in your secrets manager before closing the dialog.

Request an access token

The SDK handles token acquisition and renewal automatically. Configure it with your client credentials, and all subsequent API calls use a valid token:

Python
import caseforge

# Configure client credentials — token management is automatic
client = caseforge.Client(
    client_id="app_8v3k9m",
    client_secret=get_secret("caseforge/client-secret"),
    scopes=["cases:read", "cases:write", "sar:write"],
)

# The SDK requests a token on first use and refreshes it before expiry
cases = client.cases.list(status="open")
Node.js
import CaseForge from '@caseforge/sdk';

// Configure client credentials — token management is automatic
const client = new CaseForge({
  clientId:     'app_8v3k9m',
  clientSecret: await getSecret('caseforge/client-secret'),
  scopes:       ['cases:read', 'cases:write', 'sar:write'],
});

// Token is acquired on first use and renewed before expiry
const cases = await client.cases.list({ status: 'open' });
cURL
# Step 1: Acquire a token
curl -X POST https://auth.caseforge.io/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=app_8v3k9m&client_secret=YOUR_SECRET&scope=cases:read+cases:write"

# Response:
# {"access_token":"eyJ...","token_type":"Bearer","expires_in":3600,"scope":"cases:read cases:write"}

# Step 2: Use the token
curl https://api.caseforge.io/v2/cases \
  -H "Authorization: Bearer eyJ..."

Token lifecycle

Access tokens expire after 60 minutes. The SDK automatically requests a new token when the current one is within 5 minutes of expiry, so you don't need to handle token renewal in your application code.

EventSDK behavior
First API callSDK requests a token and caches it in memory.
Token within 5 min of expirySDK proactively requests a new token before the next API call.
Token expired (401 response)SDK requests a new token immediately and retries the original request once.
Client secret rotatedRestart the SDK client with the new secret — the in-memory token is discarded.

Scopes reference

Request only the scopes your application needs. CaseForge follows the principle of least privilege — unused scopes increase your attack surface without providing value.

ScopeGrants access to
cases:readRead case details, case list, and case history.
cases:writeCreate, update, assign, and close cases.
sar:readRead filed SARs and SAR drafts.
sar:writeCreate SAR drafts and submit SARs for review.
watchlist:readRead watchlist entries and run screenings.
watchlist:writeAdd, update, and remove watchlist entries.
transactions:readRead transaction records and search transaction history.
subjects:readRead subject profiles and risk scores.
subjects:writeCreate and update subject profiles.
alerts:readRead alerts generated by the CaseForge rules engine.

Security best practices

Never hardcode credentials

Do not embed API keys or client secrets in source code, configuration files committed to version control, or container images. Use environment variables or a dedicated secrets manager (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault).