Skip to main content

Contiguity

The main client class that provides access to all Contiguity API resources.

Constructor

new Contiguity(token?: string, config?: ContiguityConfig)
Creates a new Contiguity client instance.
token
string
Your Contiguity API token. If not provided, the SDK will look for CONTIGUITY_API_KEY or CONTIGUITY_TOKEN environment variables.The token must start with contiguity_sk_.
config
ContiguityConfig
Configuration options for the client.

Properties

text
TextResource
Access to SMS/text messaging methods. See Text API.
email
EmailResource
Access to email sending methods. See Email API.
otp
OtpResource
Access to one-time password methods. See OTP API.
imessage
ImessageResource
Access to iMessage methods. See iMessage API.
whatsapp
WhatsappResource
Access to WhatsApp methods. See WhatsApp API.
lease
LeaseResource
Access to phone number leasing methods. See Lease API.
domains
DomainsResource
Access to email domain management methods. See Domains API.
entitlements
EntitlementsResource
Access to entitlement management methods. See Entitlements API.
agreements
AgreementsResource
Access to agreement acceptance methods. Helper for accepting entitlement agreements.
webhook
WebhookResource
Access to webhook verification and parsing methods. See Webhooks API.

Example

import { Contiguity } from 'contiguity';

// Initialize with token parameter
const contiguity = new Contiguity('contiguity_sk_...');

// Or use environment variables
const contiguity = new Contiguity();

// With debug mode enabled
const contiguity = new Contiguity('contiguity_sk_...', { debug: true });

// Access resources
await contiguity.text.send({
  to: '+1234567890',
  message: 'Hello from Contiguity!'
});

Error Handling

The constructor throws an error if:
  • No token is provided and no environment variable is set
  • The provided token doesn’t start with contiguity_sk_
try {
  const contiguity = new Contiguity('invalid_token');
} catch (error) {
  console.error(error.message);
  // "Invalid Contiguity token: key must start with contiguity_sk_."
}

Build docs developers (and LLMs) love