Capycom API v1
通过脚本、n8n、Make 或 MCP 服务器创建并跟踪邮寄信件。付款始终由账户持有人在 capycom.ca 上完成:API 从不付款。
基础
- 基础网址:
https://capycom.ca/api/1.1/wf/<nom> - 所有请求均为 JSON POST(
Content-Type: application/json). - 密钥要放在
cle字段中,绝不放在网址里。 - 响应:
{"status":"success","response":{...}}. 业务错误同样返回 HTTP 200,请检查response.statut(ok或erreur). 错误包含erreur(稳定版代码),message(英文)和message_fr. - 金额以加拿大元计,不含税。税款在结账时计算。
- 请求正文不是 JSON 对象时,返回 HTTP 400。
API 密钥
创建您的密钥,位置: 我的账户,我的资料,“API 访问”卡片。每个账户只有一个密钥:生成新密钥会使旧密钥失效。密钥只显示一次,Capycom 只保存其指纹。您的电子邮箱必须已确认。
为通过 API 创建的信件付款
该 lien_paiement 字段会先跳转到登录页,再进入信件摘要:信封、文件、价格和付款。只有该密钥所属账户的持有人才能查看这封信,请把链接发给他们。未付款的草稿会被自动删除。
api_estimer_prix
Price of a letter before tax, without creating anything. 无需密钥。
| 字段 | 必填 | 描述 |
|---|---|---|
nombre_feuilles | 是 | Number of sheets (whole number, from 1 to the accepted maximum). |
couleur | 否 | true for color printing (false by default). |
响应: statut, nombre_feuilles, couleur, enveloppe, montant_enveloppe, montant_feuilles, nombre_timbres, montant_timbres, total_avant_taxes, devise (CAD). Amounts in dollars.
错误: nombre_feuilles_invalide
curl -X POST https://capycom.ca/api/1.1/wf/api_estimer_prix \
-H 'Content-Type: application/json' \
-d '{"nombre_feuilles": 1, "couleur": false}'{
"response": {
"couleur": false,
"devise": "CAD",
"enveloppe": "Petite",
"montant_enveloppe": 1.0,
"montant_feuilles": 0.8,
"montant_timbres": 1.56,
"nombre_feuilles": 1,
"nombre_timbres": 1,
"statut": "ok",
"total_avant_taxes": 3.36
},
"status": "success"
}api_creer_courrier
Creates a draft on the key holder's account from a PDF and two addresses, and returns the price and the payment link. Nothing is printed before the account holder pays. 需要密钥。
| 字段 | 必填 | 描述 |
|---|---|---|
cle | 是 | Your API key. |
pdf | 是 | Object { "filename": "letter.pdf", "contents": "<base64 PDF>" }. 10 MB max, not password protected. A file URL is not accepted. |
dest_nom | 是 | Recipient's full name or company (80 characters max). |
dest_ligne | 是 | Street number and name. |
dest_appartement | 否 | Apartment or unit. |
dest_ville | 是 | City. |
dest_province | 是 | Code (QC, ON...) or French or English name (Québec, Quebec). |
dest_code_postal | 是 | Canadian postal code, A1A 1A1 (space optional). |
exp_nom, exp_ligne, exp_appartement, exp_ville, exp_province, exp_code_postal | 是 | The same fields for the sender (return address). exp_appartement is optional. |
couleur | 否 | true for color printing (false by default). |
langue | 否 | fr or en (Français or English accepted). Language of the summary page. Default: the account language. |
canal | 否 | api, mcp, n8n or make (api by default). Used for statistics. |
cle_idempotence | 否 | Text of up to 120 characters. Calling again with the same value returns the same draft instead of creating a second one. |
响应: statut, id_courrier, statut_courrier, reference (empty until the letter is paid), canal, nombre_feuilles (counted in the PDF), couleur, enveloppe, amounts, total_avant_taxes, devise, destinataire and expediteur (multi-line text), lien_paiement (and lien_paiement_test, identical).
错误: cle_invalide, quota_atteint, code_postal_invalide, province_invalide, adresse_invalide, pdf_invalide
PDF64=$(base64 -w0 lettre.pdf)
curl -X POST https://capycom.ca/api/1.1/wf/api_creer_courrier \
-H 'Content-Type: application/json' \
-d '{"cle": "capy_VOTRE_CLE",
"pdf": {"filename": "lettre.pdf", "contents": "'"$PDF64"'"},
"dest_nom": "Entreprise Exemple", "dest_ligne": "100 rue Exemple",
"dest_ville": "Ottawa", "dest_province": "Ontario", "dest_code_postal": "K1A 0A1",
"exp_nom": "Marie Roy", "exp_ligne": "234 Rideau Street", "exp_appartement": "12",
"exp_ville": "Ottawa", "exp_province": "ON", "exp_code_postal": "K1N 0A9",
"langue": "fr", "cle_idempotence": "commande-0001"}'api_statut_courrier
Status, price and addresses of one letter of the account. 需要密钥。
| 字段 | 必填 | 描述 |
|---|---|---|
cle | 是 | Your API key. |
id_courrier | 是 | Identifier returned at creation. |
响应: The same fields as api_creer_courrier.
错误: cle_invalide, introuvable
curl -X POST https://capycom.ca/api/1.1/wf/api_statut_courrier \
-H 'Content-Type: application/json' \
-d '{"cle": "capy_VOTRE_CLE", "id_courrier": "3f6c2a9e-0000-0000-0000-000000000000"}'api_lister_courriers
The account's five most recent letters. 需要密钥。
| 字段 | 必填 | 描述 |
|---|---|---|
cle | 是 | Your API key. |
响应: statut, total_courriers, then five fixed slots courrier_1_* to courrier_5_*: id, statut, reference, canal, total_avant_taxes. An empty slot has an empty id.
错误: cle_invalide
curl -X POST https://capycom.ca/api/1.1/wf/api_lister_courriers \
-H 'Content-Type: application/json' \
-d '{"cle": "capy_VOTRE_CLE"}'api_annuler_brouillon
Cancels a draft: it is deleted right away with its pages and PDF files. 需要密钥。
| 字段 | 必填 | 描述 |
|---|---|---|
cle | 是 | Your API key. |
id_courrier | 是 | Identifier of the draft. |
响应: statut, id_courrier, statut_courrier (annule), message, message_fr.
错误: cle_invalide, introuvable, non_annulable
curl -X POST https://capycom.ca/api/1.1/wf/api_annuler_brouillon \
-H 'Content-Type: application/json' \
-d '{"cle": "capy_VOTRE_CLE", "id_courrier": "3f6c2a9e-0000-0000-0000-000000000000"}'错误代码
| 代码 | 含义 |
|---|---|
cle_invalide | 密钥缺失、未知或已撤销(新密钥会取代旧密钥)。 |
quota_atteint | 在 24 小时内,此账户通过 API 创建的信件超过 20 封。 |
code_postal_invalide | 收件人或寄件人的加拿大邮政编码无效。 |
province_invalide | 未知的省或地区(仅限加拿大)。 |
adresse_invalide | 姓名、街道或城市为空或过长。消息中会指出具体字段。 |
pdf_invalide | PDF 缺失、无法读取、受保护、超过 10 MB 或超过 30 张纸。 |
nombre_feuilles_invalide | 纸张数量不是 1 到 30 之间的整数。 |
introuvable | 此账户下没有该编号的信件(其他账户的信件也会返回此提示)。 |
non_annulable | 这封信已不再是草稿:已付款或正在处理中。 |
{
"response": {
"erreur": "cle_invalide",
"message": "API key missing, unknown or revoked.",
"message_fr": "Clé API absente, inconnue ou révoquée.",
"statut": "erreur"
},
"status": "success"
}兼容性
这些接口沿用了原 Capycom API 的名称、字段和响应。相同的地址也可通过以下路径访问: /version-test/api/1.1/wf/.
Capycom 的 MCP 服务器(https://mcp.capycom.ca/mcp)使用此 API。其代码是公开的: https://github.com/Adel-11/Capycom.