Skip to main content

Quickstart

Get started with the Optropic Trust API in under 5 minutes. This guide walks you through installation, authentication, and your first asset creation and verification.

Installationโ€‹

npm install optropic

Initialize the Clientโ€‹

import { OptropicClient } from 'optropic';

const client = new OptropicClient({
apiKey: 'optr_live_your_api_key_here',
});
Sandbox Mode

Use optr_test_* keys for sandbox mode โ€” they auto-detect and route to the test environment. No configuration needed.

Create Your First Assetโ€‹

const asset = await client.assets.create({
externalId: 'product-001',
vertical: 'pharmaceuticals',
securityLevel: 'signed',
metadata: {
product: 'Aspirin 500mg',
batch: 'B2026-0329',
},
});

console.log(`Asset created: ${asset.id}`);
console.log(`Serial: ${asset.serial}`);

Verify an Assetโ€‹

const result = await client.assets.verify(asset.serial);

if (result.valid) {
console.log('โœ“ Authentic product');
console.log(`Signed by keyset: ${result.keysetId}`);
} else {
console.log('โœ— Verification failed:', result.reason);
}

Track Provenanceโ€‹

Record the product's journey through the supply chain:

// Record manufacturing event
await client.provenance.record({
assetId: asset.id,
eventType: 'manufactured',
actor: 'factory-line-7',
location: { country: 'DE', facility: 'Munich Plant' },
});

// Ship the product
await client.provenance.record({
assetId: asset.id,
eventType: 'shipped',
actor: 'logistics-team',
location: { country: 'DE', facility: 'Munich Warehouse' },
});

// Get the full provenance chain
const chain = await client.provenance.getChain(asset.id);
console.log(`${chain.eventCount} events in chain`);
console.log(`Chain valid: ${chain.chainValid}`);

What's Next?โ€‹