Early beta (v0.9) · free while in beta · nothing anyone says is kept once it is heard

Developers

A code, a key, a button

Pair a code and talk in about ten lines. Then make it yours: your own tenant and tokens, devices and keys, webhooks, relay recipes, receipts you can verify offline, and your own server.

Quick start · Make it yours · Playground · SDK · API reference

Quick start: pair a code and talk

In a browser or Node 22. The SDK is a package in the repository, packages/sdk; it is not on npm yet.

import { PttClient, webCryptoDeviceSigner } from "@tin-phone/sdk";

const api = "https://tinphone.thingwhen.com";
const post = (path: string, body?: unknown) =>
  fetch(api + path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body ?? {}) }).then((r) => r.json());

const { display: code } = await post("/ptt/v1/pair");             // start a call: share this code
const { privateKey, publicKey } = await crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, false, ["sign", "verify"]);
const der = new Uint8Array(await crypto.subtle.exportKey("spki", publicKey));
const { channelId } = await post("/ptt/v1/invites/redeem", { code, publicKeyDer: btoa(String.fromCharCode(...der)), name: "My app" });

const talk = await new PttClient({ apiUrl: api, signer: await webCryptoDeviceSigner(privateKey, der) }).connect(channelId);
talk.on("audio", (f) => play(f.payload));
talk.on("floor", (f) => { if (f.state === "granted" && f.holder === talk.me) startSending(); });   // talk.sendAudio(packet) every 20 ms
talk.press();

Someone joins the same call from the home page or a phone with the code you print. A pairing code is 8 characters, works for 30 minutes and lets up to 4 people in; the server allows 10 new calls and 30 joins per client every 10 minutes.

Make it yours

Your tenant and tokens

The operator makes your tenant and a tenant-admin token; it mints sender tokens for your services. A token is shown once; the server keeps its SHA-256, and revoking it stops even a request already in flight.

POST /admin/v1/tenants · POST /tenants/:t/tokens · POST /tenants/:t/tokens/:id/revoke

Devices and keys

A phone or program enrols with its own P-256 public key and signs every request; its id comes from the key. Revoke or replace a device at once.

POST /tenants/:t/devices · …/devices/:id/revoke · …/devices/:id/replace

Webhooks

The workflow engine writes every event to a per-tenant outbox and delivers it to your endpoints in order, at least once, with back-off, a dead-letter range and replay. Events hold ids, states and hashes, never content.

Signed with your tenant's key; see the workflow routes.

Relay recipes

A recipe is data: a source, steps and a sink, run with a sealed step per hop. The first: a mail reply, cut to an excerpt, translated by x-talk, sent on Telegram.

Relay and providers

Receipts and offline verification

Every step is a receipt on a SHA-256 chain, signed with Ed25519. Fetch the keys, then verify a chain in the SDK or an audit export on the command line.

GET /receipts/v1/keys · Verify one in your browser

Run it yourself

One Node 22 process with SQLite (packages/server-node), or Cloudflare Workers with D1. The same SQL on both; push-to-talk runs on Node today.

pnpm --filter @tin-phone/server-node build · node packages/server-node/dist/main.mjs

The push-to-talk demo

Hold-to-talk in the browser, with invites and babel-fish.

On the pre-production server

