API Capycom v1
Crie e acompanhe cartas postais a partir de um script, n8n, Make ou um servidor MCP. O pagamento sempre é feito em capycom.ca, pelo titular da conta: a API nunca paga.
Princípios
- URL base:
https://capycom.ca/api/1.1/wf/<nom> - Todas as requisições são POST em JSON (
Content-Type: application/json). - A chave vai no campo
cledo corpo da requisição, nunca na URL. - Resposta:
{"status":"success","response":{...}}. Um erro de negócio também responde HTTP 200: verifiqueresponse.statut(okouerreur). Um erro contémerreur(código estável),message(inglês) emessage_fr. - Valores em dólares canadenses, antes dos impostos. Os impostos são calculados no pagamento.
- Um corpo que não seja um objeto JSON recebe HTTP 400.
Chave de API
Crie sua chave em Minha conta, Meu perfil, cartão "Acesso por API". Uma chave por conta: gerar uma nova revoga a anterior. A chave é exibida uma única vez; a Capycom guarda apenas uma impressão digital dela. Seu e-mail deve estar confirmado.
Pagar uma carta criada pela API
O campo lien_paiement leva à página de login e depois ao resumo da carta: envelope, documentos, preço e pagamento. Somente o titular da conta da chave pode ver esta carta: envie o link a essa pessoa. Um rascunho não pago é excluído automaticamente.
api_estimer_prix
Price of a letter before tax, without creating anything. Nenhuma chave necessária.
| Campo | Obrigatório | Descrição |
|---|---|---|
nombre_feuilles | sim | Number of sheets (whole number, from 1 to the accepted maximum). |
couleur | não | true for color printing (false by default). |
Resposta: statut, nombre_feuilles, couleur, enveloppe, montant_enveloppe, montant_feuilles, nombre_timbres, montant_timbres, total_avant_taxes, devise (CAD). Amounts in dollars.
Erros: 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. Chave obrigatória.
| Campo | Obrigatório | Descrição |
|---|---|---|
cle | sim | Your API key. |
pdf | sim | Object { "filename": "letter.pdf", "contents": "<base64 PDF>" }. 10 MB max, not password protected. A file URL is not accepted. |
dest_nom | sim | Recipient's full name or company (80 characters max). |
dest_ligne | sim | Street number and name. |
dest_appartement | não | Apartment or unit. |
dest_ville | sim | City. |
dest_province | sim | Code (QC, ON...) or French or English name (Québec, Quebec). |
dest_code_postal | sim | Canadian postal code, A1A 1A1 (space optional). |
exp_nom, exp_ligne, exp_appartement, exp_ville, exp_province, exp_code_postal | sim | The same fields for the sender (return address). exp_appartement is optional. |
couleur | não | true for color printing (false by default). |
langue | não | fr or en (Français or English accepted). Language of the summary page. Default: the account language. |
canal | não | api, mcp, n8n or make (api by default). Used for statistics. |
cle_idempotence | não | Text of up to 120 characters. Calling again with the same value returns the same draft instead of creating a second one. |
Resposta: 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).
Erros: 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. Chave obrigatória.
| Campo | Obrigatório | Descrição |
|---|---|---|
cle | sim | Your API key. |
id_courrier | sim | Identifier returned at creation. |
Resposta: The same fields as api_creer_courrier.
Erros: 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. Chave obrigatória.
| Campo | Obrigatório | Descrição |
|---|---|---|
cle | sim | Your API key. |
Resposta: 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.
Erros: 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. Chave obrigatória.
| Campo | Obrigatório | Descrição |
|---|---|---|
cle | sim | Your API key. |
id_courrier | sim | Identifier of the draft. |
Resposta: statut, id_courrier, statut_courrier (annule), message, message_fr.
Erros: 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"}'Códigos de erro
| Código | Significado |
|---|---|
cle_invalide | Chave ausente, desconhecida ou revogada (uma nova chave substitui a anterior). |
quota_atteint | Mais de 20 cartas criadas pela API em 24 horas nesta conta. |
code_postal_invalide | Código postal canadense inválido para o destinatário ou o remetente. |
province_invalide | Província ou território desconhecido (somente Canadá). |
adresse_invalide | Nome, rua ou cidade vazios ou longos demais. A mensagem indica o campo. |
pdf_invalide | PDF ausente, ilegível, protegido, maior que 10 MB ou com mais de 30 folhas. |
nombre_feuilles_invalide | Número de folhas que não é um número inteiro entre 1 e 30. |
introuvable | Nenhuma carta desta conta com este identificador (também vale para a carta de outra conta). |
non_annulable | A carta não é mais um rascunho: ela foi paga ou está em processamento. |
{
"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"
}Compatibilidade
Estes endpoints mantêm os nomes, os campos e as respostas da antiga API da Capycom. Os mesmos endereços também respondem em /version-test/api/1.1/wf/.
O servidor MCP da Capycom (https://mcp.capycom.ca/mcp) usa esta API. O código é público: https://github.com/Adel-11/Capycom.