Skip to main content
Voyant Cloud handles the outbound communication a travel app relies on: SMS to travelers, transactional email, and one-time-code verification. All three are groups on the Cloud SDK client.
import { createVoyantCloudClient } from "@voyant-travel/cloud-sdk";

const client = createVoyantCloudClient({ apiKey: process.env.VOYANT_API_KEY! });

SMS

The sms group sends text messages and lists your numbers and message history.
// List the phone numbers available to your account
const numbers = await client.sms.listPhoneNumbers();

// Send a message
const message = await client.sms.sendMessage({
  to: "+14155551234",
  body: "Your transfer is confirmed for 09:00.",
});

// List recent messages
const history = await client.sms.listMessages();
MethodScope
sms.listPhoneNumbers()phone-numbers:read
sms.listMessages()sms:read
sms.sendMessage(input)sms:send
Key types: SendSmsInput, SmsMessageSummary, PhoneNumberSummary, SmsMessageStatus, PhoneNumberStatus.

Email

The email group sends transactional email and reads message records.
const message = await client.email.sendMessage({
  to: "traveler@example.com",
  subject: "Your itinerary",
  html: "<p>Thanks for booking. Your documents are attached.</p>",
});

const sent = await client.email.listMessages();
const detail = await client.email.getMessage(message.id);
MethodScope
email.listMessages()emails:read
email.getMessage(id)emails:read
email.sendMessage(input)emails:send
Key types: SendEmailInput, EmailMessageSummary, EmailMessageStatus.

Verification

The verification group runs one-time-code flows over a channel such as SMS. You start an attempt, then check the code the user entered.
// Start a verification attempt
const attempt = await client.verification.start({
  to: "+14155551234",
  channel: "sms",
});

// Check the code the user submitted
const result = await client.verification.check({
  to: "+14155551234",
  code: "123456",
});

if (result.status === "approved") {
  // proceed
}
MethodScope
verification.start(input)verification:start
verification.check(input)verification:check
verification.listAttempts()verification:read
Key types: StartVerificationInput, CheckVerificationInput, VerificationCheckResult, VerificationChannel, VerificationAttemptStatus.

Errors

Every method throws a VoyantApiError with status, requestId, and body on failure. See Errors and transport.