API de Capycom v1
Cree y dé seguimiento a cartas postales desde un script, n8n, Make o un servidor MCP. El pago siempre se hace en capycom.ca, por el titular de la cuenta: la API nunca paga.
Conceptos básicos
- URL base:
https://capycom.ca/api/1.1/wf/<nom> - Todas las solicitudes son POST JSON (
Content-Type: application/json). - La clave va en el
cledel cuerpo de la solicitud, nunca en la URL. - Respuesta:
{"status":"success","response":{...}}. Un error de negocio también responde HTTP 200: verifiqueresponse.statut(okoerreur). Un error contieneerreur(código estable),message(inglés) ymessage_fr. - Montos en dólares canadienses, antes de impuestos. Los impuestos se calculan al pagar.
- Un cuerpo que no sea un objeto JSON recibe un HTTP 400.
Clave API
Cree su clave en Mi cuenta, Mi perfil, tarjeta «Acceso API». Una clave por cuenta: generar una nueva revoca la anterior. La clave se muestra una sola vez; Capycom solo conserva una huella de ella. Su correo electrónico debe estar confirmado.
Pagar una carta creada mediante la API
El lien_paiement lleva a la página de inicio de sesión y luego al resumen de la carta: sobre, documentos, precio y pago. Solo el titular de la cuenta de la clave puede ver esta carta: envíele el enlace. Un borrador sin pagar se elimina automáticamente.
api_estimer_prix
Price of a letter before tax, without creating anything. No se necesita clave.
| Campo | Obligatorio | Descripción |
|---|---|---|
nombre_feuilles | sí | Number of sheets (whole number, from 1 to the accepted maximum). |
couleur | no | true for color printing (false by default). |
Respuesta: statut, nombre_feuilles, couleur, enveloppe, montant_enveloppe, montant_feuilles, nombre_timbres, montant_timbres, total_avant_taxes, devise (CAD). Amounts in dollars.
Errores: 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. Se requiere una clave.
| Campo | Obligatorio | Descripción |
|---|---|---|
cle | sí | Your API key. |
pdf | sí | Object { "filename": "letter.pdf", "contents": "<base64 PDF>" }. 10 MB max, not password protected. A file URL is not accepted. |
dest_nom | sí | Recipient's full name or company (80 characters max). |
dest_ligne | sí | Street number and name. |
dest_appartement | no | Apartment or unit. |
dest_ville | sí | City. |
dest_province | sí | Code (QC, ON...) or French or English name (Québec, Quebec). |
dest_code_postal | sí | Canadian postal code, A1A 1A1 (space optional). |
exp_nom, exp_ligne, exp_appartement, exp_ville, exp_province, exp_code_postal | sí | The same fields for the sender (return address). exp_appartement is optional. |
couleur | no | true for color printing (false by default). |
langue | no | fr or en (Français or English accepted). Language of the summary page. Default: the account language. |
canal | no | api, mcp, n8n or make (api by default). Used for statistics. |
cle_idempotence | no | Text of up to 120 characters. Calling again with the same value returns the same draft instead of creating a second one. |
Respuesta: 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).
Errores: 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. Se requiere una clave.
| Campo | Obligatorio | Descripción |
|---|---|---|
cle | sí | Your API key. |
id_courrier | sí | Identifier returned at creation. |
Respuesta: The same fields as api_creer_courrier.
Errores: 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. Se requiere una clave.
| Campo | Obligatorio | Descripción |
|---|---|---|
cle | sí | Your API key. |
Respuesta: 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.
Errores: 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. Se requiere una clave.
| Campo | Obligatorio | Descripción |
|---|---|---|
cle | sí | Your API key. |
id_courrier | sí | Identifier of the draft. |
Respuesta: statut, id_courrier, statut_courrier (annule), message, message_fr.
Errores: 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 error
| Código | Significado |
|---|---|
cle_invalide | Clave ausente, desconocida o revocada (una clave nueva reemplaza a la anterior). |
quota_atteint | Más de 20 cartas creadas mediante la API en 24 horas en esta cuenta. |
code_postal_invalide | Código postal canadiense no válido para el destinatario o el remitente. |
province_invalide | Provincia o territorio desconocido (solo Canadá). |
adresse_invalide | Nombre, calle o ciudad vacíos o demasiado largos. El mensaje indica el campo. |
pdf_invalide | PDF ausente, ilegible, protegido, de más de 10 MB o de más de 30 hojas. |
nombre_feuilles_invalide | Número de hojas que no es un entero entre 1 y 30. |
introuvable | No hay ninguna carta de esta cuenta con este identificador (tampoco si es de otra cuenta). |
non_annulable | La carta ya no es un borrador: está pagada o en proceso. |
{
"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"
}Compatibilidad
Estos endpoints conservan los nombres, campos y respuestas de la antigua API de Capycom. Las mismas direcciones también responden en /version-test/api/1.1/wf/.
El servidor MCP de Capycom (https://mcp.capycom.ca/mcp) usa esta API. Su código es público: https://github.com/Adel-11/Capycom.