@vantroute/sdk
v1.0.1
Published
Official Vantroute SDK for prescription ingestion and webhook verification.
Downloads
137
Maintainers
Readme
Vantroute SDK for TypeScript / Node.js
Official TypeScript SDK for the Vantroute prescription routing API. Zero runtime dependencies -- uses native fetch and Node.js crypto.
Installation
npm install @vantroute/sdkQuick Start
1. Create a Client
import { VantrouteClient } from '@vantroute/sdk';
const client = new VantrouteClient({
baseUrl: 'https://api.vantroute.com',
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
});Authentication is automatic. The SDK obtains and refreshes tokens as needed.
2. Submit a Prescription (Typed Model)
import type { VantroutePrescription } from '@vantroute/sdk';
const prescription: VantroutePrescription = {
customReferenceId: 'abc1234',
patient: {
firstName: 'Jane',
lastName: 'Doe',
dateOfBirth: '1985-06-15',
phone: '5551234567',
address: {
street1: '123 Main St',
city: 'Austin',
state: 'TX',
zip: '78701',
},
},
prescriber: {
firstName: 'John',
lastName: 'Smith',
npi: '1234567890',
phone: '5559876543',
},
prescription: {
drugName: 'Amoxicillin 500mg Capsule',
quantity: 30,
refills: 2,
daysSupply: 10,
dateWritten: '2026-03-25',
directions: 'Take 1 capsule by mouth 3 times daily',
},
};
const result = await client.submitPrescription(prescription);
console.log(`Accepted: ${result.correlationId}`);3. Submit a Raw JSON Payload
For providers with their own payload format and server-side mapping configured:
const result = await client.submitScript(rawJsonString, {
idempotencyKey: 'order-12345',
});4. Receive Webhooks
Verify HMAC-SHA256 signatures on incoming webhook requests:
import { createServer } from 'http';
import { WebhookReceiver } from '@vantroute/sdk';
const server = createServer(async (req, res) => {
const chunks: Buffer[] = [];
for await (const chunk of req) chunks.push(chunk as Buffer);
const body = Buffer.concat(chunks).toString();
const signature = (req.headers['x-vantroute-signature'] as string) ?? '';
if (!WebhookReceiver.verifySignature(body, signature, SIGNING_SECRET)) {
res.writeHead(401).end();
return;
}
const event = WebhookReceiver.parseEvent(body);
// Handle status update: event.correlationId, event.status
res.writeHead(200).end();
});
server.listen(8080);API Reference
| Method | Description |
|--------|-------------|
| authenticate() | Obtain a bearer token (called automatically) |
| submitPrescription(prescription, options?) | Submit using the typed canonical model |
| submitScript(payload, options?) | Submit using a raw JSON payload |
| listScripts(params?) | Query prescription status history |
Examples
See examples/basic-usage.ts for a complete sample with typed submission, raw submission, and a webhook receiver HTTP server.
License
MIT
