#SDK and CLI
#TypeScript SDK
npm install @mittis/sdkimport { Mittis } from '@mittis/sdk';
const mittis = new Mittis({ apiKey: process.env.MITTIS_API_KEY! });
// Send a message (use an sk_test_ key or the +15005550006 test number: never hits a carrier)
const message = await mittis.messages.send({
to: '+14155550199',
from: '+15005550006',
body: 'Your appointment is confirmed.',
});
// Numbers: search, buy, and point inbound calls at your desk
const { data: available } = await mittis.numbers.search({ areaCode: '415' });
const number = await mittis.numbers.buy(available[0].phoneNumber);
await mittis.numbers.setRoute(number.id, {
destinationType: 'pstn',
destination: '+14155551234',
});
// Inbound calls that rang that number
const { data: calls } = await mittis.calls.list({ status: 'missed' });- Errors. Every non-2xx response throws
MittisErrorwithstatusand the API's safe message. - Lists. List endpoints return
{ data }; the events feed also returns acursorfor resumable polling viamittis.events.list({ after }). - Webhooks.
verifyWebhookSignatureandparseWebhookEventverify deliveries;mittis.webhooks.create(url, { events }),mittis.webhooks.deliveries(id)andmittis.webhooks.retryDelivery(id, deliveryId)manage endpoints. See Webhooks. - Sub-accounts.
mittis.subaccount(id)returns a client scoped to one sub-account.
#CLI
npm install -g @mittis/cli # or: npx @mittis/cli <command>
mittis login # browser approval; add --test for a carrier-free sandbox key#Embed Mittis into your app
Inside your project:
mittis initThis installs @mittis/sdk, mints a test API key into your env file (never your live CLI key; pass --live to opt out), scaffolds a signature-verifying webhook handler (Next.js app router and Express get a scaffolded handler; anything else gets the SDK and env), and prints a quickstart. Re-running is safe: nothing is overwritten without --force.
#Develop against live events
mittis listen --forward-to http://localhost:3000/api/webhooks/mittislisten polls your account's durable event feed and re-delivers each event to your local endpoint, signed with the printed whsec_ secret using the exact production signature scheme, so the handler you test locally is the handler you ship. Filter with --events message.received,call.completed.
#Everyday commands
mittis whoami # tenant + key mode
mittis usage # period meters + budget
mittis numbers search --area-code 415 # find numbers
mittis numbers buy +14155550142
mittis numbers assign <id> --campaign <id> # attach to an approved 10DLC campaign
mittis numbers route set <id> --to sip:desk@sip.example.com --ring-timeout 20
mittis numbers route set <id> --to +14155551234 # or forward to a real phone
mittis messages send --to +1... --from +1... --body "On our way!"
mittis messages list --phone +14155550199
mittis conversations show +14155550199
mittis calls list --status missed # inbound human calls
mittis webhooks create https://app.example.com/webhooks/mittis
mittis webhooks test <id> # sample signed delivery
mittis keys create ci --test # more keys (test keys can't mint live ones)Every command takes --json for scripting. Credentials resolve from --api-key, then MITTIS_API_KEY, then the profile saved by mittis login (--profile <name> for multiple workspaces).
#OpenAPI
The full OpenAPI 3.1 document is published at /openapi.json. Feed it to any generator to produce a client in another language.