Skip to main content

LeaseResource

The lease resource provides methods for leasing and managing phone numbers for sending messages.

available()

await contiguity.lease.available(): Promise<any>
Get a list of all available phone numbers that can be leased.
const numbers = await contiguity.lease.available();
console.log(numbers);

get()

await contiguity.lease.get(number: string): Promise<any>
Get information about a specific phone number’s availability.
number
string
required
The phone number in E.164 format (e.g., +1234567890).
const info = await contiguity.lease.get('+1234567890');
console.log(info);

create()

await contiguity.lease.create(
  number: string,
  options?: LeaseCreateOptions
): Promise<any>
Lease a phone number for your account.
number
string
required
The phone number to lease in E.164 format.
options
LeaseCreateOptions
// Lease with default billing
const lease = await contiguity.lease.create('+1234567890');

// Lease with custom billing method
const lease = await contiguity.lease.create('+1234567890', {
  billing_method: 'service_contract'
});

console.log(lease);

leased()

await contiguity.lease.leased(): Promise<any>
Get a list of all phone numbers currently leased to your account.
const myNumbers = await contiguity.lease.leased();
console.log(myNumbers);

details()

await contiguity.lease.details(number: string): Promise<any>
Get detailed information about a specific leased phone number.
number
string
required
The phone number in E.164 format.
const details = await contiguity.lease.details('+1234567890');
console.log(details);

terminate()

await contiguity.lease.terminate(number: string): Promise<any>
Terminate a phone number lease and release it back to the pool.
number
string
required
The phone number to terminate in E.164 format.
await contiguity.lease.terminate('+1234567890');
console.log('Lease terminated');

Complete Example

import { Contiguity } from 'contiguity';

const contiguity = new Contiguity('contiguity_sk_...');

// Step 1: Find available numbers
const available = await contiguity.lease.available();
console.log('Available numbers:', available);

// Step 2: Lease a number
const number = '+1234567890';
const lease = await contiguity.lease.create(number, {
  billing_method: 'monthly'
});
console.log('Leased number:', lease);

// Step 3: View all your leased numbers
const myNumbers = await contiguity.lease.leased();
console.log('My numbers:', myNumbers);

// Step 4: Get details about a specific number
const details = await contiguity.lease.details(number);
console.log('Number details:', details);

// Step 5: Use the number to send messages
await contiguity.text.send({
  from: number,
  to: '+0987654321',
  message: 'Hello from my leased number!'
});

// Step 6: Terminate the lease when no longer needed
await contiguity.lease.terminate(number);
console.log('Lease terminated');

Notes

  • Phone numbers must be in E.164 format (e.g., +1234567890)
  • You must have an active lease on a number before you can send messages from it
  • Terminating a lease may take a few minutes to fully process
  • Some numbers may have restrictions based on your account type

Build docs developers (and LLMs) love