FaxTerra

Webhooks

FaxTerra posts an event to your https endpoint when a fax is delivered in full or in part, fails, will be tried again, or arrives.

An owner or admin adds an https endpoint in Settings, under Developer tools, and chooses its events; each is a POST of a WebhookEvent. It is signed: FaxTerra-Signature is t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with the endpoint's secret, shown once when the endpoint is added>. Compute it over the raw body, compare in constant time, and refuse a t more than 300 seconds from your clock. Roll secret on the endpoint in Settings replaces the secret; the old one stops at once. Answer any 2xx; anything else, or no answer, is tried again with a growing wait for about 3 days. 20 failures in a row turn the endpoint off and email the person who added it. The same event can arrive more than once: act on its id once. It carries ids, status and counts, never the document; read the fax with GET /faxes/{id} or GET /inbox/{id}. An account with the HIPAA add-on gets no numbers and no reference in the event.

Events

fax.delivered
A fax sent from this account was delivered.
fax.delivered_partial
A fax ended with only some of its pages delivered. Its fax status is failed; pagesDelivered says how many arrived.
fax.failed
A fax couldn't be delivered.
fax.retry_scheduled
A fax didn't go through and will be tried again.
fax.received
A fax arrived on one of this account's numbers.

Payload

idstring
The event id: the same on every delivery of this event
typeone of "fax.delivered", "fax.delivered_partial", "fax.failed", "fax.retry_scheduled", "fax.received"
createdAtstring, date-time
testtrue
Only on a test event you asked for, with POST /webhooks/{id}/test or Send test event in Settings. Its fax is a sample that matches no fax. Absent on every real event.
data.fax.idstring, uuid
data.fax.directionone of "outbound", "inbound"
data.fax.statusone of 13 values
Outbound: the fax status after this event. Inbound: received.
data.fax.pageCountinteger, or null
data.fax.pagesDeliveredinteger, or null
data.fax.errorCodeone of 13 values, or null
As Fax.error.code
data.fax.deliveredAtstring, date-time, or null
data.fax.receivedAtstring, date-time, or null
data.fax.nextAttemptAtstring, date-time, or null
data.fax.fromstring, or null
E.164; absent for an account with the HIPAA add-on
data.fax.tostring, or null
E.164; absent for an account with the HIPAA add-on
data.fax.referencestring, or null
Outbound: your reference from the send; absent for an account with the HIPAA add-on
data.fax.testtrue
Present on an event about a fax to a test number, or the echo from one: never dialled or charged. Absent otherwise.

Example events

fax.delivered

{
  "id": "8d1c2f6a-4b0e-4b7f-8a3c-5d2e1f0a9b8c",
  "type": "fax.delivered",
  "createdAt": "2026-11-21T15:06:42.000Z",
  "data": {
    "fax": {
      "id": "6fa459ea-ee8a-4ca4-894e-db77e160355e",
      "direction": "outbound",
      "status": "delivered",
      "pageCount": 2,
      "pagesDelivered": 2,
      "errorCode": null,
      "deliveredAt": "2026-11-21T15:06:40.000Z",
      "from": "+12025550142",
      "to": "+12015550101",
      "reference": "invoice-1042"
    }
  }
}

fax.delivered_partial

{
  "id": "8d1c2f6a-4b0e-4b7f-8a3c-5d2e1f0a9b8c",
  "type": "fax.delivered_partial",
  "createdAt": "2026-11-21T15:06:42.000Z",
  "data": {
    "fax": {
      "id": "6fa459ea-ee8a-4ca4-894e-db77e160355e",
      "direction": "outbound",
      "status": "failed",
      "pageCount": 30,
      "pagesDelivered": 22,
      "errorCode": "receiver_call_dropped",
      "from": "+12025550142",
      "to": "+12015550101",
      "reference": "invoice-1042"
    }
  }
}

fax.failed

{
  "id": "8d1c2f6a-4b0e-4b7f-8a3c-5d2e1f0a9b8c",
  "type": "fax.failed",
  "createdAt": "2026-11-21T15:06:42.000Z",
  "data": {
    "fax": {
      "id": "6fa459ea-ee8a-4ca4-894e-db77e160355e",
      "direction": "outbound",
      "status": "failed",
      "pageCount": 2,
      "pagesDelivered": 0,
      "errorCode": "receiver_no_answer",
      "from": "+12025550142",
      "to": "+12015550103",
      "reference": "invoice-1042"
    }
  }
}

fax.retry_scheduled

{
  "id": "8d1c2f6a-4b0e-4b7f-8a3c-5d2e1f0a9b8c",
  "type": "fax.retry_scheduled",
  "createdAt": "2026-11-21T15:06:42.000Z",
  "data": {
    "fax": {
      "id": "6fa459ea-ee8a-4ca4-894e-db77e160355e",
      "direction": "outbound",
      "status": "retry_scheduled",
      "pageCount": 2,
      "pagesDelivered": 0,
      "errorCode": "user_busy",
      "nextAttemptAt": "2026-11-21T15:08:42.000Z",
      "from": "+12025550142",
      "to": "+12015550102",
      "reference": "invoice-1042"
    }
  }
}

fax.received

{
  "id": "8d1c2f6a-4b0e-4b7f-8a3c-5d2e1f0a9b8c",
  "type": "fax.received",
  "createdAt": "2026-11-21T15:06:42.000Z",
  "data": {
    "fax": {
      "id": "9b2e7c1d-3f4a-4e5b-8c6d-7e8f9a0b1c2d",
      "direction": "inbound",
      "status": "received",
      "pageCount": 3,
      "receivedAt": "2026-11-21T15:06:40.000Z",
      "from": "+12015550100",
      "to": "+12025550142"
    }
  }
}

Test events

POST /api/v1/webhooks/{id}/test with { "type": "fax.delivered" }, or any event above. A signed event, sent the way every event is sent. With a fax event as type, the body is that event's example with "test": true at the top and a fax id that matches no fax. webhook.test, the default, has no fax. It is tried once, never retried, and doesn't count toward turning the endpoint off. A turned-off endpoint can be tested too. GET /api/v1/webhooks lists the account's endpoints and their ids, and Settings sends the same test from Developer tools.

Check the signature

Check every delivery before acting on it, over the raw body, comparing in constant time.

import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody: the request body exactly as received, before any JSON parsing
// signatureHeader: the FaxTerra-Signature header
export function verifyFaxTerraWebhook(rawBody, signatureHeader, secret) {
  if (!signatureHeader) return false;
  const parts = Object.fromEntries(signatureHeader.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  if (!Number.isFinite(t) || Math.abs(Date.now() / 1000 - t) > 300) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const given = Buffer.from(parts.v1 ?? "", "hex");
  const want = Buffer.from(expected, "hex");
  return given.length === want.length && timingSafeEqual(given, want);
}