REST · CLI · OpenAPI

SingleFax API belgeleri ve CLI

API anahtarı ve ön ödemeli bakiye. npm’de resmi CLI veya curl, Node, Python, Go, PHP için doğrudan kullanılabilir REST örnekleri. Sohbet uygulamaları MCP kullanmalıdır.

CLI

npx @singlefax/cli send FILE --to +E164; özgün Word, Excel, PDF veya görsel dosyasıyla kullanın, önceden PDF’ye dönüştürmeyin.

REST

Bearer sf_live_… ve Idempotency-Key ile POST /api/v1/faxes.

Sohbet MCP’si

Cursor, Claude, Codex, ChatGPT. API anahtarı yerine OAuth kullanır. MCP kur.

Hızlı başlangıç

  1. API anahtarları üzerinden kapsamı sınırlı anahtar oluşturun (fax:send, fax:read, inbox:read, credits:read).
  2. Panelden veya npx @singlefax/cli credits buy üzerinden ön ödemeli bakiye yükleyin.
  3. Aşağıdaki CLI ile veya POST /api/v1/faxes üzerinden gönderin.

Temel URL https://api.singlefax.com (https://singlefax.com üzerinde aynı yollar). sf_test_ anahtarları gerçek gönderim yapamaz. Anahtarları tarayıcıya koymayın.

CLI

Node 20+. Yapılandırma: SINGLEFAX_API_KEY veya ~/.config/singlefax/config.json. Özgün dosyayı iletin (Word, Excel, PowerPoint, PDF, metin veya görsel). Önceden PDF’ye dönüştürmeyin. MCP OAuth veya Stripe MPP için değildir.

terminal
export SINGLEFAX_API_KEY=sf_live_…

npx @singlefax/cli send ./document.docx --to +14155552671
npx @singlefax/cli send ./document.pdf --to +14155552671 --wait --json
quote, status, credits
npx @singlefax/cli quote --to +14155552671 --pages 12
npx @singlefax/cli status <id>
npx @singlefax/cli list
npx @singlefax/cli numbers
npx @singlefax/cli numbers buy
npx @singlefax/cli credits
npx @singlefax/cli credits buy --dollars 20

Faks gönder

Tek istek: base64 belge ve hedef. PDF, Word, Excel, PowerPoint, metin veya görsel. Idempotency-Key zorunludur. Aynı anahtarı farklı gövdeyle kullanmak 409 döndürür.

terminal
PDF_B64="$(base64 < document.pdf | tr -d '\n')"

curl -sS https://api.singlefax.com/api/v1/faxes \
  -H "Authorization: Bearer $SINGLEFAX_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d "{\"to\":\"+14155552671\",\"base64\":\"$PDF_B64\"}"

Büyük dosyalar: önce yükleyin, sonra gönderin

CLI’nin yaptığı işlemler: yükleme belirteci oluşturmak, baytları PUT ile yüklemek, ardından uploadToken ile göndermek. PUT da Bearer belirteci gerektirir. Büyük dosyayı JSON’a gömmek yerine bu yöntemi kullanın. Önceden PDF’ye dönüştürmeyin.

terminal
UPLOAD=$(curl -sS https://api.singlefax.com/api/v1/uploads \
  -H "Authorization: Bearer $SINGLEFAX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contentType":"application/pdf"}')

UPLOAD_URL=$(printf '%s' "$UPLOAD" | python3 -c "import json,sys; print(json.load(sys.stdin)['uploadUrl'])")
TOKEN=$(printf '%s' "$UPLOAD" | python3 -c "import json,sys; print(json.load(sys.stdin)['uploadToken'])")

curl -sS -X PUT "$UPLOAD_URL" \
  -H "Authorization: Bearer $SINGLEFAX_API_KEY" \
  -H "Content-Type: application/pdf" \
  --data-binary @document.pdf

curl -sS https://api.singlefax.com/api/v1/faxes \
  -H "Authorization: Bearer $SINGLEFAX_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d "{\"to\":\"+14155552671\",\"uploadToken\":\"$TOKEN\"}"

REST başvuru belgeleri

YöntemYolKimlik doğrulamaNotlar
POST/api/v1/faxesfax:sendIdempotency-Key required. JSON { to, base64 | uploadToken } or multipart file.
GET/api/v1/faxesfax:readList. Query limit, offset.
GET/api/v1/faxes/{id}fax:readStatus including latest delivery attempt.
POST/api/v1/faxes/quotefax:read{ to, pages? | base64? }, quote without charging.
POST/api/v1/uploadsfax:sendReturns uploadToken + uploadUrl. PUT the bytes, then send with uploadToken.
GET/api/v1/creditscredits:readPrepaid balance.
POST/api/v1/credits/checkoutcredits:checkout{ amountCents }. Stripe Checkout for a credit pack.
GET/api/v1/received-faxesinbox:readInbound inbox list. Query limit, cursor. No transcripts in list.
GET/api/v1/received-faxes/{id}inbox:readInbound detail with bounded transcript slice. HIPAA Secure content is omitted.
GET/api/v1/numbersfax:readActive fax numbers.
POST/api/v1/numberscredits:checkout{ sku?, country?, state? }, default inbound_30day. Returns checkoutUrl + reserved phoneNumber.
GET/api/v1/skuspublicCatalog. Same shape as MCP list_skus.
POST/api/v1/checkoutcredits:checkout{ sku }, credit_pack, inbound, subscriptions, lifetime.

Tam şemalar: openapi.json. Geriye uyumsuz değişiklikler: sürüm politikası (90 günlük Sunset süresi). Bu bakiye API’sinde HTTP 402 yetersiz bakiye anlamına gelir. MPP 402 yalnızca POST /api/v1/machine/faxes içindir.

Webhook’lar

İmzalı fax.queued, fax.delivered, fax.failed ve credits.low_balance olayları. SingleFax-Signature (t=,v1=) doğrulamasını ham gövde üzerinde yapın. timestamp.payload için HMAC-SHA256 kullanılır. paneldeki webhook’lar bölümünden uç nokta ekleyin.

verify.mjs
import { createHmac, timingSafeEqual } from 'node:crypto'

export function verifySingleFaxSignature(rawBody, signatureHeader, secret, toleranceSeconds = 300) {
  const parts = Object.fromEntries(signatureHeader.split(',').map((kv) => kv.split('=')))
  const timestamp = Number(parts.t)
  if (!Number.isFinite(timestamp) || !parts.v1) return false
  if (Math.abs(Math.floor(Date.now() / 1000) - timestamp) > toleranceSeconds) return false
  const expected = createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex')
  const a = Buffer.from(parts.v1)
  const b = Buffer.from(expected)
  return a.length === b.length && timingSafeEqual(a, b)
}

Kısıtlamalar

  • API anahtarlarını sunucuda tutun. sf_live_ anahtarını web sayfasına gömmeyin.
  • PHI göndermeyin. Kapsam dahilindeki kuruluşlar web sitesinde elektronik BAA ile HIPAA Secure modunu kullanır.
  • Geçerli E.164 hedefleri. PDF, Word, Excel, PowerPoint, RTF, düz metin ve görseller; MIME türleri için OpenAPI’ye bakın. Önceden PDF’ye dönüştürmeyin; gönderimden önce biz dönüştürürüz.
  • Sohbet MCP’si ve Stripe MPP: /agents, mpp.md ve MPP ve Instant Checkout karşılaştırması.

Sık sorulan sorular

Makinece okunabilir belgeler

Tarayıcı robotları ve kodlama ajanları için düz Markdown ve OpenAPI. Bu sayfayla aynı bilgileri içerir.