Reference

SDK Reference

The credian package is a zero-dependency TypeScript SDK for Node 18+. It supports both ESM and CommonJS.

Client initialization

TypeScript
import { Credian } from 'credian'
// Agent auth (API key)
const client = new Credian({ apiKey: 'avs_...' })
// Owner auth (OAuth token)
const client = new Credian({ accessToken: 'eyJ...' })

Options: baseUrl, timeout (ms, default 30000), retries (default 3).

client.agents

Register, update, and manage agents. Owner auth required for write operations.

agents.register(input)Agent & { apiKey }

Register a new agent. Returns the agent with a one-time API key.

agents.get(agentId)Agent

Get an agent's profile by ID.

agents.update(agentId, input)Agent

Update agent metadata or display name.

agents.deactivate(agentId)void

Deactivate an agent. Owner auth required.

client.score

Query trust scores. Score lookups are public and rate-limited.

score.get(agentId)AgentScore

Current score with breakdown (reliability, financial, identity), confidence, classification.

score.getHistory(agentId, options?)ScoreSnapshot[]

Historical score snapshots. Options: from, to, limit.

score.getBatch(agentIds)Map<string, AgentScore>

Batch lookup for up to 100 agents.

client.events

Report behavioral events that feed into trust scores.

events.report(agentId, events){ accepted, rejected, errors? }

Submit one or more events. Returns counts of accepted and rejected.

events.list(agentId, options?)Event[]

Get event history. Options: type, from, to, cursor, limit.

client.credentials

Issue and verify trust credentials for agents.

credentials.issue(input)Credential

Issue a credential. Includes agentId, type, claims, expiresAt.

credentials.verify(credentialId){ valid, status, claims }

Verify a credential is active and not expired/revoked.

credentials.get(credentialId)Credential

Get full credential details.

credentials.revoke(credentialId)void

Revoke a previously issued credential.

client.webhooks

Manage webhook subscriptions. Owner auth required.

webhooks.create(input)WebhookSubscription

Create a subscription with a URL and list of event types.

webhooks.list()WebhookSubscription[]

List all active subscriptions.

webhooks.delete(subscriptionId)void

Delete a webhook subscription.

Error handling

TypeScript
import { CredianError } from 'credian'
try {
await client.score.get('agent_id')
} catch (err) {
if (err instanceof CredianError)
console.error(err.code) // 'NOT_FOUND'
}

All errors include code, message, details, and status.

Exported types

TypeScript
import type {
Agent,
AgentScore,
ScoreSnapshot,
AgentEvent,
Credential,
WebhookEvent,
CredianError,
} from 'credian'