Skip to main content

Authentication

All Optropic API requests require an API key passed via the X-API-Key header. The SDK handles this automatically.

API Key Formatโ€‹

PrefixEnvironmentDescription
optr_live_*ProductionReal assets, real verification
optr_test_*SandboxTest data, no billing

The SDK auto-detects the environment from the key prefix. No manual configuration is needed.

Permissionsโ€‹

API keys can be scoped with granular permissions. Use the Permission constants for type-safe key creation:

import { Permission } from 'optropic';

// Create a read-only key
const key = await client.keys.create({
environment: 'live',
label: 'Read-only integration',
permissions: [Permission.ASSETS_READ, Permission.ASSETS_VERIFY],
});

Available Permissionsโ€‹

PermissionDescription
assets:readList and retrieve assets
assets:writeCreate and update assets
assets:verifyVerify asset authenticity
audit:readQuery audit trail
compliance:readAccess compliance reports
keys:manageCreate and revoke API keys
schemas:manageManage vertical schemas
documents:enrollEnroll document fingerprints
documents:verifyVerify document fingerprints
provenance:readRead provenance chains
provenance:writeRecord provenance events
webhooks:manageCreate and manage webhooks

Permission Groupsโ€‹

GroupPermissions Included
Permission.ALL_READassets:read, audit:read, compliance:read, provenance:read
Permission.ALL_WRITEassets:write, assets:verify, documents:enroll, documents:verify, provenance:write, webhooks:manage, keys:manage, schemas:manage
Permission.all()All permissions combined

Rate Limitsโ€‹

The SDK automatically parses rate limit headers after every response:

const rl = client.rateLimit;
if (rl) {
console.log(`${rl.remaining}/${rl.limit} requests remaining`);
console.log(`Resets at: ${rl.reset}`);
}

Request Correlationโ€‹

Every request includes an X-Request-ID header for end-to-end tracing. The SDK generates UUIDs automatically. Use this ID when contacting support.

Debug Loggingโ€‹

Enable debug mode to log all requests and responses (API keys are automatically redacted):

const client = new OptropicClient({
apiKey: 'optr_live_...',
debug: true, // logs to console
});