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 |
devices.createPairingToken
Section titled “devices.createPairingToken”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).
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);devices.list
Section titled “devices.list”Every paired phone, with status (online, offline, disabled), battery, signal, network, app version, last check-in and SIMs.
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(', '));}devices.get
Section titled “devices.get”One phone.
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);devices.update
Section titled “devices.update”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).
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);devices.delete
Section titled “devices.delete”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.
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
await sms.devices.delete('dev_…');devices.updateSim
Section titled “devices.updateSim”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).
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);devices.setDefaultSim
Section titled “devices.setDefaultSim”Makes this SIM the organization’s default sending SIM: messages without a deviceId, simId or poolId go through it.
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); // trueA 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.
pools.list
Section titled “pools.list”Every pool with the ids of its phones.
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);pools.create
Section titled “pools.create”Creates an empty pool.
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 });pools.update
Section titled “pools.update”Renames a pool.
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)' });pools.delete
Section titled “pools.delete”Deletes a pool. Its phones stay paired; their poolId becomes null.
import { SMSFabric } from '@smsfabric/sdk';
const sms = new SMSFabric({ apiKey: process.env.SMSFABRIC_API_KEY });
await sms.pools.delete('pool_…');