Cartaventa

Docs · Connect other apps

Use the API

The API lets another app do what you do in the dashboard: publish, upload a new version, share, revoke access, archive, and see who viewed what. It works on your behalf, only with the permissions you give it, and it emails you about anything sensitive.

Your API key

In Settings → API, under Create a key, give it a name that tells you where you’ll use it (“Prospector,” “Claude Code”) and check what it can do. For a read-only integration, leave only the first box checked.

Permission What it allows
documentos:leer See the list and the details, including the emails of the people you shared with
documentos:publicar Publish documents and upload new versions
documentos:compartir Share on your behalf and receive the links
documentos:revocar Revoke one person’s access
documentos:archivar Revoke everyone’s access and archive; we notify you and you can undo it

Three things to know:

  • The key is shown only once. If you lose it, revoke it and create another one.
  • You need a recent login to create one. If your session is a few days old, we email you a Magic Link and you create the key from that new session. That way, someone who has your session open somewhere else can’t create a key for themselves.
  • It acts as you, on every document in your account, including ones a teammate published. It can’t manage your account or create other keys. It expires after 12 months.

You get an email every time a key is created or revoked. If you get one you weren’t expecting, revoke the key and click Log out my other sessions in Settings.

Test it

The key goes in the Authorization header:

curl https://api.cartaventa.com/v1/yo -H "Authorization: Bearer cv_live_…"

It returns who you are, your account, and the key’s permissions. A 401 means the key was copied wrong, was revoked, or has expired.

Routes

Route Permission What it does
GET /v1/yo read Who this key belongs to
GET /v1/documentos read Your documents, 20 at a time (?estado=activo|archivado|todos&limite=…&cursor=…)
POST /v1/documentos publish Publishes a new document; returns 201
GET /v1/documentos/{id} read The details: versions, plus each person with their status and views
POST /v1/documentos/{id}/versiones publish New version, same link
POST /v1/documentos/{id}/compartir share Shares and returns each person’s link
POST /v1/documentos/{id}/revocar revoke Revokes one person’s access
POST /v1/documentos/{id}/revocar-todos archive Revokes everyone’s access
POST /v1/documentos/{id}/archivar archive Archives the document

{id} is the public_id returned by publish and by the list; it’s the same one in the document’s link. Dates are in UTC with a Z, and lists come back as { datos, siguiente_cursor }: when siguiente_cursor is null, there are no more results.

Publish and replace

The HTML follows the same rules as in the dashboard (HTML requirements), goes through the same moderation, and shares the same cap of 30 uploads per hour. You can send it three ways:

The raw file, up to 5 MB, with the title in the query string. Use this for large files:

curl -X POST "https://api.cartaventa.com/v1/documentos?titulo=Acme%20Proposal" \
  -H "Authorization: Bearer cv_live_…" \
  -H "Content-Type: text/html" \
  --data-binary @proposal.html

As a form, with the titulo and archivo fields, also up to 5 MB:

curl -X POST https://api.cartaventa.com/v1/documentos \
  -H "Authorization: Bearer cv_live_…" \
  -F titulo="Acme Proposal" -F archivo=@proposal.html

As JSON, { "titulo": "…", "html": "…" }, up to 512 KB. Easiest when the HTML is already in a variable.

With any of the three you can set restriccion: estandar (Standard Access, the default) or estricta (Verified Access), where each person confirms their email with a code we send them. We recommend Verified Access for integrations: the link returned when you share only identifies the person; on its own, it doesn’t open the document. Pass it in the query string (&restriccion=estricta), as a form field, or in the JSON.

To upload a new version, make the same request to /v1/documentos/{id}/versiones, without a title. It returns the new version and how many people will see the change the next time they view it.

Share

