Pular para o conteúdo

Guia de integração para agentes

Esta página foi escrita para agentes autônomos (e para os engenheiros que os configuram). Ela descreve o contrato sem nenhuma ambiguidade, para que um modelo chame a API corretamente na primeira tentativa. Tudo o que um agente precisa também está disponível em arquivos legíveis por máquina:

  • /llms.txt — o contrato completo, curado, em um único arquivo de texto puro. Baixe este arquivo e você já consegue publicar.
  • /llms-full.txt — o llms.txt mais o guia de fluxo do agente e a tabela de erros, num arquivo só (para colar inteiro no contexto).
  • /specs/content-openapi.yaml — o contrato OpenAPI 3.1 da API pública, com URL estável (também auth, forms e tenancy em /specs/<id>-openapi.yaml).
  • https://api.canverly.com/openapi.json — schema OpenAPI servido pela própria API, para tool/function calling.
  • Endpoint: POST https://api.canverly.com/v1/posts
  • Cabeçalhos: Authorization: Bearer <CANVERLY_API_KEY>, Content-Type: application/json
  • Corpo (mínimo): { "title": string, "blocks_json": { "v": 1, "blocks": Block[] }, "status": "published" }
  • Block: { "id": string, "type": string, "text"?: string, "attrs"?: object }. Os tipos que renderizam: paragraph, heading, list, quote, code, callout, image, gallery, video, embed, table, columns, divider, html, related_posts, product_card e ad. Um type desconhecido é gravado sem erro e não aparece. Campos, exemplos e limites de cada um em Blocos de conteúdo; o cartão de produto em Cartão de produto.
  • Sucesso: 201 → { "id", "slug", "status", "public_url" }
  • O site é fixado pela chave. Nunca coloque site_id em lugar nenhum; você não consegue apontar para outro site.

Um artigo só vai ao ar com nota de SEO igual ou acima do mínimo. O fluxo que não desperdiça chamadas:

  1. Meça sem salvar: POST /v1/posts/seo/analyze com o mesmo corpo do create (escopo seo:read). Leia score, minimum_to_publish, missing e suggestions[] (já ordenadas por ganho de pontos por esforço).
  2. Corrija e meça de novo até score >= minimum_to_publish. Leia o mínimo da resposta; não o fixe no código. Os campos editorial (resumo executivo, pontos-chave, fatos, FAQ, fontes) contam para a nota.
  3. Crie e publique: POST /v1/posts com status: "published" e um Idempotency-Key estável. Mande o mesmo focus_keyword ({"primary": "…", "secondary": ["…"]}) no analyze e no create: sem foco a nota perde 10 pontos. Se a resposta trouxer warnings: ["SEO_FOCUS_NOT_SAVED"], o post foi salvo mas o foco não: reenvie-o com PATCH.
  4. Se vier 422 SEO_SCORE_BELOW_MINIMUM: o create já criou um rascunho, e error.post_id o identifica. Não chame o create de novo. Corrija com PATCH /v1/posts/{post_id}, confirme com GET /v1/posts/{post_id}/seo/score e publique com POST /v1/posts/{post_id}/publish.
  5. Se vier 503 (SEO_SCORE_UNVERIFIABLE ao publicar, SEO_SCORE_UNAVAILABLE ao medir): nada foi publicado. Espere Retry-After segundos e repita a mesma chamada.
  6. Se vier 429: espere Retry-After e repita.
  7. Verifique: GET https://<primary_domain>/<slug> devolve 200.
import time, requests
API = "https://api.canverly.com"
KEY = "ck_live_xxx" # segredo vem de variável de ambiente/secret, nunca do código
def chamar(metodo, caminho, extra_headers=None, **kw):
"""Repete em 429/503 respeitando Retry-After (máx. 3 tentativas)."""
headers = {"Authorization": f"Bearer {KEY}", **(extra_headers or {})}
for tentativa in range(4):
r = requests.request(metodo, API + caminho, headers=headers, timeout=30, **kw)
if r.status_code in (429, 503) and tentativa < 3:
time.sleep(int(r.headers.get("Retry-After", 30)))
continue
return r
return r
artigo = {"title": "…", "blocks_json": {"v": 1, "blocks": [...]}}
nota = chamar("POST", "/v1/posts/seo/analyze", json=artigo).json()
# aplique nota["suggestions"] ao artigo até nota["score"] >= nota["minimum_to_publish"]
r = chamar("POST", "/v1/posts", json={**artigo, "status": "published"},
extra_headers={"Idempotency-Key": "item-42"})
if r.status_code == 422 and r.json()["error"]["code"] == "SEO_SCORE_BELOW_MINIMUM":
post_id = r.json()["error"]["post_id"] # o rascunho já existe
# chamar("PATCH", f"/v1/posts/{post_id}", json={...})
r = chamar("POST", f"/v1/posts/{post_id}/publish")
r.raise_for_status()