Start a call and you get a pairing code to share; the other person types it on a phone or opens your link. An invite link (it ends in #invite=…) works too. Open it in two browsers or on two phones, pick a name and the language you listen in, then hold the button and talk.

Without a code or a link, the page offers Start a call and Join with a code. You can also start one on the home page.

What you will see

  • Your browser makes its own device key; it never leaves the browser.
  • Hold to talk: the others hear you as you speak. Let go, and the floor is free.
  • Speak, or type what you said; each listener gets it in their own language and hears it read aloud.
  • No microphone? Tick "Test tone" and the browser sends a tone instead.

Run it on your own machine

Node 22 and pnpm. Nothing here is a real secret: the demo makes a development key and an admin token for the run and throws them away.

pnpm install
pnpm --filter @tin-phone/server-node build
node packages/server-node/scripts/ptt-demo.mjs
# prints an invite link for http://127.0.0.1:8788; open it in two browsers
# options: --port 8788  --host 0.0.0.0 (phones on the same network)  --xtalk <x-talk URL>

Without --xtalk, a local stand-in answers each translation as [lang] words, so babel-fish can be seen without x-talk. In one browser, add ?as=bob to the address to be a second person in another tab.

API playground

Pick a call and fill in the blanks; copy the command. Calls that need no token can be sent from here.

Choose a call.

The token stays a placeholder, $TIN_PHONE_TOKEN: set it in your own shell. This page never asks for it.

Nothing sent yet.

Verify a receipt chain

The conformance vectors, verified with WebCrypto in your browser.

Open the verifier.

SDK reference

@tin-phone/sdk: TypeScript for browsers, Node 22 and React Native.

Channels and messages: TinPhoneClient

import { TinPhoneClient } from "@tin-phone/sdk";

const client = new TinPhoneClient({ apiUrl: "https://tin-phone.example", apiKey: token });

const channel = await client.createChannel("websocket", participants);
await client.sendMessage(channel.id, sender, { type: "text", body: "Hello!" });
const history = await client.getMessages(channel.id);
await client.getAdapters();
await client.health();
await client.closeChannel(channel.id);

// Realtime
const socket = client.connect(channel.id, "user1");
socket.onMessage((msg) => console.log(msg));
socket.onPresence((p) => console.log(p));
socket.open();
socket.send({ type: "text", body: "Hi there!" });

Errors are TinPhoneError.

Device notices: NoticesClient

Contract version 1.0.0, checked by the conformance vectors.

import { NoticesClient } from "@tin-phone/sdk";

const notices = new NoticesClient({ baseUrl, tenantId, token, trustedKeys });
const sent = await notices.send({ to: [deviceId], content: { type: "text", body: "Gate 4 is open" } });
await notices.get(sent.id);                 // per-device states
await notices.waitFor(sent.id, (s) => s.deliveries.every((d) => d.state === "acknowledged"));
const { events, check } = await notices.verifiedReceipts(sent.id);   // throws unless the chain verifies
await notices.revoke(sent.id);
NoticesClient
MethodDoes
send(input)sends a notice: to, content, actions, ttlSeconds or expiresAt, followUp
get(id)the notice and each delivery's state
revoke(id)takes it back from every device that has not acknowledged
receipts(id)the sealed chain, as the server gives it
verifiedReceipts(id, keys?)the chain, verified against the keys you pinned
waitFor(id, done, options)polls until done(status) is true or the wait runs out
verifyReceiptChain(events, keys, id?)the verifier on its own: {ok, count, head} or the first failure's seq and code

Errors are NoticeApiError with a kind (invalid, unauthorised, forbidden, not-found, conflict, unavailable, server, unexpected), ReceiptVerificationError and NoticeWaitTimeoutError.

Push-to-talk: PttClient and PttSession

import { PttClient, webCryptoDeviceSigner } from "@tin-phone/sdk";

const signer = await webCryptoDeviceSigner(privateKey, publicKeyDer);   // Pillion's request signing
const ptt = new PttClient({ apiUrl, signer });
const [first] = await ptt.channels();
const talk = await ptt.connect(first.id);
talk.on("audio", (f) => player.play(f.payload));
talk.on("floor", (f) => {
  // press() only asks; send once the server grants the floor to this device
  if (f.state === "granted" && f.holder === talk.me) startSending();
});
talk.press();
// while talking (talk.talking is true), every 20 ms: talk.sendAudio(packet)
// when the key is let go: talk.release()

The session checks each sealed digest against what it heard and confirms a replay as heard only when they match. ptt.iceServers() gives STUN and TURN for WebRTC.

WebRTC: PttRtcMesh

import { PttRtcMesh } from "@tin-phone/sdk";

const mesh = new PttRtcMesh(talk, {        // the connected PttSession, then the options
  RTCPeerConnection,                       // the platform's
  iceServers: () => ptt.iceServers(),      // refreshed before the TURN credential runs out
  localStream: () => navigator.mediaDevices.getUserMedia({ audio: true }),
  onRemoteStream: (from, stream) => play(stream),
});

Writing an adapter

  1. Create packages/adapters/<name>/ with its package.json and tsconfig.json.
  2. Implement the Adapter interface from @tin-phone/core.
  3. Declare its capabilities: realtime, bidirectional, richContent, presence, typing.
  4. send() for outbound delivery; parse() for inbound events; verify() for webhook signatures, if it has them.
  5. Tests in src/__tests__/.

Writing a provider

  1. packages/providers/<name>/, exporting . and ./fake.
  2. A classifier for the provider's error bodies, and a class implementing TextSink (or a narrower API) that passes its secrets in for redaction.
  3. A fake built on FakeProvider, with the provider's real request checks and error bodies.
  4. Tests of the adapter against its fake, including each refusal and each error kind.

API reference

tin-phone public notices API: Send a notice to enrolled devices of a tenant and read its delivery and acknowledgement receipts. Contract version 1.0.0, OpenAPI 3.1.0.

Authentication

A tenant API credential: 20 to 128 characters of [A-Za-z0-9_-], issued once by the tenant's admin (role sender) or the operator. The server keeps only its SHA-256. The operator's own token is accepted too but is not part of this contract.

The base address is the operator's: a self-hosted server answers on http://127.0.0.1:8787 by default.

Notices

POST /tenants/{tenantId}/notices

Send a notice to enrolled devices Bearer tenant token

Role sender only. Every addressee must be an enrolled, unrevoked device of this tenant; otherwise 403 with the same answer for an unknown, another tenant's or a revoked device, so a sender learns nothing about devices outside its tenant. The notice and one queued receipt per device commit together.

tenantId path, required
The tenant. personal is never a tenant: every route refuses it (403).

Body: SendNoticeRequest

  • 201 The notice was queued for every addressee. (SentNotice)
  • 400 The request is malformed or breaks a limit. (Error)
  • 401 No credential, or one the server does not know. (Error)
  • 403 The credential is of another tenant, its role may not do this, an addressee is not an enrolled device of this tenant, or the tenant is personal. (Error)
  • 404 No such tenant or notice (or it is another tenant's). (Error)
  • 503 Notice delivery is not configured on this server. (Error)

Try it in the playground

GET /tenants/{tenantId}/notices/{noticeId}

Delivery state per device Bearer tenant token

Roles sender and tenant-admin. Overdue deliveries are expired before the answer. A notice of another tenant is 404.

tenantId path, required
The tenant. personal is never a tenant: every route refuses it (403).
noticeId path, required
  • 200 The notice and one delivery per addressee. (NoticeStatus)
  • 401 No credential, or one the server does not know. (Error)
  • 403 The credential is of another tenant, its role may not do this, an addressee is not an enrolled device of this tenant, or the tenant is personal. (Error)
  • 404 No such tenant or notice (or it is another tenant's). (Error)
  • 503 Notice delivery is not configured on this server. (Error)

Try it in the playground

POST /tenants/{tenantId}/notices/{noticeId}/revoke

Take a notice back Bearer tenant token

Role sender only. Every open delivery (queued or delivered) becomes revoked, sealed; acknowledged and expired deliveries keep their state. Idempotent.

tenantId path, required
The tenant. personal is never a tenant: every route refuses it (403).
noticeId path, required
  • 200 The deliveries after the revocation. (RevokedNotice)
  • 401 No credential, or one the server does not know. (Error)
  • 403 The credential is of another tenant, its role may not do this, an addressee is not an enrolled device of this tenant, or the tenant is personal. (Error)
  • 404 No such tenant or notice (or it is another tenant's). (Error)
  • 503 Notice delivery is not configured on this server. (Error)

Try it in the playground

GET /tenants/{tenantId}/notices/{noticeId}/receipts

The sealed receipt chain of a notice Bearer tenant token

Roles sender and tenant-admin. events is the whole chain, oldest first. check is the server's own check and is informative only: a client verifies events itself against the seal keys it pinned. A receipt never carries the notice's content, only its digest.

tenantId path, required
The tenant. personal is never a tenant: every route refuses it (403).
noticeId path, required
  • 200 The chain and the server's check of it. (NoticeReceipts)
  • 401 No credential, or one the server does not know. (Error)
  • 403 The credential is of another tenant, its role may not do this, an addressee is not an enrolled device of this tenant, or the tenant is personal. (Error)
  • 404 No such tenant or notice (or it is another tenant's). (Error)
  • 503 Notice delivery is not configured on this server. (Error)

Try it in the playground

Schemas

Error

Every error. The HTTP status is the contract; error is a human-readable sentence that may change between minor versions.

error required
string

Health

status required
any
service
string
version
string

DeviceId

A device ID: base32 of SHA-256 over the device's P-256 SPKI key, first 26 characters.

string

Digest

Lowercase hex SHA-256.

string

UnixMillis

integer

NoticeContent

type required
"text" | "html" | "json" | "binary" | "audio" | "event"
body required
string: At most 64 KiB of UTF-8.
mimeType
string

NoticeAction

id required
string
label required
string

FollowUpRequest

afterMinutes required
integer
times required
integer

FollowUp

afterMs required
integer
times required
integer

SendNoticeRequest

to required
array of DeviceId: Duplicates are collapsed.
content required
NoticeContent
ttlSeconds
number: Default 7 days. Not with expiresAt.
expiresAt
UnixMillis: Within the next 30 days. Not with ttlSeconds.
actions
array of NoticeAction: The replies a device may acknowledge with. Without actions a device acknowledges with acknowledge.
followUp
FollowUpRequest or null: Re-notify devices that have not acknowledged.

DeliveryState

"queued" | "delivered" | "acknowledged" | "expired" | "revoked"

Delivery

noticeId required
string
deviceId required
DeviceId
state required
DeliveryState
updatedAt required
UnixMillis
deliveredAt required
integer or null
acknowledgedAt required
integer or null
ackAction required
string or null: The action the device acknowledged with (acknowledge for a plain acknowledgement).
reminders required
integer
lastNotifiedAt
integer or null

NoticeStatus

id required
string
expiresAt required
UnixMillis
revokedAt required
integer or null
actions required
array of NoticeAction
followUp required
FollowUp
deliveries required
array of Delivery

RevokedNotice

id required
string
deliveries required
array of Delivery

ReceiptWho

id required
string
name required
string
role required
string

SealedReceipt

One sealed step. hash = lowercase hex SHA-256 of the UTF-8 canonical JSON of {lineId, seq, at, who, what, text, data, prev} (keys sorted by UTF-16 code unit at every depth); sig = base64 Ed25519 over the UTF-8 bytes of the 64-character hash; keyId = first 16 hex of SHA-256 over the seal key's SPKI DER. The shape of @contextual/seal.

lineId required
string: The notice ID.
seq required
integer
at required
string: ISO 8601 UTC.
who required
ReceiptWho
what required
"queued" | "delivered" | "acknowledged" | "expired" | "revoked" | "reminded"
text required
string
data required
object
prev required
Digest
hash required
Digest
keyId required
string
sig required
string

ChainCheck

object or object

Every other route

Outside the versioned notices contract; they may change between versions.

Routes by area
AreaWhoRoutes
Channels and messagesBearer: operator or tenant tokenGET /health · GET /adapters · POST /channels · GET /channels/:id · DELETE /channels/:id · POST /channels/:id/messages · GET /channels/:id/messages · POST /webhooks/:adapterId
OperatorBearer: admin tokenPOST /admin/v1/tenants · POST /admin/v1/tenants/:t/tokens · POST /admin/v1/devices · POST /admin/v1/devices/import · POST /admin/v1/devices/:id/revoke · GET /admin/v1/tenants/:t/devices · POST /admin/v1/tenants/:t/tokens/:id/revoke · POST /admin/v1/tenants/:t/workflow-credentials/:id/revoke
Tenant adminBearer: tenant-admin token, or the operatorPOST /tenants/:t/tokens · POST /tenants/:t/tokens/:id/revoke · POST /tenants/:t/devices · POST /tenants/:t/devices/:id/revoke · POST /tenants/:t/devices/:id/replace · GET /tenants/:t/devices · GET /tenants/:t/audit?format=json|csv&from=&to=
DevicesSigned by the device (X-Pillion-*)GET /devices/v1/self · GET /devices/v1/notices · GET /devices/v1/notices/stream (SSE) · GET /devices/v1/notices/socket (WebSocket) · POST /devices/v1/notices/:id/received · POST /devices/v1/notices/:id/ack
Receipt keysNone; rate limited, cacheableGET /receipts/v1/keys
Push-to-talkTenant admin or operator; devices signPOST /ptt/v1/tenants/:t/channels · GET /ptt/v1/tenants/:t/channels/:id · GET /ptt/v1/tenants/:t/channels/:id/receipts · GET /ptt/v1/device/channels · POST /ptt/v1/device/channels/:id/ticket · POST /ptt/v1/device/channels/:id/spurts/:spurtId/heard · GET /ptt/v1/device/ice · GET /ptt/v1/socket?ticket=…
RelayTenant admin; postmaster signs its eventsPOST /relay/v1/tenants/:t/telegram/links · PUT /relay/v1/tenants/:t/sources/postmaster · POST /relay/v1/postmaster/:tenantId · POST /relay/v1/telegram/webhook
Pillion FleetBearer: operator token of the tenantPOST /fleet/v1/admin/tenants/:t/operator-tokens · GET /fleet/v1/tenants/:t/jobs · POST /fleet/v1/tenants/:t/jobs · GET /fleet/v1/tenants/:t/jobs/:id · the console at /fleet