Skip to content

Devices

sms.devices covers the Android phones paired to your organization and their SIMs. sms.pools groups phones so that a message fails over to another phone when one goes offline. Reading needs devices:read; every change needs devices:manage.

Method HTTP Returns
devices.createPairingToken(options?) POST /v1/devices/pairing-tokens PairingToken
devices.list() GET /v1/devices Device[]
devices.get(id) GET /v1/devices/:id Device
devices.update(id, params) PATCH /v1/devices/:id Device
devices.delete(id) DELETE /v1/devices/:id void
devices.updateSim(deviceId, simId, params) PATCH /v1/devices/:id/sims/:simId Sim
devices.setDefaultSim(deviceId, simId) POST /v1/devices/:id/sims/:simId/default Sim
pools.list() GET /v1/pools Pool[]
pools.create(params, options?) POST /v1/pools Pool
pools.update(id, params) PATCH /v1/pools/:id Pool
pools.delete(id) DELETE /v1/pools/:id void

A token that pairs a new phone, valid for 10 minutes. Show qrPayload as a QR code and scan it with the SMSFabric app (pairing).

pairing-token.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
const pairing = await sms.devices.createPairingToken();
console.log(pairing.qrPayload); // smsfabric://pair?server=…&token=…
console.log('Expires', pairing.expiresAt);

Every paired phone, with status (online, offline, disabled), battery, signal, network, app version, last check-in and SIMs.

list-devices.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
for (const d of await sms.devices.list()) {
console.log(d.id, d.name, d.status, `${d.battery ?? '?'}%`, d.sims.map((s) => s.carrier).join(', '));
}

One phone.

get-device.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
const device = await sms.devices.get('dev_…');
console.log(device.status, device.lastSeenAt, device.appVersion);

Renames a phone (name, up to 120 characters), turns sending on or off (enabled), or moves it into a pool (poolId; null takes it out).

update-device.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
const device = await sms.devices.update('dev_…', { name: 'Front desk Pixel', poolId: 'pool_…' });
console.log(device.name, device.poolId);

Unpairs the phone and revokes its device token, so it can no longer reach the API. To use the phone again, pair it with a new token.

delete-device.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
await sms.devices.delete('dev_…');

Turns a SIM on or off, sets a daily limit (0 to 100,000 messages; null removes it) or a label (up to 80 characters).

update-sim.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
const sim = await sms.devices.updateSim('dev_…', 'sim_…', { dailyLimit: 500, label: 'Vodafone business' });
console.log(sim.label, sim.dailyLimit);

Makes this SIM the organization’s default sending SIM: messages without a deviceId, simId or poolId go through it.

default-sim.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
const sim = await sms.devices.setDefaultSim('dev_…', 'sim_…');
console.log(sim.isDefault); // true

A pool is a group of phones that share the work. A message sent with poolId goes round-robin to the pool’s online phones; if a phone doesn’t take it in time, rejects it or goes offline, the message moves to another phone in the pool. Phones join with devices.update(id, { poolId }). More in Pools.

Every pool with the ids of its phones.

list-pools.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
for (const pool of await sms.pools.list()) console.log(pool.id, pool.name, pool.deviceIds.length);

Creates an empty pool.

create-pool.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
const pool = await sms.pools.create({ name: 'Cairo office' });
for (const id of ['dev_…', 'dev_…']) await sms.devices.update(id, { poolId: pool.id });

Renames a pool.

rename-pool.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
await sms.pools.update('pool_…', { name: 'Cairo office (2 phones)' });

Deletes a pool. Its phones stay paired; their poolId becomes null.

delete-pool.ts
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
await sms.pools.delete('pool_…');