sinch-fax-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSinch Fax API
Sinch Fax API
Overview
概述
The Sinch Fax API lets you send and receive faxes programmatically. It supports multiple file formats, webhooks for incoming faxes, fax-to-email delivery, and automatic retries. Used for healthcare, legal, financial, and government applications where fax remains a required communication channel.
Auth: HTTP Basic () or OAuth2 bearer token. All examples use Basic auth. See sinch-authentication for setup.
keyId:keySecretSinch Fax API允许您以编程方式发送和接收传真。它支持多种文件格式、入站传真Webhook、传真转邮件交付以及自动重试功能。适用于医疗、法律、金融和政府类应用场景,这些场景中传真仍是必需的沟通渠道。
认证方式: HTTP Basic()或OAuth2承载令牌。所有示例均使用Basic认证。请参阅sinch-authentication进行设置。
keyId:keySecretGetting Started
快速开始
Before generating code, gather from the user: approach (SDK or direct API), language (Node.js, Python, Java, .NET, curl), and use case (sending, receiving, fax-to-email, or managing services). Do not assume defaults.
When the user chooses SDK, fetch the relevant API reference docs linked in Links for accurate method signatures. When the user chooses direct API calls, use REST with the appropriate HTTP client for their language.
| Language | Package | Install |
|---|---|---|
| Node.js | | |
| Python | | |
| Java | | Maven dependency |
| .NET | | |
在生成代码之前,需向用户确认以下信息:实现方式(SDK或直接调用API)、开发语言(Node.js、Python、Java、.NET、curl)以及使用场景(发送传真、接收传真、传真转邮件或管理服务)。请勿默认任何选项。
当用户选择SDK时,请参考链接中提供的相关API参考文档,以获取准确的方法签名。当用户选择直接调用API时,请使用REST方式,并结合其对应语言的合适HTTP客户端。
| 语言 | 包名 | 安装命令 |
|---|---|---|
| Node.js | | |
| Python | | |
| Java | | Maven依赖项 |
| .NET | | |
First API Call — Send a Fax
首次API调用——发送传真
curl (replace with your project ID from the Sinch dashboard):
{projectId}bash
curl -X POST \
'https://fax.api.sinch.com/v3/projects/{projectId}/faxes' \
-H 'Content-Type: application/json' \
-u YOUR_key_id:YOUR_key_secret \
-d '{
"to": "+12025550134",
"contentUrl": "https://example.com/document.pdf",
"callbackUrl": "https://yourserver.com/fax-callback"
}'Node.js SDK: See Send a Fax with Node.js.
Test number: Send to to emulate a real fax without charges (always suggest this for integration testing).
+19898989898curl(将替换为您在Sinch控制台中的项目ID):
{projectId}bash
curl -X POST \
'https://fax.api.sinch.com/v3/projects/{projectId}/faxes' \
-H 'Content-Type: application/json' \
-u YOUR_key_id:YOUR_key_secret \
-d '{
"to": "+12025550134",
"contentUrl": "https://example.com/document.pdf",
"callbackUrl": "https://yourserver.com/fax-callback"
}'Node.js SDK: 请参阅使用Node.js发送传真。
测试号码: 发送至可模拟真实传真发送且不产生费用(集成测试时建议始终使用该号码)。
+19898989898Key Concepts
核心概念
Fax Services — Logical containers for fax configuration. Associate numbers, set defaults, and manage routing.
Fax Numbers — Phone numbers provisioned for fax. Must be configured in your Sinch dashboard.
Faxes — Individual fax transmissions (inbound or outbound). Each has a unique ID, status, and metadata.
Fax statuses — → → or . Error details in and fields.
Supported formats — PDF (most reliable), DOC, DOCX, TIF/TIFF, JPG, PNG, TXT, HTML.
Webhooks/Callbacks — HTTP POST notifications for fax events. Default content type is (fax content as attachment). Set for JSON callbacks.
Cover Pages — Customizable cover pages per service. Attach via and on send.
Fax-to-Email — Incoming faxes auto-forwarded to email addresses.
Retries — Auto-retry on failure. Default set per fax service; maximum: 5.
Retention — Fax logs and media retained for 13 months. Use to remove earlier.
QUEUEDIN_PROGRESSCOMPLETEDFAILUREerrorTypeerrorMessagemultipart/form-datacallbackUrlContentType: "application/json"coverPageIdcoverPageDataDELETE /faxes/{id}/file传真服务 —— 用于配置传真的逻辑容器。可关联号码、设置默认值并管理路由。
传真号码 —— 为传真功能配置的电话号码。必须在Sinch控制台中完成配置。
传真任务 —— 单个的传真传输任务(入站或出站)。每个任务都有唯一ID、状态和元数据。
传真状态 —— (排队中)→ (处理中)→ (已完成)或(失败)。错误详情包含在和字段中。
支持的文件格式 —— PDF(最可靠)、DOC、DOCX、TIF/TIFF、JPG、PNG、TXT、HTML。
Webhook/回调 —— 针对传真事件的HTTP POST通知。默认内容类型为(传真内容作为附件)。可设置以接收JSON格式的回调。
封面页 —— 可针对每个服务自定义封面页。发送时通过和进行关联。
传真转邮件 —— 收到的传真会自动转发至指定邮箱地址。
自动重试 —— 发送失败时自动重试。默认次数由传真服务设置,最大为5次。
数据保留 —— 传真日志和媒体文件保留13个月。可使用提前删除。
QUEUEDIN_PROGRESSCOMPLETEDFAILUREerrorTypeerrorMessagemultipart/form-datacallbackUrlContentType: "application/json"coverPageIdcoverPageDataDELETE /faxes/{id}/fileCommon Patterns
常见使用模式
Three ways to deliver content: for URLs (recommended — supports basic auth), for local files, or for in-memory bytes. can be a single URL or an array of URLs to compose multi-document faxes.
contentUrlmultipart/form-datacontentBase64contentUrlFor HTTPS URLs, ensure your SSL certificate (including intermediate certs) is valid and up-to-date. You can optionally specify to set the sender number.
from- Send a fax (URL, file upload, base64, multiple recipients) — See Send a Fax endpoint. Use for local files, JSON with
multipart/form-datafor URLs.contentUrl - Receive faxes via webhook — Callbacks use the content type configured via (see Key Concepts). Check
callbackUrlContentTypeon the fax object. See Receive a Fax with Node.js.direction === 'INBOUND' - Fax-to-email — Configure via API or dashboard. Incoming faxes auto-forward to the configured email. See Fax-to-Email Reference.
- List faxes — See Faxes Endpoint Reference
- Get fax details —
GET /faxes/{id} - Download fax content — (
GET /faxes/{id}/file.pdfsuffix required).pdf - Delete fax content — (removes stored content before 13-month expiry)
DELETE /faxes/{id}/file - Manage fax services — See Services Endpoint Reference
- Manage cover pages — — see Services reference
POST/GET/DELETE /services/{id}/coverPages - Manage fax-to-email — See Fax-to-Email Reference
交付内容的三种方式:使用指定URL(推荐——支持Basic认证)、使用上传本地文件,或是使用传递内存中的字节数据。可以是单个URL,也可以是URL数组以组合多文档传真。
contentUrlmultipart/form-datacontentBase64contentUrl对于HTTPS URL,请确保您的SSL证书(包括中间证书)有效且为最新版本。您可选择性指定字段设置发送方号码。
from- 发送传真(URL、文件上传、Base64、多收件人) —— 请参阅发送传真端点。本地文件使用,URL使用JSON格式的
multipart/form-data。contentUrl - 通过Webhook接收传真 —— 回调的内容类型由配置(请参阅核心概念部分)。在传真对象中检查
callbackUrlContentType来判断是否为入站传真。请参阅使用Node.js接收传真。direction === 'INBOUND' - 传真转邮件 —— 可通过API或控制台进行配置。收到的传真会自动转发至配置的邮箱。请参阅传真转邮件参考文档。
- 列出传真任务 —— 请参阅传真端点参考文档
- 获取传真详情 ——
GET /faxes/{id} - 下载传真内容 —— (必须包含
GET /faxes/{id}/file.pdf后缀).pdf - 删除传真内容 —— (在13个月保留期前删除存储的内容)
DELETE /faxes/{id}/file - 管理传真服务 —— 请参阅服务端点参考文档
- 管理封面页 —— —— 请参阅服务参考文档
POST/GET/DELETE /services/{id}/coverPages - 管理传真转邮件 —— 请参阅传真转邮件参考文档
Troubleshooting
故障排查
Fax not delivered
传真未交付
- Check fax status via — look at
GET /faxes/{id},status(errorType,DOCUMENT_CONVERSION_ERROR,CALL_ERROR,FAX_ERROR,FATAL_ERROR), andGENERAL_ERRORerrorMessage - If was used with HTTPS, verify the SSL certificate (including intermediate certs) is valid
contentUrl - Fax delivery depends on the receiving machine answering — retries are automatic (max 5, default set per service)
- 通过查询传真状态——查看
GET /faxes/{id}、status(errorType、DOCUMENT_CONVERSION_ERROR、CALL_ERROR、FAX_ERROR、FATAL_ERROR)和GENERAL_ERROR字段errorMessage - 如果使用了且为HTTPS地址,请验证SSL证书(包括中间证书)是否有效
contentUrl - 传真交付依赖接收方设备应答——系统会自动重试(最多5次,默认次数由服务设置)
Fax content renders incorrectly
传真内容显示异常
- Complex DOC/DOCX formatting may not render perfectly on receiving machines. Recommend PDF instead.
- 复杂的DOC/DOCX格式在接收设备上可能无法完美渲染。建议使用PDF格式。
Cannot send or receive faxes
无法发送或接收传真
- Verify the number has fax capability enabled in the Sinch dashboard
- Numbers must be provisioned for fax before use
- 请在Sinch控制台中验证号码是否已启用传真功能
- 号码必须先完成传真功能的配置才能使用
Gotchas and Best Practices
注意事项与最佳实践
- Use for status tracking — fax delivery is async. Prefer callbacks over polling.
callbackUrl - PDF is the safest format for reliable rendering on receiving machines.
- Fax logs and media are retained for 13 months. Use to remove earlier, or download and archive if longer retention is needed.
DELETE /faxes/{id}/file - International fax success rates vary by country — some have specific dialing prefix requirements.
- Use (400 dpi) for faxes with small text or detailed images; default
resolution: "SUPERFINE"(200 dpi) works for most cases.FINE
- 使用跟踪状态——传真交付是异步的。优先使用回调而非轮询。
callbackUrl - 为确保在接收设备上可靠渲染,PDF是最安全的文件格式。
- 传真日志和媒体文件保留13个月。如需提前删除,可使用;如需更长时间保留,请下载并归档。
DELETE /faxes/{id}/file - 国际传真的成功率因国家而异——部分国家有特定的拨号前缀要求。
- 对于包含小字体或细节丰富的图像的传真,使用(400 dpi);默认的
resolution: "SUPERFINE"(200 dpi)适用于大多数场景。FINE