curl -X POST https://api.cartaventa.com/v1/documentos/{id}/compartir \
  -H "Authorization: Bearer cv_live_…" \
  -H "Content-Type: application/json" \
  -d '{"destinatarios": [{"nombre": "Sarah Chen", "correo": "sarah@acme.com"}], "mensaje": "Here is the proposal we discussed."}'
  • Each recipient has a nombre, a correo, or a telefono (their WhatsApp number), or any combination. On a Verified Access document, correo is required.
  • A telefono with + and its country code is saved as is (+1 512 555 0123, +52 55 1234 5678). Without the +, also send pais with the country’s two-letter code ("pais": "US", "MX", "GB"…). Without pais, the country comes from your account’s language: the US if it’s in English, Mexico if it’s in Spanish.
  • One invalid recipient doesn’t fail the whole request: it’s returned in invalidos with its position, error code, and reason, and everyone else is shared normally.
  • With "enviar_correo": false, we don’t email anyone: your app gets the links and sends them itself.
  • The response includes creados, repetidos, invalidos, and fallidos, and each person with their link. It’s the only API response that contains links; treat them like passwords.
  • repetidos are people who already had access: they don’t get another email, but they get a new link so you always have the current one. The link the API gave you earlier stops working; the ones sent by email and the ones you copied in the dashboard don’t.
  • fallidos are people who were added but whose email didn’t go out: their link is there so you can send it yourself.

These caps protect you if an agent gets tricked by a malicious email: 5 people and 2 different companies (email domains) per call; 20 people a day per user and 60 per account. People who already had access and people without an email count too. For more than that, share from the dashboard.

Every call that shares sends you an email with who it was shared with. If it wasn’t you, revoke the key.

Revoke access and archive

  • POST …/revocar with { "destinatario_id": "…" } (from the share response or the details) or { "correo": "…" }. It’s safe to repeat. A single key can revoke access for at most 10 people per hour.
  • POST …/revocar-todos revokes access for everyone who had it.
  • POST …/archivar turns the document off; if it was already archived, you get the same response.

Revoking everyone and archiving can be undone from the email: as soon as it happens, you get a notice with an Undo button that works without logging in, for 72 hours (revoke everyone) or 7 days (archive). It restores access with the same links as before, and your clients aren’t notified. The API can’t restore a document: you do that in the dashboard.

If a key does four of these things in 24 hours (archive, or revoke access for everyone or for one person), instead of one email per action you get a single email with a button that undoes everything that key has done since then and revokes it.

If the document belongs to a teammate, they also get their own notice with their own Undo button, under the same rule: three separate notices, and on the fourth, a single one that undoes everything on their documents. Their button keeps working even if the person who created the key is deactivated, and when either of you undoes, you both get a confirmation.

Retries

Retrying a write doesn’t perform it twice. If the same key sends the same request within 60 seconds, with no other write in between, it gets the original response (with the same links, and no emails sent again) and the header Idempotent-Replayed: true. Revoking access, revoking everyone, and archiving don’t need that window: repeating them changes nothing. To retry safely after that, send your own idempotency key:

-H "Idempotency-Key: share-acme-proposal-sarah"

We recognize the operation by that key for 24 hours. Use a unique key for each operation: reusing a key with a different body returns an error.

Limits

What Limit
Reads (GET) 120 per minute per key
Publish or replace 30 per hour per user, across every surface
Share 5 people and 2 domains per call; 20 a day per user, 60 per account
Changes of any kind (POST) 60 per minute per key
Revoking one person’s access 10 per hour per key
API keys 10 active and 5 created per hour per user

When you hit one, you get a 429 with limite_ritmo, the name of the limit, and, when available, a Retry-After header.

Alerts you’ll get

Besides the ones for sharing, archiving, and revoking, we email you if a key pulls the details of more than 25 documents in an hour: sweeping your whole catalog is a telltale sign of an agent following someone else’s instructions. If you asked it to do that, you can ignore the email.

If your clients’ email addresses shouldn’t reach other apps, the Account Holder can turn on “Hide recipient emails from the API” in Settings → API: the details then show them as s***@acme.com, with no name.

Errors

Every error comes back as application/problem+json:

{
  "type": "https://cartaventa.com/guias/usar-la-api#limite_ritmo",
  "title": "Rate limit reached",
  "status": 429,
  "codigo": "limite_ritmo",
  "mensaje": "You uploaded 30 documents or versions in the last hour, which is the limit...",
  "limite": "publicar_por_hora"
}

codigo never changes; the text in mensaje can. type is a stable identifier and points to the Spanish edition of this page in every language; the same anchors work here, at /en/docs/api#<codigo>. Any details you need to fix the request, like the moderation rule or the limit, come back as top-level fields alongside it.

moderacion_bloqueada

Moderation blocked the document. reglas tells you which rule fired and why; fix the HTML and send it again. See When a document won’t publish.

html_invalido

Cartaventa can’t accept this HTML: it isn’t HTML, it contains something that isn’t allowed, or it has a broken image. The message tells you which.

html_demasiado_grande

The document is too large. JSON bodies can be up to 512 KB; raw files and forms, up to 5 MB. The stored document, after image compression, can’t exceed 5 MB either.

cuota_paginas_activas

Your plan has reached its limit of live documents. Archive one you no longer use or upgrade your plan; what you’ve already shared keeps working.

slug_sin_confirmar

The account hasn’t confirmed its subdomain yet. Log in to the dashboard once and confirm it.

correo_invalido

That email doesn’t look valid. When revoking access, passing "todos" also returns this error: use revocar-todos for that.

demasiados_destinatarios

More than 5 people in a single call. Split them across several calls, or share from the dashboard.

demasiados_dominios

People from more than 2 different companies in a single call. Make one call per company.

correo_requerido_en_estricta

The document uses Verified Access and that person has no email: without one, we can’t send them their code.

sin_datos

That person has no name, email, or WhatsApp number, or the recipient isn’t a JSON object.

telefono_invalido

That WhatsApp number doesn’t match its country, or pais isn’t a two-letter country code. Send the full number with + and the country code (+1 512…, +52 55…), or the national number with pais ("US", "MX"…). Without pais, the country comes from your account’s language.

documento_archivado

The document is archived and that action doesn’t apply. Restore it from the dashboard.

documento_no_encontrado

That document doesn’t exist, belongs to another account, or is archived and the action doesn’t apply to archived documents. The response is identical in all three cases, on purpose.

destinatario_no_encontrado

That person isn’t one of the document’s recipients.

limite_ritmo

You hit a limit; limite says which one, and Retry-After says when to retry. See Limits.

organizacion_suspendida

The account is suspended. Contact us.

entrada_invalida

A field is missing or isn’t in the expected format; campo says which one. You also get this if the body isn’t valid JSON.

no_autenticado

The key is missing, copied wrong, revoked, or expired. The response is the same in every case and doesn’t say which.

permiso_insuficiente

The key doesn’t have the permission that route needs; the WWW-Authenticate header says which one is missing. Create another key with that permission.

ruta_no_encontrada

That route or method doesn’t exist. All routes are under /v1.

error_interno

Something failed on our end, and it’s already been logged. Retry in a moment; if it keeps happening, contact us and include the time it happened.

tipo_no_soportado

That Content-Type isn’t accepted on that route. Publish and replace accept text/html, multipart/form-data, or application/json; share and revoke, application/json.

cuerpo_demasiado_grande

The body is over 512 KB on a route that doesn’t take documents.

solicitud_en_curso

That same request is still being processed. Wait a few seconds and retry: you’ll get the result of the first one.

clave_idempotencia_reusada

That Idempotency-Key was already used with a different request. Use a new key for each different operation.

pago_requerido

The account’s plan payment needs attention: you can still view, archive and revoke, but not publish or share with someone new. Existing links stay open. The Account Holder fixes it under Billing; the link comes in facturacion_url (inside detalle over MCP) and in the mensaje too.

Something not adding up? Message us on WhatsApp.

Next guide Connect Cartaventa to Claude →

Something missing from this guide? Message us on WhatsApp and we’ll fix it. You can also read it in Markdown, ready to paste into your AI, at /en/docs/api.md.