Connect Canverly
“Connect Canverly” is the “one click” for an app to work on a person’s sites. The person clicks, chooses which company (or which sites) they are releasing and what the app may do. The app receives a token and calls the API, with nobody generating or pasting an API key.
It uses the same authorization server as Sign in with Canverly. Read that guide first: app registration, PKCE, state/nonce and id_token validation apply here unchanged. This guide only adds what differs.
What changes compared to sign-in
Section titled “What changes compared to sign-in”- The request includes API scopes (and
offline_access) and theresourceparameter. - The consent screen is always shown for “Connect”, and the person chooses the company and sites.
- The
/oauth/tokenresponse carries an opaqueaccess_tokenfor the API, arefresh_tokenand thecanverlyblock with what was released. - The permission that counts is the person’s current one, not the one on the consent day.
Scopes
Section titled “Scopes”Names are the API’s, with no translation. The full catalog, with risk, partner rule and consent screen text, is in App scopes: 38 fine scopes (for example posts:create, posts:publish, briefing:write) and the legacy packages (posts:write, export and others), which expand into fine scopes. Request only what the app uses.
- Fine scopes only exist on
.net, behindOAUTH_ESCOPOS_V2_ENABLED. With the flag off the API requires the literal v1 scope: a fine scope alone answers 403. No endpoint reports whether a ring has the flag; see API v2 for how to probe. - An API key
ck_never receives a fine scope. They reach the app through an OAuth grant (cvt_). - High-risk scopes (nine in the catalog:
site:settings:write,sites:create,posts:publish,posts:delete,seo:site:write,leads:read,export:posts,export:leadsandimport:posts) only enter an app registration by a recorded decision of the Canverly team, with a justification. sites:createrequires the person to own the company and creates at most 5 sites per grant; see Create sites.
The consent screen always appears on “Connect”. If the app becomes able to request a new scope, the person approves it by reopening the flow (see Updating permissions).
Restriction by content type (post_types)
Section titled “Restriction by content type (post_types)”Consent may restrict the grant to content types: up to 20 slugs (a-z, 0-9, _ and -, at most 64 characters, starting with a letter or digit), unique. An empty list means all types. Auth stores the list and returns it when the token is resolved (post_types); changing a grant’s restriction emits grant.updated. An invalid list in the consent decision answers 422 UNPROCESSABLE. The restriction only exists behind OAUTH_RESTRICAO_POST_TYPES_ENABLED (off by default: the grant is unrestricted and the resolve response does not send post_types).
With OAUTH_RESTRICAO_POST_TYPES_ENABLED on in auth, the API enforces the restriction:
- Creating or importing with a type outside the list answers
403 insufficient_scope(scope `posts:create` not granted for this content type). PATCH,DELETE, publish, unpublish,source,seo,score, revisions,restore, pending,promoteand per-post analytics for a forbidden type answer404, identical to that of a nonexistent post.- Listings intersect
?post_type=with the restriction (a request outside the list returns an empty list);/v1/post-typesshows only the allowed types;batch-readtreats a forbidden item as nonexistent. /v1/exportand/v1/seo/backlog*(refresh included) answer403with the messagecontent typeto a restricted grant.- An empty list means all types.
ck_andpk_keys have no restriction. - Not covered:
/v1/posts/seo/analyze, the aggregate/v1/analytics/postsand the planner’s keyword x post link.
Request the restriction in authorize (post_types)
Section titled “Request the restriction in authorize (post_types)”The app can propose the restriction in the request itself, with the post_types parameter of /oauth/authorize:
GET /oauth/authorize?...&scope=openid%20offline_access%20posts:read%20posts:create&post_types=post%20glossario- Format: space-separated slugs, the same format as
scope; each with the restriction format above. Repeated slugs are merged. More than 20 slugs or an invalid slug gives theinvalid_requesterror (invalid post_types). Validation runs with or without the flag. - The parameter is only kept when the request has a “Connect” scope (an API scope or
offline_access). On a login-only request it is ignored. - With
OAUTH_RESTRICAO_POST_TYPES_ENABLEDon, the consent screen receives the list (post_typesin the ticket detail). The person can narrow the list (tick a subset) but never widen it: a type outside the app’s request is 422. If the decision arrives with no types, the app’s list applies. If the app proposed nothing, the person freely chooses the types (empty list = all). - With the flag off the parameter is validated and ignored: the grant has no restriction.
- When reauthorizing an existing grant with the flag on, the restriction becomes the one from this decision, and an empty list means all types. To keep the restriction, send
post_typesagain in the request.
Updating permissions
Section titled “Updating permissions”When Canverly widens what your app may request (the registration’s allowed_scopes), existing grants gain nothing by themselves: a grant only changes when the person approves again. The flow, as the code implements it:
- Canverly knows what is missing. The grants listing that feeds the panel carries, per grant,
escopos_efetivos(what the grant actually grants, with the legacy package already expanded and a label, risk and group for each scope),escopos_pendentes(the API scopes the app can request today that the grant does not cover) andapp.site_url. WithOAUTH_RESTRICAO_POST_TYPES_ENABLEDit also carriespost_types. The comparison is against what the app may request, not what it requested: someone who unticked a scope on the screen still sees it as pending while the app can request it. - The panel warns the person. In “Connected apps”, the grant card shows “The app can ask for permissions this access does not have”, the list of what is missing and the Update permissions action. The action grants nothing: it is an https link to the app’s
site_url, opened in another tab. Without an httpssite_url, the panel shows the instruction “Open the app and use Connect again”. In the company list (owners) only the notice appears, saying that whoever connected must update. - The app restarts “Connect”. Canverly has no route that reauthorizes on its own:
/oauth/authorizecan only be started by the app, because PKCE,stateandnoncelive in it. So your app must expose an https URL, registered assite_url, that starts “Connect” when opened, with the new scopes. Ask for the full set the app uses, not only the new ones, and repeatpost_typesif you use the restriction. - The person approves. The consent screen appears (on “Connect” it is always shown). On approval, the existing grant (person, app, company) is widened: same
grant_idand live tokens keep working, but sites, scopes (andpost_types, with the flag) become those of this decision.grant.updatedis only sent to the webhook if sites or scopes really changed.
site_url is the “site address” of the app registration: absolute https URL, no username and password, no fragment, up to 2048 characters. If it is not the page that starts “Connect”, ask the Canverly team to adjust it.
The request
Section titled “The request”GET /oauth/authorize ?response_type=code &client_id=YOUR_CLIENT_ID &redirect_uri=https%3A%2F%2Fyourapp.example%2Fauth%2Fcanverly%2Fcallback &scope=openid%20profile%20email%20offline_access%20sites:read%20posts:read%20posts:write &resource=https%3A%2F%2Fapi.canverly.net &state=...&nonce=... &code_challenge=...&code_challenge_method=S256resource (RFC 8707) is the API address of the same environment as the authorization server (https://api.canverly.net in test), identical as text, with no trailing slash and no normalization. Discovery does not publish it: configure it next to the issuer. If omitted, the server assumes the environment’s API; any other value returns invalid_target. A token requested for one resource only works there.
The screen shows, in plain language, who the app is (logo, name, responsible company, “Group” or “Partner”), what it will do (one line per scope, risk highlighted), which company (preselected if the person has only one) and which sites. Rules your app needs to know:
- The person can only release what they themselves can do on that site. A scope with no possible resource shows disabled.
- Releasing the whole company, including future sites, requires the company
ownerrole. Administrators release specific sites only. - Each person has one grant per app and per company. To connect another company, repeat the flow and pick the other one on the screen.
- Connecting triggers a notice email to the person (and to the company owners when the scope writes, the app is a partner’s, or the whole company was released). The app cannot configure this.
The response
Section titled “The response”{ "token_type": "Bearer", "access_token": "cvt_...", "expires_in": 900, "refresh_token": "cvr_...", "scope": "openid profile email offline_access sites:read posts:read posts:write", "id_token": "eyJ...", "canverly": { "grant_id": "01J...", "org": { "id": "...", "nome": "My Company" }, "sites": [{ "id": "...", "nome": "My Blog" }] }}sitesis a list, or the text"todos"when the whole company was released. The person decides the scope, on the consent screen: one site, several or all (including future ones,owneronly). The app does not choose or request a scope: read thecanverlyblock of/oauth/tokento see what was granted and treat"todos"as “any current or future site of the company”.- The
access_tokenis opaque (cvt_plus 32 random bytes): do not try to read or decode it. It lives 15 minutes. Keepgrant_idyourself: it is the key of the link in your app. - The
refresh_token(cvr_) only comes withoffline_access.
Calling the API
Section titled “Calling the API”curl -s https://api.canverly.net/v1/sites/me \ -H "Authorization: Bearer $ACCESS_TOKEN"The token goes always in the Authorization header. Passing it in the query string is refused. The token is for server-to-server calls: the API returns no CORS headers for it, so a browser cannot use it (on purpose).
Paths and bodies are those of the API reference. The only change is the credential: where a site API key already fixed the site, the OAuth token reaches the grant’s sites, and the API proves the site on every call.
Which site a call reaches
Section titled “Which site a call reaches”- Grant with ONE site:
GET /v1/sites/mereturns that site (same body as a site key). This holds for any route without{site}(for exampleGET /v1/posts), not only/v1/sites/me. - Grant with several sites, or “todos”:
/v1/sites/meanswers 400SITE_AMBIGUO. Use the twin routes/v1/sites/{site}/…(for exampleGET /v1/sites/{site}) with asite.idfrom thecanverly.sitesblock of the token response. A site outside the grant answers 404, the same as a site that does not exist.
Deleting and publishing
Section titled “Deleting and publishing”- Delete:
DELETE /v1/sites/{site}/posts/{reference}(scopeposts:delete; in v1,posts:write) sends the post to the trash and answers 204 with no body. It is not a permanent deletion: the person restores it from the panel for 30 days and an operator for 180. The audit log records the app acting on behalf of the person. A post that does not exist, belongs to another site or is already in the trash answers 404. - Publish:
POST /v1/sites/{site}/posts/{reference}/publishreturns, besidesid,slugandstatus, thepublic_urlfield: the article’s public address, the same one the site serves. It isnullwhen the article was only scheduled (not live yet) or if the URL could not be read at that moment; the publication itself succeeded in that case.
Who is the author
Section titled “Who is the author”Articles created with the token have the person who connected as author (not the app). The audit log also records which app made the call. This does not change the post contract.
Two rings: .com and .net
Section titled “Two rings: .com and .net”Canverly runs two independent environments, canverly.com (production) and canverly.net (test), each with its own authorization server, users and sub. The same human’s pairwise sub is different in each (and between partner apps). Therefore:
- the account key in your app is the pair
(iss, sub), neversubalone; - store
isswith each link and use the discovery andresourceof the same ring; - there is no
.com.brring for the authorization server: customer sites may have their own domains, butauthandapionly exist on.comand.net. Never merge accounts across rings.
Effective permission
Section titled “Effective permission”The scopes of a call are the intersection of three things: what the person released (grant.scopes), what the app is allowed to request, and what the person can do today on that site. If any is empty, the call fails. A grant never widens what the person can do.
In practice, the token stops working with no new login when the person leaves the company, is demoted, is suspended, or the site is archived. See the handling below.
Renewing: rotating refresh
Section titled “Renewing: rotating refresh”When the API answers 401 with WWW-Authenticate: Bearer error="invalid_token", the token expired. Renew:
curl -s https://auth.canverly.net/oauth/token \ -u "$CANVERLY_CLIENT_ID:$CANVERLY_CLIENT_SECRET" \ -d grant_type=refresh_token \ -d refresh_token="$REFRESH_TOKEN"- Each refresh returns a new refresh token and invalidates the previous one. Store the new one before using the
access_token. - Idle for 30 days, the refresh token expires. As a rule there is also a 90-day cap from the connection, after which the person must connect again.
- Exception,
sem_teto_absoluto: in agrupoapp with this flag on, every refresh renews the 30-day window and the 90-day cap does not exist; only 30 days of idleness expire the refresh. Only the operator (operator_admin) switches the flag, per app, and only on agrupoapp (on a partner the registration answers 422APP_RULE_VIOLATION). It is off by default, so agrupoapp also has the 90-day cap. Rotation, the 10 s reuse window, revocation and live permission keep applying in both cases. - Two refresh calls with the same refresh token within 10 seconds return the same successor (useful for two tabs or two jobs). Reusing an already-used refresh token outside that window is treated as theft: the whole family and the grant are revoked, and the person and company owners are notified. So serialize refresh per grant in your app (a mutex per
grant_id) and never let two instances rotate the same token uncoordinated. - Refresh does not request new scope. To widen, redo the authorization flow.
Notice before expiry (grant.expiring)
Section titled “Notice before expiry (grant.expiring)”When a grant’s live refresh token will expire within 7 days, auth sends the grant.expiring webhook to the app’s events URL (see App events). The notice goes out once per cycle and carries reason: idle (30 days of idleness is about to run out) or ceiling (the 90-day cap, only on an app without sem_teto_absoluto).
- On
idle, using the refresh (rotation) beforeexpires_atrenews the window and reopens the notice cycle. - On
ceiling, rotation does not postpone the expiry: the cap is inherited by the following refreshes.
What to do on receiving it
Section titled “What to do on receiving it”The notice only reports the expiry; it renews nothing. On idle, one refresh before expires_at is enough. On ceiling, the only way is to redo “Connect” before the date. The step by step is in App events. Without the webhook enabled on the ring, the app keeps finding out about expiry through invalid_grant on refresh.
When it goes wrong
Section titled “When it goes wrong”| What the API or token endpoint returns | Meaning | What the app does |
|---|---|---|
401 + invalid_token |
Access token expired or revoked | Refresh once and repeat the call. If refresh fails with invalid_grant, mark the link as disconnected and ask the person to connect again. |
403 (ESCOPO_INSUFICIENTE) |
The grant or the person’s current permission does not cover the route | Do not insist. Show which permission is missing; for a new scope, redo authorization. |
404 on a site that existed |
Access to the site was lost, or it was archived | Remove the site from the person’s list. Do not tell “does not exist” from “not yours”: the 404 is uniform on purpose. |
429 + Retry-After |
Over quota | Wait the indicated time. The quota is per grant (60 per minute for writes, 600 for reads) and there is a bucket per app (6000). See Rate limits. |
503 (OAUTH_INDISPONIVEL) |
The authorization server did not answer | Retry soon (with growing backoff). API keys keep working; only the OAuth bearer depends on auth. |
invalid_client on refresh |
App disabled or secret changed | Stop retrying; tell the app owner. |
Access lost to every resource in the grant: the grant stays listed as active in the person’s panel (with a warning) until they or the owner revoke it, and a daily job revokes it when nothing is reachable anymore. Your app sees this as repeated 404/403 and as refresh failing after the revocation.
Login session vs publishing connection
Section titled “Login session vs publishing connection”These are two separate things with separate lifecycles:
- Login session: the person’s Canverly session (the one behind “Sign in with Canverly”). It ends on logout, on “sign out of all devices”, on password change or recovery, and on reuse of a session refresh token. When it ends, Canverly fires the back-channel logout to the apps that received an
id_tokenin that session. - Publishing connection: the Connect Canverly grant, with its own
cvr_refresh token. This is the delegated access your app uses to read and publish.
Signing out of Canverly does not drop publishing. Logout, “sign out of all devices”, password change and session refresh reuse revoke only login sessions. The grant, the cvr_ and the cvt_ stay valid, so a job in your app that publishes overnight keeps working after the person signed out. If your app uses both features, receiving a logout_token ends your app’s session, not the connection: do not delete Connect tokens because of it.
What ends the connection
Section titled “What ends the connection”| Cause | Signal the app receives |
|---|---|
| The person revokes under “Connected apps” | grant.revoked webhook with motivo: "usuario"; then 401 invalid_token on the API and invalid_grant on refresh. |
| The company owner revokes | grant.revoked with motivo: "dono_da_empresa"; then 401/invalid_grant. |
| The Canverly operator revokes | grant.revoked with motivo: "operador"; then 401/invalid_grant. |
Your app calls POST /oauth/revoke |
No webhook for your own app (you already know). The API returns 401 and refresh returns invalid_grant. |
Reuse of a cvr_ refresh token outside the 10 s window |
Revokes the family and the grant: grant.revoked with motivo: "refresh_reuso"; refresh returns invalid_grant. |
| The person loses access or closes the account (daily job) | grant.revoked with motivo: "perdeu_acesso" or "conta_encerrada"; before that, repeated 403/404; after, 401/invalid_grant. |
90-day cap since connecting (except a grupo app with sem_teto_absoluto) or 30 days unused |
Before that: grant.expiring webhook (7 days). The refresh token expires: invalid_grant on refresh and 401 invalid_token once the access token lapses. The person connects again. |
The webhook only exists where the environment already offers it (see availability). Without it, treat 401 invalid_token followed by invalid_grant on refresh as the signal that the connection is over, mark the link as disconnected and ask for a new connection. Canverly logout is deliberately not on this list.
Revoking
Section titled “Revoking”Anyone can revoke, and the effect reaches the API within 10 seconds (the cache limit):
-
the person, under “Connected apps” in their account;
-
the company owner, under “Connected apps” in the company settings;
-
the Canverly operator;
-
your app, with
POST /oauth/revoke(RFC 7009), authenticated as the client:Janela do terminal curl -s https://auth.canverly.net/oauth/revoke \-u "$CANVERLY_CLIENT_ID:$CANVERLY_CLIENT_SECRET" \-d token="$REFRESH_TOKEN" -d token_type_hint=refresh_tokenRevoking a refresh token drops the whole family and the grant. The response is always
200, even for a token that no longer exists. Offer “Disconnect Canverly” in your app and call this route.
If your app stores information tying the grant, delete it on disconnect.
Push notice by webhook
Section titled “Push notice by webhook”You do not need to wait for a 401 to learn about a revocation: the app can register an events URL and receive signed grant.revoked (and grant.updated, when sites or scopes change) right away. See App events (webhook). Available on .net; not yet on .com. Where the webhook does not exist, keep treating 401 invalid_token and invalid_grant on refresh as the revocation signal.
Availability
Section titled “Availability”| Feature | .net |
.com |
|---|---|---|
| Sign in with Canverly | live | not yet |
Connect Canverly (cvt_ token, refresh) |
live | not yet |
| Webhook notice | rolling out | not yet |
Federated logout (back-channel and end_session) |
rolling out | not yet |
Limit headers (RateLimit) |
rolling out | not yet |
Fine scopes (OAUTH_ESCOPOS_V2_ENABLED) |
rolling out | not yet |
| QA grant | rolling out | not yet |
Guided example: Chimpee rewriting articles
Section titled “Guided example: Chimpee rewriting articles”Chimpee is the first group app to use “Connect”. Scope set requested:
openid profile email offline_access sites:read post_types:read posts:read posts:write media:read media:write seo:read plan:read.
With fine scopes on, Chimpee requests the 28-scope fine set listed in App scopes.
Order of calls after the person connects:
- Exchange the
codeand storegrant_id,access_token,refresh_tokenandcanverly.sites. GET /v1/sites/me(grant with one site) orGET /v1/sites/{site}to confirm the site and read the site niche, when the environment already exposes it (today only on hml and.net), which guides the text.GET /v1/post-typesto learn the valid types.GET /v1/posts(andGET /v1/posts/{reference}/sourcefor the source text) to read the articles to rewrite.POST /v1/postsorPATCH /v1/posts/{reference}to write the new version, as a draft by default. The person, or an explicit action of yours, decides to publish (POST …/publishreturns thepublic_url).DELETE …/posts/{reference}sends a draft your app created to the trash.GET /v1/posts/{reference}/seo/scoreto measure before publishing (seo:read).- On
401, refresh (serialized pergrant_id) and repeat. On403/404, stop and show the reason.
Details of the Chimpee integration, including the API-key flow that exists today, are in the Chimpee guide.
Good practice
Section titled “Good practice”- Request the minimum scopes and explain on your own screen why each one is needed before sending the person to Canverly.
- Store tokens encrypted at rest, server-side only. Never in the browser, in logs or in events.
- Treat
cvt_andcvr_like passwords: a recognizable prefix helps secret-scanning tools. - Log
grant_id(not the token) and correlate with your app’strace_id. - Show the person what your app did on their behalf. Canverly’s panel shows the grant’s last use.
Ready-made examples
Section titled “Ready-made examples”- Node 22, zero dependencies:
/examples/canverly-oauth.mjs(includes per-grant serialized refresh) - Python 3.11:
/examples/canverly_oauth.py - Authorization endpoint contract (draft):
/rascunhos/oauth-apps-openapi.yaml