PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/专题/打印排障

接口返回成功但没有出纸

创建任务返回 201 只表示已排队。要看任务是否变成 completed。免费套餐用轮询,Webhook 在付费套餐。调用 POST /v1/print-jobs,API Key 只放在服务端。

面向 遇到接口成功却没纸的人

其他语言版本: English

说明

很多云打印接口把受理当成成功。PrintBase 的创建响应是 id 加 status queued。纸打出来对应 completed。失败会带 AGENT_OFFLINE、PRINTER_OFFLINE、DOWNLOAD_FAILED、PRINT_ERROR 或 INVALID_CONTENT。

用 GET /v1/print-jobs/{id} 查询。响应里没有原来的 base64 正文。付费套餐才能登记 Webhook,而且只有 print_job.completed 和 print_job.failed。免费套餐登记会返回 403 PLAN_LIMIT_EXCEEDED。

这是英文确认出纸页的中文版。签名头是 X-PrintBase-Signature,对时间戳和原始 body 做 HMAC。

创建任务使用 POST /v1/print-jobs,请求头 Authorization: Bearer,正文包含 printer_code、content_type(pdf 或 raw)以及 content 或 content_url 二者之一。免费套餐是一台电脑每月 100 个任务。

接入步骤

  1. 01

    保存返回的 id

    不要只保存 HTTP 状态码。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  2. 02

    查询或订阅

    免费套餐轮询。付费套餐可加两个终态 Webhook。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  3. 03

    按原因处理

    电脑离线、打印机离线、下载失败和内容类型错误不是同一种上门动作。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  4. 04

    补打使用新键

    对已失败的任务再次 POST 时换 Idempotency-Key。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

Node.js — read job status

// 创建后立刻查询状态
const created = await fetch('https://api.printbase.cloud/v1/print-jobs', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': jobKey,
  },
  body: JSON.stringify({
    printer_code: Number(process.env.PRINTER_CODE),
    content_type: 'raw',
    content: Buffer.from(payload).toString('base64'),
    copies: 1,
  }),
}).then(async (res) => {
  if (!res.ok) throw new Error(await res.text());
  return res.json();
});

const status = await fetch(`https://api.printbase.cloud/v1/print-jobs/${created.id}`, {
  headers: { Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}` },
}).then((res) => res.json());
// status.status moves queued -> dispatched -> printing -> completed

这一套的细节

Webhook 事件范围

没有排队中的回调。不要等一个 queued 事件。Agent 只打印你提交的内容,不会替你向平台拉取单据。Agent 只打印你提交的内容,不会替你向平台拉取单据。

验签

用原始 body。重新序列化 JSON 会验签失败。Agent 只打印你提交的内容,不会替你向平台拉取单据。Agent 只打印你提交的内容,不会替你向平台拉取单据。

常见问题

返回 0 或 200 就一定出纸吗?

创建成功只是排队。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

completed 表示客人拿走了吗?

表示 Agent 报告打印过程结束。不表示有人核对过内容。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

免费有回调吗?(详见本页)

没有。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

同一把幂等键再 POST?

会返回原来的任务,不会再打一张。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

相关页面

  • 小票中文乱码和 GBK

    Agent 不会把 UTF-8 转成 GBK。中文小票要在 base64 之前按打印机字库编码。任务 completed 仍可能是乱码。调用 POST /v1/print-jobs,API Key 只放在服务端。

  • 扫码点餐如何自动打印后厨单

    扫码点餐的下单接口在服务端把后厨单打到对应档口。没有点餐插件,顾客手机也不保存打印密钥。调用 POST /v1/print-jobs,API Key 只放在服务端。

免费套餐:一台电脑每月 100 个任务,不需要信用卡。

免费注册查看 API 文档
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds