从这里开始
你的第一个要求,分四步走
Keep your main SMSMobileAPI subscription active; Telegram connection, API access, sending and sent-message history pause when it expires.
在仪表板中通过 QR code 连接您自己的 Telegram 帐户并同步其联系人。
从 My API Key 复制您的 SMSMobileAPI 密钥并将其保存在您的服务器上。
列出联系人并复制目标收件人的 contact_id。
Send JSON for text, or multipart/form-data to attach an image or document. Use the returned message_id to check the sent log.
您的 TELEGRAM 账户
连接、选择联系人,然后跟踪发送情况。
每位客户通过 QR code 扫描以连接其自己的 Telegram 帐户。在仪表板中同步联系人,使用返回的联系 ID 将消息入队,然后在已发送日志中检查其状态。
1连接
在 Telegram 仪表板页面扫描 QR code。
2查找联系人
先同步,然后通过 API 搜索联系人 ID。
3发送
使用幂等键 POST 一条 JSON 消息。
4追踪
读取排队、已发送、未知或错误状态。
验证
在服务器上保存证书
Send X-SMSMobileAPI-Key: YOUR_API_KEY in an HTTPS header. Keep this key on your server, never in browser JavaScript or a public repository. The endpoints are scoped to the Telegram account connected to that SMSMobileAPI account. A short-lived signed download_url can be opened without the key. Access can be disabled in My API Key.
- An expired SMSMobileAPI subscription blocks Telegram API access with HTTP 402 subscription_expired, including attachment downloads. Renew in the dashboard to restore access; existing connection and history are preserved.
- QR code 将每位客户自己的 Telegram 账户关联起来。消息由该账户发送,而非共享的 SMSMobileAPI 账户。
- 202 响应表示请求已排队。这并不证明 Telegram 已接受或投递该消息。请轮询已发送日志以确认已发送或错误。
- 本服务当前每次请求向一个已同步联系人或已保存的 @username 发送。请遵守 Telegram 规则并确保收件人同意。
- 请求速率限制为每分钟 15 条新消息,每个已连接账户最多 30 条排队消息。重试时使用稳定的 idempotency_key。
- Images and documents can be up to 5 MB. The send queue holds file bytes only until processing finishes; a separate private copy supports later downloads. File bytes are never embedded in the sent log.
- Newly sent attachments are kept in private storage for 90 days. The sent log returns a download_url valid for 15 minutes; request the log again to get a new link. Older attachments sent before this feature have no downloadable copy.
得到
列出 Telegram 联系人
https://api.smsmobileapi.com/telegram/contacts/返回您已连接的 Telegram 账户中可用的联系人。
按显示名称或 @username 搜索,然后使用 contact_id 发送。
参数
| 姓名 | 类型 | 所需经费 | 描述 |
|---|---|---|---|
q |
细绳 | 可选 | 可选的名称或用户名搜索,最多 80 个字符。 |
limit |
整数 | 可选 | 页面大小为 1 到 100;默认 50。 |
cursor |
整数 | 可选 | 使用上一次响应中的 paging.next_cursor;第一页请求时省略此参数。 |
请求示例
curl -G 'https://api.smsmobileapi.com/telegram/contacts/' \
-H 'X-SMSMobileAPI-Key: YOUR_API_KEY' \
--data-urlencode 'q=Alex' \
--data-urlencode 'limit=50'
示例回复
{"ok":true,"data":[{"contact_id":42,"display_name":"Alex Example","username":"alex_example","source":"telegram"}],"paging":{"has_more":false,"next_cursor":null}}
想听这个请求吗?连接页面上方的 API 键以解锁交互式测试器 。
连接密钥 QQ- 联系 ID 属于已连接的帐户;不能使用其他帐户的 ID。
- 当有人未出现时,请在仪表板 → Telegram 联系人 刷新联系人。
邮政
发送 Telegram 消息
https://api.smsmobileapi.com/telegram/send/将一条文本消息排入队列,发送到您已连接的 Telegram 帐户中的联系人。
请使用来自联系人端点的 contact_id。保存 message_id 以便跟踪。
参数
| 姓名 | 类型 | 所需经费 | 描述 |
|---|---|---|---|
contact_id |
整数 | 必需的 | 由 /telegram/contacts/ 返回的联系 ID。 |
message |
细绳 | 必需的 | UTF-8 文本,1–4096 字符且最多 16,000 字节。 |
idempotency_key |
UUID 字符串 | 可选 | 稳定的 36 字符小写 UUID 风格密钥。网络重试时重用以避免重复消息。 |
请求示例
curl -X POST 'https://api.smsmobileapi.com/telegram/send/' \
-H 'X-SMSMobileAPI-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"contact_id":42,"message":"Your appointment is confirmed.","idempotency_key":"2d40bb10-cc42-4c30-a282-93fc6dd8e161"}'
示例回复
{"ok":true,"message_id":123,"status":"queued","idempotency_key":"2d40bb10-cc42-4c30-a282-93fc6dd8e161","duplicate":false}
想听这个请求吗?连接页面上方的 API 键以解锁交互式测试器 。
连接密钥 QQ- HTTP 202 表示已入队;这并非送达回执。精确重试将返回 HTTP 200 并带有 duplicate=true 以及原始 message_id。
- 重试时,使用相同的 idempotency_key 并对同一联系人和消息重用。如果在相同键下更改了有效载荷,会返回 HTTP 409。
邮政
Send a Telegram image or document
https://api.smsmobileapi.com/telegram/send/Queue one file for a contact, with an optional caption.
Use multipart/form-data. The field name for the attachment is file.
参数
| 姓名 | 类型 | 所需经费 | 描述 |
|---|---|---|---|
contact_id |
整数 | 必需的 | 由 /telegram/contacts/ 返回的联系 ID。 |
file |
file | 必需的 | One JPG, PNG, WebP, PDF, TXT, CSV, JSON, ZIP or Office file, at most 5 MB. |
message |
细绳 | 可选 | Optional caption of at most 1024 characters. |
idempotency_key |
UUID 字符串 | 可选 | Reuse the same key and identical file and caption when retrying. |
请求示例
curl -X POST 'https://api.smsmobileapi.com/telegram/send/' \
-H 'X-SMSMobileAPI-Key: YOUR_API_KEY' \
-F 'contact_id=42' \
-F 'message=Here is the document.' \
-F 'file=@./document.pdf' \
-F 'idempotency_key=2d40bb10-cc42-4c30-a282-93fc6dd8e161'
示例回复
{"ok":true,"message_id":124,"status":"queued","idempotency_key":"2d40bb10-cc42-4c30-a282-93fc6dd8e161","duplicate":false}
想听这个请求吗?连接页面上方的 API 键以解锁交互式测试器 。
连接密钥 QQ- Do not set Content-Type manually; cURL adds the multipart boundary.
- For JSON clients, send file_base64 with the Base64 file contents and filename, alongside contact_id and an optional message caption.
- A queued response is not proof of delivery. Check GET /telegram/sent/?message_id=124.
- The connected Telegram account sends the file to one contact.
邮政
Send a Telegram file using JSON
https://api.smsmobileapi.com/telegram/send/Queue one image or document using a Base64 string when multipart upload is inconvenient.
Encode the original file bytes with Base64. Do not include an API key in the JSON body.
参数
| 姓名 | 类型 | 所需经费 | 描述 |
|---|---|---|---|
contact_id |
整数 | 必需的 | 由 /telegram/contacts/ 返回的联系 ID。 |
filename |
细绳 | 必需的 | Original file name, for example photo.png or invoice.pdf. |
file_base64 |
细绳 | 必需的 | Raw Base64 file contents or a data URI; decoded file must be 5 MB or smaller. |
message |
细绳 | 可选 | Optional caption of at most 1024 characters. |
idempotency_key |
UUID 字符串 | 可选 | Reuse the same key with identical file contents, filename and caption on retries. |
请求示例
curl -X POST 'https://api.smsmobileapi.com/telegram/send/' \
-H 'X-SMSMobileAPI-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"contact_id":42,"filename":"photo.png","file_base64":"BASE64_ENCODED_FILE","message":"See attached","idempotency_key":"2d40bb10-cc42-4c30-a282-93fc6dd8e161"}'
示例回复
{"ok":true,"message_id":125,"status":"queued","idempotency_key":"2d40bb10-cc42-4c30-a282-93fc6dd8e161","duplicate":false}
想听这个请求吗?连接页面上方的 API 键以解锁交互式测试器 。
连接密钥 QQ- Replace BASE64_ENCODED_FILE with the actual Base64 of a supported file.
- Use multipart/form-data instead if your client supports direct file upload; it avoids Base64 size overhead.
得到
列出已发送的 Telegram 消息
https://api.smsmobileapi.com/telegram/sent/返回最近的排队、发送中、已发送和发送失败的消息,按最新优先。
使用 message_id 对该端点进行轮询,以跟踪由 /telegram/send/ 返回的消息。
参数
| 姓名 | 类型 | 所需经费 | 描述 |
|---|---|---|---|
message_id |
整数 | 可选 | 返回 /telegram/send/ 的特定消息 ID。 |
contact_id |
整数 | 可选 | 将结果限制为一个联系人 ID。 |
status |
queued | sending | sent | error | unknown | 可选 | 按发送状态过滤。 |
limit |
整数 | 可选 | 页面大小为 1 到 100;默认 50。 |
cursor |
整数 | 可选 | 使用 paging.next_cursor 获取更早的消息。 |
请求示例
curl -G 'https://api.smsmobileapi.com/telegram/sent/' \
-H 'X-SMSMobileAPI-Key: YOUR_API_KEY' \
--data-urlencode 'message_id=123'
示例回复
{"ok":true,"data":[{"message_id":123,"contact_id":42,"contact_name":"Alex Example","username":"alex_example","message":"Your appointment is confirmed.","type":"text","media":null,"status":"sent","telegram_message_id":781,"error_code":null,"error_detail":null,"attempts":1,"queued_at":"2026-11-06T09:42:00+00:00","sent_at":"2026-11-06T09:42:04+00:00"}],"paging":{"has_more":false,"next_cursor":null}}
想听这个请求吗?连接页面上方的 API 键以解锁交互式测试器 。
连接密钥 QQ- The top-level type is text, image or file. For an attachment, media contains the filename, MIME type, size, download_url and available_until; media is null for text messages. File bytes are not embedded in the log.
- The download_url opens in a browser for 15 minutes. Refresh this endpoint for a new link while the file remains available.
- sent 表示 Telegram 已从已连接账户接受该消息;未报告收件人交付或已读回执。
- unknown 表示无法确认发送结果。请勿在此状态下盲目重发消息。
得到
Download a sent Telegram attachment
https://api.smsmobileapi.com/telegram/media/Downloads a previously sent image or document while it remains available.
Use media.download_url from the sent log, or call this endpoint with the account API key.
参数
| 姓名 | 类型 | 所需经费 | 描述 |
|---|---|---|---|
message_id |
整数 | 必需的 | Message ID returned by /telegram/send/. |
请求示例
curl -L 'https://api.smsmobileapi.com/telegram/media/?message_id=124' \
-H 'X-SMSMobileAPI-Key: YOUR_API_KEY' \
-o attachment
示例回复
Binary image or document bytes (Content-Type matches the file)
想听这个请求吗?连接页面上方的 API 键以解锁交互式测试器 。
连接密钥 QQ- A download_url returned by /telegram/sent/ is signed and works without an API key for 15 minutes. Keep it private.
- The authenticated endpoint requires the Telegram sent-log API access switch.
- Files are retained for 90 days; the type and filename remain in the log after expiry.
故障排除
错误和安全的重试
在重试前读取 HTTP 状态和 JSON 错误字段 。 不先更正请求, 不重试验证或认证失败 。
| HTTP | 代码 | 怎么办 |
|---|---|---|
| 401 | api_key_required / invalid_api_key | 发送有效的 X-SMSMobileAPI-Key 请求头。 |
| 402 | subscription_expired | Renew the SMSMobileAPI subscription linked to the API key. Telegram API access resumes after renewal. |
| 403 | API_ENDPOINT_DISABLED | 在 My API Key 中启用 Telegram API 或此特定端点。 |
| 404 | contact_not_found | 同步联系人并使用来自您自身 Telegram 连接的 ID。 |
| 409 | telegram_not_connected / idempotency_conflict | 连接 Telegram 或为已更改内容选择新的幂等键。 |
| 422 | invalid_message / invalid_pagination | 更正消息、联系 ID 或分页参数。 |
| 429 | queue_full / rate_limited | 等待排队发送或每分钟限制解除。 |
| 503 | sending_unavailable / service_unavailable | 发送工作进程或存储暂时不可用;请稍后重试。 |
| 503 | media_not_ready | File sending requires the current Telegram service update. Text sending remains available. |
| 404 / 410 | media_not_found / media_expired | The file is unavailable or past its 90-day retention period. |
需要帮助吗?
带上请求的背景 而不是你的秘密
共享端点,时间戳,HTTP状态和消毒响应. 永远不要包括API密钥,指使或私人消息内容.


