Skip to main content
This guide gets you calling Voyant Cloud services from a TypeScript project in a few minutes.

Prerequisites

  • A Voyant Cloud account and an API token. Mint one in the dashboard tokens UI, or with the CLI after voyant login.
  • Node.js 20 or newer.

Install the SDK

pnpm add @voyant-travel/cloud-sdk

Create a client

The client reads your API token and points at https://api.voyant.travel by default.
import { createVoyantCloudClient } from "@voyant-travel/cloud-sdk";

const client = createVoyantCloudClient({
  apiKey: process.env.VOYANT_API_KEY!,
});
Keep your API token on the server. It carries the scopes that authorize real actions like sending messages and reading secrets. For browser clients that need realtime, mint a short-lived client token instead. See Realtime.

Make a call

Each service is a group on the client. Here are one-line examples across several services:
// Send an SMS
await client.sms.sendMessage({
  to: "+14155551234",
  body: "Hello from Voyant Cloud",
});

// Send an email
await client.email.sendMessage({
  to: "traveler@example.com",
  subject: "Your itinerary",
  html: "<p>See you soon.</p>",
});

// Read a secret from a vault
const secret = await client.vault.getSecret("production", "STRIPE_KEY");

// Render a page to PDF
const pdf = await client.browser.pdf({
  url: "https://example.com",
  pdfOptions: { format: "a4", printBackground: true },
});

// Publish a realtime message
await client.realtime.publish("orders:eu", {
  event: "order.updated",
  data: { orderId: "ord_1" },
});

Handle errors

Any non-2xx response throws a VoyantApiError carrying the HTTP status, a requestId, and the response body. Always preserve the request id in logs and support requests:
import { VoyantApiError } from "@voyant-travel/cloud-sdk";

try {
  await client.sms.sendMessage({ to: "+10000000000", body: "test" });
} catch (error) {
  if (error instanceof VoyantApiError) {
    console.error(error.status, error.requestId, error.body);
  }
  throw error;
}
See Errors and transport for the full transport behavior shared across the SDKs.

Next steps

Messaging

SMS, email, and verification in depth.

All services

Browse the full Cloud service catalog.