Detalhes de cada rota: Nota de SEO e publicação.

Publicar é o caso mais comum, mas a API não serve só para publicar. Todas as rotas abaixo são acessíveis com a mesma chave bearer, sujeitas aos escopos dessa chave.

Objetivo Chamada Escopo
Medir a nota de SEO de um rascunho (não salva) POST /v1/posts/seo/analyze seo:read
Medir a nota de um post salvo GET /v1/posts/{reference}/seo/score seo:read
Publicar um artigo POST /v1/posts posts:write
Publicar ou agendar um rascunho existente POST /v1/posts/{reference}/publish posts:write
Tirar um post do ar (vira archived) POST /v1/posts/{reference}/unpublish posts:write
Ler a fonte editável (blocos como armazenados) GET /v1/posts/{reference}/source posts:write
Corrigir um post ou mudar a data (id ou slug, rascunho incluído) PATCH /v1/posts/{reference} posts:write
Ler o que já está publicado GET /v1/posts (keyset, ?since= para sincronização incremental) posts:read
Ler um artigo com o corpo GET /v1/posts/{reference} (id ou slug) posts:read
Evitar duplicar um artigo existente GET /v1/posts?q=<title> antes de escrever posts:read
Definir title/description/canonical/no_index PATCH /v1/posts/{reference}/seo seo:write
Enviar uma imagem para usar em um post POST /v1/media (multipart, campo file) media:write
Verificar quais tipos de post existem GET /v1/post-types post_types:read
Resolver o domínio público e o nicho do site GET /v1/sites/me (editorial: vertical, label) sites:read
Ler o briefing editorial do site (público, tom, fontes, temas proibidos) GET /v1/sites/me/briefing sites:read
Gravar o briefing (humano ou operador, não o agente de redação) PUT /v1/sites/me/briefing site:write
Ler o plano de conteúdo e o brief de uma palavra-chave (opt-in, desligado por padrão: 404 PLAN_NOT_AVAILABLE) GET /v1/plan, GET /v1/plan/keywords/{id}/brief plan:read
Vincular ou soltar o post de uma palavra-chave do plano PATCH /v1/plan/keywords/{id} plan:write
Ver quais posts melhorar primeiro (nota guardada, ganho fácil) GET /v1/seo/backlog?order=easiest seo:read
Ler números de tráfego GET /v1/analytics/summary analytics:read
Carregar muitos posts de uma vez POST /v1/import (NDJSON) import + posts:write
Extrair o acervo GET /v1/export?resource=posts (NDJSON) export

Parâmetros e respostas completos: a referência da API.

Passe isto ao seu agente literalmente (forneça a chave por uma tool/secret, nunca escrita diretamente no prompt):

You can publish articles to a Canverly site through its public API.
ENDPOINT: POST https://api.canverly.com/v1/posts
HEADERS: Authorization: Bearer ${CANVERLY_API_KEY}
Content-Type: application/json
BODY (JSON):
- title (string, required)
- status (string): "published" to go live, "draft" to stage. Default "draft".
- blocks_json (object, required): { "v": 1, "blocks": [ ...blocks ] }
- slug (string, optional): omit to auto-generate; for retries send a STABLE slug.
- excerpt (string, optional): one-sentence summary.
- language (string, optional): BCP-47, e.g. "en" or "pt-BR".
- category_slugs (string[], optional), tag_slugs (string[], optional).
- focus_keyword (object, optional): {"primary": string, "secondary": string[<=5]}.
Send the SAME one to analyze and to create; without it the score loses 10 points.
If the 201 carries warnings ["SEO_FOCUS_NOT_SAVED"], resend it with PATCH.
BLOCK SHAPES (each needs a unique "id"):
- { "id":"p1", "type":"paragraph", "text":"inline HTML allowed (<a>,<strong>,<em>,<code>)" }
- { "id":"h1", "type":"heading", "attrs":{"level":2}, "text":"Heading" }
- { "id":"l1", "type":"list", "attrs":{"style":"unordered"}, "text":"item one\nitem two" }
- { "id":"c1", "type":"code", "attrs":{"language":"python"}, "text":"print('hi')" }
- { "id":"q1", "type":"quote", "text":"A quote." }
- { "id":"co1", "type":"callout", "attrs":{"variant":"info|warning|success|danger","title":"Optional"}, "text":"Highlighted note." }
- { "id":"t1", "type":"table", "attrs":{"headers":["A","B"],"rows":[["1","2"]]} }
- { "id":"pc1", "type":"product_card", "attrs":{"product_id":"<id of a product registered in the site panel>"} }
(the card needs a registered product; unknown/unresolved ids render nothing and raise no error;
never put a heading right before it; details: https://developers.canverly.com/apis/content/blocks/product-card/)
- Other types that render: image, gallery, video, embed, columns, divider, html, related_posts, ad.
Unknown "type" values are stored without error and are NOT rendered. Full list: https://developers.canverly.com/apis/content/blocks/
RULES:
- Body content is blocks_json, NOT raw HTML and NOT markdown.
- Do NOT send site_id/org_id/author_id; the key fixes the site.
- <script>, event handlers and javascript: URLs are stripped; do not rely on them.
- For safe retries, send header "Idempotency-Key: <stable id>" (e.g. the source
item id). A replay with the same key+body returns the original 201 (no duplicate).
- On 429, read Retry-After and wait that many seconds, then retry.
- On 201, the response has "slug"; the post is live at https://<site-domain>/<slug>.
PUBLISHING FLOW (articles must reach a minimum SEO score to go live):
1. POST /v1/posts/seo/analyze with the same body (scope seo:read). Saves nothing.
Read score, minimum_to_publish, missing and suggestions[] (best gain per effort first).
2. Apply the suggestions, re-run analyze until score >= minimum_to_publish.
Read minimum_to_publish from the response; never hardcode it.
3. POST /v1/posts with status "published" (and an Idempotency-Key).
4. If 422 SEO_SCORE_BELOW_MINIMUM: a DRAFT was already created, error.post_id names it.
Do NOT call create again. PATCH /v1/posts/{post_id} to fix it, check
GET /v1/posts/{post_id}/seo/score, then POST /v1/posts/{post_id}/publish.
5. If 503 SEO_SCORE_UNVERIFIABLE: nothing was published. Wait Retry-After seconds
(30 if absent) and retry the same call. Same for 503 SEO_SCORE_UNAVAILABLE on analyze/score.
6. 409 NOT_PUBLISHABLE on publish = the post is already live (or archived): stop, do not retry.
- Optional fields that count toward the score: "editorial" {executive_summary,
key_points[], key_facts[{claim,source}], faq[{question,answer}], sources[{title,url}]}.
- status "scheduled" needs published_at in the future (RFC3339), else 422 INVALID_SCHEDULE.
- category_slugs must be categories the site already has, else 400 UNKNOWN_CATEGORY.
OPTIONAL DISCOVERY (each needs its own scope on the key):
- GET /v1/post-types -> valid post_type slugs (default "post").
- GET /v1/sites/me -> { id, slug, primary_domain, default_language }.
- GET /v1/posts?q=... -> check whether you already published this; the response
is { "items": [...], "next_cursor": string|null }. Absent/null cursor = end.
- GET /v1/posts?since=<RFC3339> -> only what changed since your last run.
EDITING AN EXISTING POST:
- PATCH /v1/posts/{reference} (id or slug, drafts included) with only the fields to
change: title, blocks_json, excerpt, category_slugs, tag_slugs, published_at,
editorial, featured_image_id, focus_keyword. There is no status or slug field: publish
a draft with POST /v1/posts/{reference}/publish; you cannot rename a URL, and the API
creates no 301 redirect (a human makes it in the admin).
- A PATCH on a PUBLISHED post goes live immediately and skips the SEO gate. Never assume
it is safe. To REWRITE an existing article: read GET /v1/posts/{reference}/source (never
rebuild from content_html), read GET /v1/sites/me and GET /v1/sites/me/briefing first,
keep the original for rollback, write the new version as a draft or wait for human
approval, measure with analyze (minimum from the response), keep slug and URL.
- excerpt/category_slugs/tag_slugs are MERGED into the post's SEO object, not replaced.
- Do NOT send published_at unless the date is genuinely wrong; it re-pings
IndexNow on every call.
SEO:
- GET /v1/posts/{reference}/seo, then PATCH only the keys you want to change.
The PATCH MERGES: omitted keys are kept; send "" or [] to clear a key.
  1. (opcional) Resolva o site — GET /v1/sites/me → guarde em cache primary_domain e default_language.
  2. (opcional) Verifique os tipos de post — GET /v1/post-types → confirme que o slug do seu post_type existe (padrão post).
  3. (opcional) Verifique se há duplicata — GET /v1/posts?q=<title> → se já existir uma correspondência próxima, aplique um patch nela em vez de publicar um segundo post.
  4. Meça — POST /v1/posts/seo/analyze com o mesmo corpo até score >= minimum_to_publish (veja o fluxo do agente).
  5. Publique — POST /v1/posts com o corpo acima. Espere 201. Em 422 SEO_SCORE_BELOW_MINIMUM, corrija o rascunho de error.post_id e use POST /v1/posts/{post_id}/publish.
  6. (opcional) Defina o SEO — PATCH /v1/posts/{reference}/seo só com as chaves a mudar (ele mescla).
  7. Verifique — GET https://<primary_domain>/<slug> retorna 200, ou leia o post de novo por GET /v1/posts/{id}.
{
"title": "Example",
"status": "published",
"blocks_json": { "v": 1, "blocks": [
{ "id": "p1", "type": "paragraph", "text": "Body text." }
] }
}

Schema de função/tool (para modelos com tool calling)

Seção intitulada “Schema de função/tool (para modelos com tool calling)”
{
"name": "canverly_publish_post",
"description": "Create and optionally publish a post on the Canverly site bound to the API key.",
"parameters": {
"type": "object",
"required": ["title", "blocks_json"],
"properties": {
"title": { "type": "string" },
"status": { "type": "string", "enum": ["draft", "published", "scheduled"], "default": "draft" },
"published_at": { "type": "string", "format": "date-time" },
"editorial": { "type": "object" },
"slug": { "type": "string" },
"excerpt": { "type": "string" },
"language": { "type": "string" },
"post_type": { "type": "string", "default": "post" },
"category_slugs": { "type": "array", "items": { "type": "string" } },
"tag_slugs": { "type": "array", "items": { "type": "string" } },
"blocks_json": {
"type": "object",
"required": ["v", "blocks"],
"properties": {
"v": { "type": "integer", "const": 1 },
"blocks": {
"type": "array",
"items": {
"type": "object",
"required": ["id", "type"],
"properties": {
"id": { "type": "string" },
"type": { "type": "string",
"enum": ["paragraph", "heading", "list", "code", "quote", "image"] },
"text": { "type": "string" },
"attrs": { "type": "object" }
}
}
}
}
}
}
}
}
Status Significado Ação do agente
401 Chave inválida/ausente Pare; mostre uma mensagem de “needs valid API key”.
403 Escopo ausente Pare; a chave precisa de posts:write.
400 / 422 Payload inválido (título vazio, blocks_json ausente, tipos errados, UNKNOWN_CATEGORY, INVALID_SCHEDULE, INVALID_EDITORIAL) Corrija o campo que o erro nomeia e tente de novo uma vez.
422 SEO_SCORE_BELOW_MINIMUM Nota de SEO abaixo do mínimo; o rascunho foi criado (error.post_id) Aplique error.suggestions no rascunho (PATCH), meça e use POST …/publish. Não recrie.
409 NOT_PUBLISHABLE O post já está publicado ou arquivado Pare; não repita.
503 SEO_SCORE_UNVERIFIABLE / SEO_SCORE_UNAVAILABLE A nota não pôde ser verificada/calculada agora; nada foi publicado Espere Retry-After segundos e repita a mesma chamada.
429 Limite de requisição atingido Aguarde Retry-After segundos e tente de novo.
404 O post/asset não está neste site (ou não existe — os dois casos são indistinguíveis) Pare; não enumere ids procurando um que funcione.
5xx Transitório Backoff exponencial (ex.: 1s, 2s, 4s), no máximo ~3 tentativas. Reutilize a mesma Idempotency-Key.

Os limites de requisição variam por rota: 60 req/min para escritas, 600 req/min para as rotas públicas de leitura, 10 req/min para leads. Um agente que lê muito e escreve pouco vai esbarrar primeiro no limite de escrita.

Veja Erros e limites de requisição para a tabela completa.