Campaigns
The post calendar and content-performance surface of dfl-campaigns — Bloco 3
of the revenue-engine-inbound-v1 plan. An agent writes a post into the queue.
A person clears it. The agent can then send the post and analyze its
results.
- Connector
https://mcp.devfellowship.com/mcp
- Tools
- 112 in 17 groups
- Package
packages/dfl-mcp-campaigns- Auth
- Sign in once on the DFL connector. Every call runs as you, under RLS and your IAM role. See Auth & security.
Connect
Add the one DFL connector, https://mcp.devfellowship.com/mcp, to your client. Sign in once. On the consent page
choose the campaigns domain: read gives the scope campaigns.read, and write gives
campaigns.write. The steps for each client are on
Connect the DFL MCP.
Then find a tool of this domain with the router tools of the connector:
-
search_toolswith a keyword or an exact tool name. Each result givescampaigns.<tool>and its mode (read or write).{ "query": "list_zernio_profiles" } -
describe_toolwith that id for the description and the input schema.{ "tool": "campaigns.list_zernio_profiles" } -
call_read_toolfor a read tool, orcall_write_toolfor a write tool, with the id and the arguments.
Scripts and agents that sign in with a token: see Getting started, For scripts.
| Backing data | Calendar writes use the dfl-campaigns Hono API. Analytics uses SECURITY INVOKER RPCs and bounded history reads with the caller’s JWT and RLS. The social account mapping reads and writes campaigns.social_accounts with the caller’s JWT and RLS. Experiments read and write work.hypotheses and read campaigns.analytics_daily_metrics and campaigns.analytics_targets with the caller’s JWT and RLS. |
Accounts & voice
Section titled “Accounts & voice”Read the Zernio profiles and connected accounts, the business units the calendar schedules for, and a business unit’s brand voice. Read these before you draft.
See who publishes where, which social accounts are connected, and how a brand should sound before you write a post.
list_zernio_profiles
Who publishes where: each Zernio profile (a person or the company) with its connected accounts per network, plus the accounts that belong to no profile.read
list_zernio_profilesList Zernio profiles and their accounts
Who publishes where: each Zernio profile (a person or the company) with its connected accounts per network, plus the accounts that belong to no profile. Call this FIRST when drafting a post: draft_post_for_review requires zernio_profile_id — the profile of the person or brand the post goes out as ("Criador" in the dfl-campaigns UI). A post is NOT limited to that profile's own accounts — the app allows channels across profiles (e.g. the brand DevFellowship plus a team member's personal accounts); the profile just names who the post is mainly for.
Takes no parameters.
list_zernio_accounts
The social accounts connected in Zernio, each with the id a channel needs to actually publish.read
list_zernio_accountsList connected Zernio accounts
The social accounts connected in Zernio, each with the id a channel needs to actually publish. Call this BEFORE draft_post_for_review whenever the post has channels: Zernio publishes per ACCOUNT, and there is more than one account on the same platform (a company profile and a personal one), so "instagram" alone does not say where the post goes out. A channel drafted without its zernio_account_id is dropped at dispatch, and the review queue cannot add the account afterwards — that post has to be redone.
Takes no parameters.
list_post_business_units
The business units the post calendar can schedule for — strategy.business_units, archived ones excluded.read
list_post_business_unitsList post calendar business units
The business units the post calendar can schedule for — strategy.business_units, archived ones excluded. Call this FIRST: every other tool takes a business_unit_id (a uuid), never a name like "itera".
Takes no parameters.
get_business_unit_voice
READ the brand VOICE of a business unit before you write any post copy — the writing patterns that say how that BU sounds.read
get_business_unit_voiceGet business unit voice
READ the brand VOICE of a business unit before you write any post copy — the writing patterns that say how that BU sounds. Source is strategy.writing_patterns, the single canonical store, read with your own JWT through the shared canonical reader in native sessions or strategy MCP list_writing_patterns in first-party sessions. Call it after list_post_business_units and BEFORE draft_post_for_review: a Reel written without it is written in a voice you guessed. Each row is one "slot" (e.g. "book", "youtube"); the free-form pattern jsonb carries description, toneAxes, vocabularyDo / vocabularyAvoid and examplePairs. Optionally narrow to one slot. This tool is READ-ONLY: authoring a voice happens in BM Canvas or on the strategy MCP.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | The BU whose voice to read (from list_post_business_units) |
slot | string | no | Narrow to a single voice slot, e.g. "book", "youtube", "pedagogia_aula". |
Suggested topics
Section titled “Suggested topics”The Curadoria board of content ideas (“pautas”). A person turns a topic into one or more posts.
The ideas board for posts: read what people said this week, and add, edit, move or archive topic suggestions.
list_suggested_topics
Read the suggested topics on the Curadoria board of /posts/pautas in dfl-campaigns.read
list_suggested_topicsList suggested topics (Curadoria board)
Read the suggested topics on the Curadoria board of /posts/pautas in dfl-campaigns. A suggested topic (a curated content topic, "pauta" in Portuguese) is an idea for content that a person or an agent put on the board and that later turns into one or many posts. Each topic has a title, briefing, status (idea, todo, awaiting_content, in_production, awaiting_approval, posted, standby), optional due_date, formats, channels, reference_links, business_unit_id, assignee_id and a url to its card. Active topics are returned by default; pass archived=true for the archived ones. Filters are applied after the read: status, assignee_id, business_unit_id, content_pillar_ext_id (null = the free pautas with no pillar), content_kind, primary_keyword_ext_id, planned, due_from and due_to (São Paulo dates YYYY-MM-DD, both inclusive; due_from = due_to = one day; a pauta with no due_date never matches a due filter). Each topic also carries its pillar name and keyword text when the strategy layer is live. The strategy layer: content_pillar_ext_id is a pillar of the business unit (the id from list_content_pillars on the strategy server), content_kind is hero (launch or big moment), hub (recurring series) or hygiene (keyword video), primary_keyword_ext_id is a keyword of the same business unit (from list_keywords), planned is true when the pauta comes from the pillar plan. The API checks that the pillar and the keyword exist and belong to the pauta business unit, and refuses the call otherwise (do not retry); a pillar or keyword needs business_unit_id. Read-only. Call it before create_suggested_topic so you do not add a duplicate. If the answer says the board is not live on this deployment, do not retry.
| Parameter | Type | Required | Description |
|---|---|---|---|
status | enum | no | Only topics in this column. One of: idea, todo, awaiting_content, in_production, awaiting_approval, posted, standby. |
assignee_id | string | no | Only topics assigned to this user. |
business_unit_id | string | no | Only topics of this BU (from list_post_business_units) |
content_pillar_ext_id | string | no | Only topics of this pillar (id from list_content_pillars); null = only the topics with no pillar. |
content_kind | enum | no | Only topics of this kind. One of: hero, hub, hygiene. |
primary_keyword_ext_id | string | no | Only topics with this primary keyword. |
planned | boolean | no | true = only the planned pautas; false = only the free ones. |
due_from | string | no | Only topics with due_date on or after this São Paulo date (YYYY-MM-DD); a topic with no due_date never matches. |
due_to | string | no | Only topics with due_date on or before this São Paulo date (YYYY-MM-DD); due_from = due_to reads one day. |
archived | boolean | no | true reads the archived topics instead of the active ones. Default: false. |
get_suggested_topic
Read-only. Resolve ONE pauta of the Curadoria board from ref: a full uuid (or the card link .../posts/pautas?pauta=<uuid>), an 8-hex prefix, or the handle that "Copiar handle" gives, P-<8hex> · <title> · <BU name>…read
get_suggested_topicGet one suggested topic (pauta) by id, prefix or handle
Read-only. Resolve ONE pauta of the Curadoria board from ref: a full uuid (or the card link .../posts/pautas?pauta=<uuid>), an 8-hex prefix, or the handle that "Copiar handle" gives, P-<8hex> · <title> · <BU name> (only the P-<8hex> part is used to find the row). Returns the pauta (title, briefing, status, due_date, reference_links), business_unit (id and name), the primary keyword (primary_keyword_ext_id and primary_keyword_text), the pillar, its posts (the posts whose post_suggested_topic_id is this pauta), handle and url. An ambiguous prefix is REFUSED: the answer lists the candidate ids, titles and BUs, and you call again with a longer prefix or the full id. A ref that matches no pauta you can see is refused too. Active pautas are searched first; archived ones only when no active pauta matches. Runs as the caller (RLS). Use it to turn a pasted handle into a pauta id before linking a Lesson Studio recording or drafting posts with suggested_topic_id.
| Parameter | Type | Required | Description |
|---|---|---|---|
ref | string | yes | A full uuid, an 8-hex prefix, or the handle P-<8hex> · <title> · <BU>. |
list_keyword_candidates
Read-only. For ONE business unit, the keywords of strategy.keywords that match the filters, each with its latest TubeBuddy score (and the date of that score), post_links (rows of campaigns.post_keywords: posts that use…read
list_keyword_candidatesKeyword candidates of a business unit, with score and usage
Read-only. For ONE business unit, the keywords of strategy.keywords that match the filters, each with its latest TubeBuddy score (and the date of that score), post_links (rows of campaigns.post_keywords: posts that use the keyword) and pauta_links (pautas, not archived, whose primary keyword is this id). A keyword is unused when post_links and pauta_links are both 0. Order: unused first, then score descending (no score last), then created_at ascending. Filters: category, cluster_name, locale, created_since (YYYY-MM-DD), min_score (a keyword with no TubeBuddy score never passes it), unused_only. limit defaults to 50 (max 500); total_matching says how many rows matched before the limit. Use it to pick the keyword of the next pauta; use list_keyword_coverage for the SEO page view instead. It writes nothing. Runs as the caller (RLS).
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
category | string | no | Only keywords with this category (for example general) |
cluster_name | string | no | Only keywords with this cluster_name. |
created_since | string | no | Only keywords created at or after this day (YYYY-MM-DD) |
locale | string | no | Only keywords of this locale (pt-BR, en, es) |
min_score | number | no | Only keywords whose latest TubeBuddy score is at least this. |
unused_only | boolean | no | true keeps only keywords with post_links 0 and pauta_links 0. Default: false. |
limit | number | no | Rows to return (default 50) Default: 50. |
create_suggested_topic
Add one suggested topic to the Curadoria board of /posts/pautas in dfl-campaigns.write
create_suggested_topicAdd a suggested topic to the Curadoria board
Add one suggested topic to the Curadoria board of /posts/pautas in dfl-campaigns. A suggested topic (a curated content topic, "pauta" in Portuguese) is an idea for content that a person or an agent proposes and that later turns into one or many posts. Creating one posts NOTHING and drafts no post: it only puts a card on the board, marked as created by an agent (origin "mcp"), for a person to pick up. To draft a post use draft_post_for_review. The status defaults to idea. Run list_suggested_topics first to avoid duplicates. The answer carries the card url. A refusal (not available on this deployment, a rule, a missing BU or user) says do not retry; only a temporary failure may be retried. The strategy layer: content_pillar_ext_id is a pillar of the business unit (the id from list_content_pillars on the strategy server), content_kind is hero (launch or big moment), hub (recurring series) or hygiene (keyword video), primary_keyword_ext_id is a keyword of the same business unit (from list_keywords), planned is true when the pauta comes from the pillar plan. The API checks that the pillar and the keyword exist and belong to the pauta business unit, and refuses the call otherwise (do not retry); a pillar or keyword needs business_unit_id.
| Parameter | Type | Required | Description |
|---|---|---|---|
title | string | yes | Short name of the topic, as it shows on the card. |
briefing | string | no | What the content is about and the angle (up to 5000 characters) |
status | enum | no | Board column; omitted means idea. One of: idea, todo, awaiting_content, in_production, awaiting_approval, posted, standby. |
due_date | string | no | Day the content is wanted, YYYY-MM-DD. |
formats | enum[] | no | Content formats. |
channels | enum[] | no | Networks the content is for. |
reference_links | string[] | no | http(s) links that inspired or back the topic. |
business_unit_id | string | no | Which BU the topic is for (from list_post_business_units) |
assignee_id | string | no | The user expected to produce it. |
content_pillar_ext_id | string | no | Pillar of the BU (id from list_content_pillars); needs business_unit_id. |
content_kind | enum | no | hero, hub or hygiene. One of: hero, hub, hygiene. |
primary_keyword_ext_id | string | no | Primary keyword of the BU (id from list_keywords); needs business_unit_id. |
planned | boolean | no | true = from the pillar plan; false (default) = a free pauta. |
idea_source_ids | string[] | no | Idea sources (from list_idea_sources) to link to the new pauta in the same call. |
update_suggested_topic
Edit the content of one suggested topic ("pauta") on the Curadoria board of /posts/pautas in dfl-campaigns: title, briefing, due date, formats, channels, reference links, BU or assignee.write
update_suggested_topicEdit a suggested topic on the Curadoria board
Edit the content of one suggested topic ("pauta") on the Curadoria board of /posts/pautas in dfl-campaigns: title, briefing, due date, formats, channels, reference links, BU or assignee. Any member can edit any topic. Send only the fields to change; an omitted field keeps its value, and null clears briefing, due_date, business_unit_id or assignee_id. Arrays (formats, channels, reference_links) replace the whole list. It does NOT change the column or the order: use move_suggested_topic for that, and archive_suggested_topic to archive. It refuses an empty change, an unknown field and an unknown id. Get the id from list_suggested_topics. A refusal says do not retry; only a temporary failure may be retried. null clears content_pillar_ext_id, content_kind and primary_keyword_ext_id. The strategy layer: content_pillar_ext_id is a pillar of the business unit (the id from list_content_pillars on the strategy server), content_kind is hero (launch or big moment), hub (recurring series) or hygiene (keyword video), primary_keyword_ext_id is a keyword of the same business unit (from list_keywords), planned is true when the pauta comes from the pillar plan. The API checks that the pillar and the keyword exist and belong to the pauta business unit, and refuses the call otherwise (do not retry); a pillar or keyword needs business_unit_id.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The suggested topic id (from list_suggested_topics) |
title | string | no | New title. |
briefing | string | no | New briefing; null clears it. |
due_date | string | no | Day the content is wanted, YYYY-MM-DD; null clears it. |
formats | enum[] | no | Replaces the formats. |
channels | enum[] | no | Replaces the channels. |
reference_links | string[] | no | Replaces the http(s) reference links. |
business_unit_id | string | no | BU from list_post_business_units; null clears it. |
assignee_id | string | no | The user expected to produce it; null clears it. |
content_pillar_ext_id | string | no | Pillar of the BU (id from list_content_pillars); null clears it. |
content_kind | enum | no | hero, hub or hygiene; null clears it. One of: hero, hub, hygiene. |
primary_keyword_ext_id | string | no | Primary keyword of the BU (id from list_keywords); null clears it. |
planned | boolean | no | true = from the pillar plan; false = a free pauta. |
move_suggested_topic
Move one suggested topic ("pauta") to a column of the Curadoria board of /posts/pautas in dfl-campaigns and, optionally, to a place inside it.write
move_suggested_topicMove a suggested topic to a column or position
Move one suggested topic ("pauta") to a column of the Curadoria board of /posts/pautas in dfl-campaigns and, optionally, to a place inside it. status is the target column (it may be the current one, to only reorder). Without before_id/after_id the card goes to the end of the column; with before_id it lands right above that card, with after_id right below it (send one, never both). The neighbour must be an active topic already in the target column. Any member can move any topic. It does not edit content (update_suggested_topic) and does not touch posts. A refusal says do not retry; only a temporary failure may be retried.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The suggested topic to move (from list_suggested_topics) |
status | enum | yes | Target column. One of: idea, todo, awaiting_content, in_production, awaiting_approval, posted, standby. |
before_id | string | no | Place the card right above this one. |
after_id | string | no | Place the card right below this one. |
archive_suggested_topic
Archive one suggested topic ("pauta") of the Curadoria board of /posts/pautas in dfl-campaigns, or bring an archived one back with restore=true.write
archive_suggested_topicArchive or restore a suggested topic
Archive one suggested topic ("pauta") of the Curadoria board of /posts/pautas in dfl-campaigns, or bring an archived one back with restore=true. Archiving hides the card from the board but keeps it, and it is reversible: this is the safe way to take a topic off the board. Any member can archive or restore any topic. To remove one for good use delete_suggested_topic. Archived topics are read with list_suggested_topics archived=true. A refusal (unknown id, not available on this deployment) says do not retry; only a temporary failure may be retried.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The suggested topic id (from list_suggested_topics) |
restore | boolean | no | true brings an archived topic back to the board; default archives. Default: false. |
delete_suggested_topic
Permanently delete one suggested topic ("pauta") from the Curadoria board of /posts/pautas in dfl-campaigns.write
delete_suggested_topicPermanently delete a suggested topic you created
Permanently delete one suggested topic ("pauta") from the Curadoria board of /posts/pautas in dfl-campaigns. It cannot be undone. Only the creator of the topic or an admin may delete it: the server decides that, from the caller session, and refuses everybody else with "do not retry" (ask the creator or an admin instead). To take a topic off the board without losing it, use archive_suggested_topic. Pass confirm_title equal to the topic's current title, exactly as list_suggested_topics shows it; a different title, or an id that is not on the board, deletes nothing. Posts already drafted from the topic are not deleted.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The suggested topic id (from list_suggested_topics) |
confirm_title | string | yes | The topic's current title, copied exactly: the guard against deleting the wrong card. |
Idea sources
Section titled “Idea sources”An idea source (fonte) is an idea captured before it is a pauta: a WhatsApp chat, an X reply, a link, a note or a published piece, with the author of each excerpt. Capture it with create_idea_source (a second capture with the same external_id answers duplicate), then decide with set_idea_source_triage: virou_pauta creates the pauta from it, ligada links an existing pauta, referencia keeps it, descartada drops it, and null reopens it. The server writes each decision into the source history with your own id; no argument can write the history. A source of a business unit needs an editor of that unit to write; a source with no unit is open to any member.
The bag of ideas captured before they are a topic: save a chat, an X reply, a link or a note with who said it, then triage it into a topic, a reference or the bin.
list_idea_sources
Read the sources bag of dfl-campaigns, newest first, with the pautas each source links to and its triage history.read
list_idea_sourcesList idea sources (fontes)
Read the sources bag of dfl-campaigns, newest first, with the pautas each source links to and its triage history. An idea source is an idea captured before it is a pauta (a "fonte"): a WhatsApp chat, an X reply, a pasted link or note, or a published piece. It has a business unit (or none: "sem BU"), the raw text, the author of each excerpt, the origin link and date, and a triage state: nova (new), or triada with a destination (virou_pauta, ligada, referencia, descartada). It links N:N to pautas (suggested topics). Third-party words enter only with their author named in excerpts; an unconfirmed third-party story stays a referencia, never a fact in a post. Filters: status (nova, triada; omit for all), type, business_unit_id (a BU id, or "none" for the sources with no BU), keyword_request (requested, answered, cancelled, none = no request was made, any = a request exists), limit (1..200). The answer also carries new_count, the number of sources still nova that you can read. Read-only.
| Parameter | Type | Required | Description |
|---|---|---|---|
status | enum | no | nova or triada; omit for both. One of: nova, triada. |
type | enum | no | Only this type. One of: whatsapp_chat, x_reply, pasted_link, pasted_note, published_piece. |
business_unit_id | string | literal("none") | no | Only this BU, or "none" for the sources with no BU. |
keyword_request | enum | no | Only the sources whose keyword request has this status; none = no request was made; any = a request exists. One of: requested, answered, cancelled, none, any. |
limit | number | no | Maximum rows (default 200) |
get_idea_source
Read one idea source by id: its content, excerpts with authors, triage state, full triage history (who and when) and the linked pautas.read
get_idea_sourceRead one idea source
Read one idea source by id: its content, excerpts with authors, triage state, full triage history (who and when) and the linked pautas. Read-only. not_found also means you cannot read it (RLS).
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
create_idea_source
Put one idea into the sources bag of dfl-campaigns (Pautas → Fontes).write
create_idea_sourceCapture an idea source (fonte) before it becomes a pauta
Put one idea into the sources bag of dfl-campaigns (Pautas → Fontes). An idea source is an idea captured before it is a pauta (a "fonte"): a WhatsApp chat, an X reply, a pasted link or note, or a published piece. It has a business unit (or none: "sem BU"), the raw text, the author of each excerpt, the origin link and date, and a triage state: nova (new), or triada with a destination (virou_pauta, ligada, referencia, descartada). It links N:N to pautas (suggested topics). Third-party words enter only with their author named in excerpts; an unconfirmed third-party story stays a referencia, never a fact in a post. It is created as nova and marked captured_via mcp (or collector). It creates no pauta and no post: triage it with set_idea_source_triage. Send the content: raw_text, excerpts, origin_url or published_post_id (only for type published_piece). external_id is the id at the origin (the X post id of an x_reply) and is unique per type: a second capture of the same item answers duplicate with no new row, so a collector can run twice safely. Permissions (RLS, with your own login): a source of a BU is visible to a viewer of that BU and writable by an editor of that BU (or a global admin); a source with no BU is open to any member. A refusal names the missing role: do not retry it.
| Parameter | Type | Required | Description |
|---|---|---|---|
type | enum | yes | whatsapp_chat, x_reply, pasted_link, pasted_note or published_piece. One of: whatsapp_chat, x_reply, pasted_link, pasted_note, published_piece. |
business_unit_id | string | no | BU of the idea (from list_post_business_units); omit or null = sem BU. |
title | string | no | Short name. |
raw_text | string | no | Raw text or transcript. |
excerpts | object[] | no | The quoted words, each with its author. |
origin_url | string | no | http(s) link to the origin (the X reply, the article) |
origin_at | string | no | When it was said or posted at the origin, ISO 8601. |
external_id | string | no | Id at the origin (X post id): the dedup key per type. |
published_post_id | string | no | Only for published_piece: the campaigns post that the piece is. |
captured_via | enum | no | mcp (default) or collector for a scheduled capture job. One of: mcp, collector. |
set_idea_source_triage
Record one triage decision on an idea source.write
set_idea_source_triageTriage an idea source
Record one triage decision on an idea source. destination: virou_pauta (the server creates a pauta from the source — title from pauta_title, else the source title or text; briefing from the text; the origin link as reference — and links it), ligada (link an existing pauta: suggested_topic_id is required), referencia (keep as reference), descartada (discard), or null to send it back to nova (re-triage is allowed). The server appends one entry to the triage history with YOUR id and the time, in the same write as the new status; you cannot write the history yourself. virou_pauta can take primary_keyword_ext_id: the pauta is born with that primary keyword (a strategy keyword of the pauta BU; get_idea_source lists the keywords the research found for this source, best score first; another BU is refused and no pauta is created). Omit it for a pauta with no keyword. business_unit_id sets the source BU in the same write (for a "sem BU" source). A conflict means another triage won at the same moment: read it again with get_idea_source before you decide again. Permissions (RLS, with your own login): a source of a BU is visible to a viewer of that BU and writable by an editor of that BU (or a global admin); a source with no BU is open to any member. A refusal names the missing role: do not retry it.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
destination | enum | yes | virou_pauta, ligada, referencia, descartada, or null = back to nova. One of: virou_pauta, ligada, referencia, descartada. |
suggested_topic_id | string | no | ligada only: the pauta to link (from list_suggested_topics) |
pauta_title | string | no | virou_pauta only: the title of the new pauta. |
primary_keyword_ext_id | string | no | virou_pauta only: the primary keyword of the new pauta (a strategy keyword id of its BU) |
business_unit_id | string | no | Set the source BU in the same write. |
note | string | no | Why, in one line (kept in the history) |
set_idea_source_keyword_request
Record that this idea source needs keywords (the "Pedir keywords" button of Pautas → Fontes).write
set_idea_source_keyword_requestAsk for keywords for an idea source
Record that this idea source needs keywords (the "Pedir keywords" button of Pautas → Fontes). The server stores one keyword_request on the source: status requested, who asked (YOUR id, verified by the server), when, and an optional seed_hint (the angle or seed words to research, at most 500 chars). It only RECORDS the ask: it sends nothing to an agent and creates no pauta and no keyword. The keyword agent is chosen elsewhere, never by this call. The source needs a business unit (the keywords of a research belong to one BU): a source with no BU is refused, set its BU first with set_idea_source_triage. A second call while the request is still requested changes nothing and keeps the first requester. cancel true cancels a pending request (status cancelled); a cancelled request can be asked again. Read the result with get_idea_source (keyword_request). Permissions (RLS, with your own login): a source of a BU is visible to a viewer of that BU and writable by an editor of that BU (or a global admin); a source with no BU is open to any member. A refusal names the missing role: do not retry it.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
seed_hint | string | no | Optional hint for the keyword agent: the angle or seed words. |
cancel | boolean | no | true = cancel the pending request (no seed_hint with it) |
set_idea_source_keyword_dispatch
For the keyword dispatcher job (plan 20261111-campaigns-fontes-keyword-request-pauta, P3), not for a person.write
set_idea_source_keyword_dispatchRecord the dispatch of a keyword request
For the keyword dispatcher job (plan 20261111-campaigns-fontes-keyword-request-pauta, P3), not for a person. It records, on the keyword_request of a source, that the request goes to a keyword agent. Two steps, so that a request never opens two threads. Step 1, without thread_id: CLAIM the request before you open the thread (it needs status requested and no thread; a claim younger than 30 minutes blocks a second claim; at most 3 claims). Step 2, with thread_id: record the thread you opened (the same thread again changes nothing; another thread is refused, the first one wins). It writes only agent_slug, thread_id and its own claim stamps: status, requested_by and requested_at stay. It sends nothing to an agent and opens no thread. A refused claim means another dispatcher has the request or it was sent already: skip it. Permissions (RLS, with your own login): a source of a BU is visible to a viewer of that BU and writable by an editor of that BU (or a global admin); a source with no BU is open to any member. A refusal names the missing role: do not retry it.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
agent_slug | string | yes | The keyword agent the request goes to (an agent slug, from the dispatcher config) |
thread_id | string | no | Absent = claim the request. Present = the comms thread you opened for it. |
add_idea_source_topic
Link an idea source to one more pauta (suggested topic), with an optional note.write
add_idea_source_topicLink an idea source to a pauta
Link an idea source to one more pauta (suggested topic), with an optional note. A link that already exists is kept as it is. It does not change the triage state; use set_idea_source_triage with destination ligada to record the decision in the history. Permissions (RLS, with your own login): a source of a BU is visible to a viewer of that BU and writable by an editor of that BU (or a global admin); a source with no BU is open to any member. A refusal names the missing role: do not retry it.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
suggested_topic_id | string | yes | The pauta id (from list_suggested_topics) |
note | string | no | Why this source feeds this pauta. |
remove_idea_source_topic
Remove the link between an idea source and a pauta.write
remove_idea_source_topicUnlink an idea source from a pauta
Remove the link between an idea source and a pauta. Only the link is deleted: the source and the pauta both stay. Permissions (RLS, with your own login): a source of a BU is visible to a viewer of that BU and writable by an editor of that BU (or a global admin); a source with no BU is open to any member. A refusal names the missing role: do not retry it.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
suggested_topic_id | string | yes | The pauta id. |
ingest_x_replies
Read the X timeline of one account and save each of its replies to ANOTHER account as one x_reply idea source of one business unit (plan M4: "every @tainanfidelis X reply becomes an x_reply source within 24 h"…write
ingest_x_repliesIngest the replies of an X account as idea sources
Read the X timeline of one account and save each of its replies to ANOTHER account as one x_reply idea source of one business unit (plan M4: "every @tainanfidelis X reply becomes an x_reply source within 24 h"; @tainanfidelis = x_user_id 51754507, BU tainanfidelis.com). The dfl-campaigns server reads X with its own app bearer and writes with YOUR login, so RLS decides; each row is captured_via collector. A reply to the account itself (its own thread) and a plain post are skipped. The read starts after the newest stored reply of that BU (the first run reads lookback_hours back). The X post id is the dedup key: a second run writes no duplicate. With check_deleted_days > 0, the stored replies of that window are looked up on X and a reply that X answers as not found gets origin_deleted_at (the row stays). Only a global admin (or an agent of one) may run it: the X read is paid. dry_run reads X and answers the sources it would write. A scheduled job (dfl-infra x-reply-collector timer) calls this every 3 h; call it by hand only to catch up or to check.
| Parameter | Type | Required | Description |
|---|---|---|---|
x_user_id | string | yes | The numeric X user id (51754507 = @tainanfidelis) |
business_unit_id | string | yes | The BU that receives the sources (from list_post_business_units) |
lookback_hours | number | no | First run only: how far back to read (default 48) |
check_deleted_days | number | no | 0 (default) = skip; N = mark the replies of the last N days that were deleted on X. |
dry_run | boolean | no | Read X and answer the sources, write nothing. |
delete_idea_source
Delete one idea source for good, with its pauta links and its triage history.write
delete_idea_sourceDelete an idea source
Delete one idea source for good, with its pauta links and its triage history. The pautas themselves stay. Use it to remove a test row or a source captured by mistake; to keep a source but stop working on it, triage it with set_idea_source_triage (descartada) instead. Permissions (RLS, with your own login): only the person or agent that captured the source, while an editor of its BU, or a global admin, can delete it. Any other caller gets forbidden: do not retry. not_found also means you cannot read it. A second delete of the same id answers not_found.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The idea source id. |
Posts & review queue
Section titled “Posts & review queue”Draft, revise, approve, schedule, tag and remove posts. An agent writes a post into the review queue; a person clears it.
The posting calendar: see what runs this week or on any date range, write a post, and send it through human review to publishing.
list_posts
Read the post calendar, ordered by scheduled_for.read
list_postsList calendar posts
Read the post calendar, ordered by scheduled_for. Without business_unit_id it is the consolidated view across every BU. Pass status: "awaiting_review" to read the human review queue — everything the AI wrote that is still waiting on a person. assignee_id and zernio_profile_id narrow it to one person or one profile; while those columns do not exist yet the filter is skipped and notes says so. Each post carries assignment; pass include_metrics: true to attach latest_metrics per platform and account. Each post carries archetype and media_group (its content-format tag; null when unset). suggested_topic_id narrows it to the posts linked to one pauta; each post carries post_suggested_topic_id. scheduled_from/to filter on the schedule slot; published_from/to filter on published_at and approved_from/to on approved_at (ISO date-times, inclusive; a post with no such timestamp never matches). For a Sao Paulo day use 03:00Z to the next 03:00Z.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | no | Filter to one BU (from list_post_business_units) |
status | enum | no | Filter by lifecycle state. One of: draft, awaiting_review, approved, rejected, dispatched. |
scheduled_from | string | no | Only posts scheduled at/after this ISO date-time. |
scheduled_to | string | no | Only posts scheduled at/before this ISO date-time. |
published_from | string | no | Only posts published at/after this ISO date-time (published_at; a post never published never matches) |
published_to | string | no | Only posts published at/before this ISO date-time. |
approved_from | string | no | Only posts approved at/after this ISO date-time (approved_at; a post never approved never matches) |
approved_to | string | no | Only posts approved at/before this ISO date-time. |
assignee_id | string | no | Only posts assigned to this user id. |
zernio_profile_id | string | no | Only posts linked to this Zernio profile. |
suggested_topic_id | string | no | Only posts linked to this pauta (post_suggested_topic_id). Applied after the read. |
include_metrics | boolean | no | Attach latest_metrics per platform and account to each post (never summed across platforms) Default: false. |
limit | number | no | Default: 50. |
get_post
One post with its channels, its lifecycle state and its approval trail — who approved it and when, and whether it was already dispatched to Zernio.read
get_postGet one calendar post
One post with its channels, its lifecycle state and its approval trail — who approved it and when, and whether it was already dispatched to Zernio. Also returns assignment (zernio_profile_id, assignee_id; null while those columns do not exist) and latest_metrics: the latest views/likes/comments per platform AND Zernio account, never summed across platforms. The post always carries archetype and media_group (its content-format tag; null when unset or while the columns do not exist). live is { published_at, published_url } once dfl-campaigns read the post LIVE in Zernio (status published): the link to the post on the network. null while it is not known live. keywords are the SEO keywords linked to the post (id, text, slug, cluster_name, is_primary; primary first), read under your own JWT: the read side of set_post_keywords. [] when none are linked; null (with keywords_note) when they could not be read. Use it to answer "how did this post do" and "where is it".
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | — |
draft_post_for_review
Write one post into the calendar.write
draft_post_for_reviewDraft a post into the human review queue
Write one post into the calendar. It lands in awaiting_review and NOTHING leaves this server until a person opens the queue in dfl-campaigns, reads it and approves it — you cannot clear it yourself; approve_post only records a decision a person already gave you. Schedule the time you want it to go out; a channel only reaches its network if it carries the connected zernio_account_id. A YouTube video or an Instagram Reel needs a cover before it can be approved or scheduled (Tainan TG 27243). When such a post (one media_id, no cover) arrives without cover_media_id / cover_url, dfl-campaigns makes the cover itself: a Thumbify cover from the title (or auto_cover_text) — 16:9 for YouTube, 9:16 for a Reel, text only, no person — and attaches it. The result carries auto_cover: created (with cover_media_id), failed (the post is saved without a cover; retry with revise_post_in_review auto_cover: true) or skipped (auto_cover: false). For the designed cover with the author's portrait, make it with the thumbify-reel-cover / thumbify-youtube-cover skill and pass cover_media_id or cover_url: an explicit cover always wins. A Reel cover that is not a Thumbify cover is refused at approval. The Lesson Studio cover slide is NOT carried over. A carousel (Instagram, or a TikTok photo carousel) is either media_ids (existing public.media ids) or media_urls (rendered images, e.g. from render_composition_images; dfl-campaigns registers them as your media). A single image is media_id; TikTok accepts it as a photo post (JPEG, PNG or WebP, up to 20 MB each). An Instagram caption takes at most 5 hashtags (3 to 5 is the target): a body with more than 5 on an Instagram channel is refused before anything is saved, and the same cap blocks approval and sending. Pass media_group + archetype (the content-format tag): a post without an archetype is "untagged" in the weekly summary, and the result carries content_tag_warning. suggested_topic_id links the post to its pauta (from list_suggested_topics): pass it on every post derived from a pauta, so the card shows the post. An id that is not a pauta you can see is refused before anything is saved; the result carries pauta_link_note when the link was not stored. dictated_by marks text that came from a PERSON's speech and that you only transcribed, translated or trimmed (an audio, a video transcript): pass "me" when the person who connected you spoke the words. The post stays authored_by ai (you wrote the file) and still goes to review; dictated_by only records whose words they are, so the weekly summary can tell them from your own copy. Never set it for text you wrote or rewrote with new ideas. Only the caller itself can be named, and only a person. One call can carry a different caption per network: set body_override (and title_override) on a channel entry, for example a long YouTube description in body and a short Instagram caption with at most 5 hashtags on the instagram channel (the hashtag cap is checked per network on its own text). youtube_tags carries the YouTube keywords, sent with the YouTube channel only. An X thread: use media_group text and archetype x-thread, pass the tweets in thread_items (needs an x channel). Item 1 is the root tweet; the post body is not published for a thread, so repeat the first tweet as item 1. x_long_video: true uses the X long video upload for the video of the X entry. Check what each network will receive with get_post_dispatch_preview (sends nothing). For an X or LinkedIn text use media_group text with an archetype from list_archetypes (x-tweet, x-thread, x-article...); article_kind goes only with an article archetype. Returns review_url for the stored Campaigns post UUID: send it to the person who reviews the post. An invalid response identity can follow a saved write; inspect the queue rather than recreating blindly.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Which BU publishes it (from list_post_business_units) |
title | string | yes | Internal title — how the post shows up in the calendar. |
body | string | yes | The text that goes out to the network. |
scheduled_for | string | yes | ISO date-time the post should be published at. |
youtube_visibility | enum | no | How the post lands on YouTube and TikTok. Omitted means private — the closed default, on purpose: a post that goes out more public than intended cannot be taken back, while a private one is one click away from being opened. On TikTok (video or photo) it sets the privacy level: private = only the creator, unlisted = followers only, public = everyone — so the default private means a TikTok post only the creator can see. Only matters when a channel is youtube or tiktok. One of: private, unlisted, public. |
link_url | string | no | INTERNAL note only — this URL is NOT published. The dispatch sends title, body and media to Zernio and nothing else, so a link (and any utm_ it carries) reaches the network ONLY if it is written inside body. The dfl-campaigns form stopped offering this field for that reason; it is kept here for rows written through the API. Put the link in body. |
media_id | string | no | public.media id — never a raw bucket URL; media is served by media.devfellowship.com/:id. |
media_ids | string[] | no | Carousel (Instagram, or TikTok photo carousel): ordered public.media ids of 2 to 10 images; use instead of media_id. Never a single image: one image is media_id. |
media_urls | string[] | no | Carousel (Instagram, or TikTok photo carousel) from rendered images: 2 to 10 public devfellowship S3 media/ PNG/JPG URLs (e.g. render_composition_images output) in order; use instead of media_ids. Never together with media_id or media_ids. |
cover_media_id | string | no | Reel cover: another public.media id (JPEG or PNG, 1080x1920) holding a Thumbify cover (reel-cover-v<N>-…) — any other file is refused at approval. Not the video. Required to approve or schedule a YouTube video or an Instagram Reel (not to draft one); omitted there, dfl-campaigns makes the auto cover (see auto_cover). Dispatch sends this as instagramThumbnail. |
cover_url | string | no | Reel cover as a URL, in place of cover_media_id: a public JPEG/PNG of the devfellowship S3 bucket under media/ — typically a Thumbify render output_url (media/renders/<template>/<ts>.png). dfl-campaigns registers it as public.media (owned by you) and stores that id. Other hosts are refused. Never both. |
auto_cover | boolean | no | Default true. false = do NOT make the automatic Thumbify cover of a YouTube video / Instagram Reel saved without a cover (the post then cannot be approved until you attach one). An explicit cover_media_id / cover_url always wins over the auto cover. |
auto_cover_text | string | no | The words of the auto cover, in place of the title (2 to 6 strong words read best; the first ones go big, the rest on the support line). Ignored when the post gets no auto cover. |
instagram_collaborators | string[] | no | Instagram co-authors: up to 3 usernames, without the @. A co-authored post appears in the feed AND the grid of BOTH accounts, with both handles in the header and the reach added together — it is what makes a post published by a personal profile also work for the company account, without reposting. Naming the @ in the caption does NOT do this; that is only text. ⚠️ Tagging is not publishing: the tagged account gets an INVITE and has to accept it in the Instagram app, and until it does the post does not appear there. Neither Zernio nor Meta can accept for us. Dispatch sends these as collaborators, so they must be on the post BEFORE dispatch — they cannot be added to a post already sent. |
channels | object[] | no | Networks this post goes out through. The same content on several networks or accounts — even across profiles and business units (e.g. TikTok of a person plus YouTube Shorts of the brand) — is ONE call with several entries here, never one call per channel: each extra post is one more approval for the reviewer. With media_group set and no zernio_account_id in any entry (or the list empty), the post gets the BU default channels of that content kind (get_publish_rules) when it is created, and the answer says channels_from_defaults: true. An account you pass is kept as is. No default rule for the kind = no channels are added (approval fills them later if a rule appears). Default: []. |
zernio_profile_id | string | yes | Zernio profile of the person or brand this post goes out as ("Criador" in the dfl-campaigns UI). Required on every post — get it from list_zernio_profiles. |
assignee_id | string | no | Who is expected to produce the content ("Solicitante" in the UI). null unassigns it. |
suggested_topic_id | string | no | The pauta (suggested topic, from list_suggested_topics) this post is derived from. Stored in post_suggested_topic_id, so the post shows as a chip on the pauta card. A pointer only: it changes nothing about status, review or approval. The id must be a pauta that you can see (your own session, RLS); otherwise the call is refused before anything is written. |
youtube_tags | string[] | no | YouTube tags (keywords) of the video: each 1 to 100 characters, at most 500 characters in all by YouTube's count (a comma between tags, quotes around a tag with a space). dfl-campaigns trims them, drops a leading #, removes duplicates, and sends them with the YouTube channel only (Zernio tags). Put the BU keywords here (the primary keyword first). On revise_post_in_review the list REPLACES the stored one; [] clears it. A change after approval sends the post back to review. |
thread_items | object[] | no | X thread: up to 25 items, each { text (max 280 characters), media_ids (up to 4 media uuids, optional) }. An empty text is allowed only when the item has media_ids. Needs an x channel in channels (the server refuses it with 400 otherwise). Item 1 is the root tweet. The post body is NOT published for an X thread (the thread replaces it), so repeat the first tweet as item 1. On revise_post_in_review, omitted leaves the stored thread, [] clears it, and the list REPLACES the stored one. A change after approval sends the post back to review. |
x_long_video | boolean | no | Uses X's long video upload for the video of the X entry (Zernio longVideo). Zernio ignores it on an X account without a paid plan. A change after approval sends the post back to review. |
dictated_by | literal("me") | string | no | The person whose spoken words this text is, when you only transcribed, translated or trimmed them. "me" = the person who connected you (their user id is taken from your session). Omit it for any text you wrote. The server refuses any user id but the caller's own, and an agent login. |
keyword_ids | string[] | no | SEO keywords (strategy.keywords ids, from list_keywords on the strategy MCP) this post was written for, same business unit as the post. The first one is the primary keyword: the post's views count for it. Replaces the whole set; an empty array unlinks all. |
archetype | string | no | Content-format archetype of the post, as a lowercase slug (e.g. "talking-head-hook"), max 64 characters. Requires media_group. null clears it. |
media_group | enum | no | Media group of the post: vertical-short | long-video | micro-clips | ephemeral-daily | swipe-static | text. Required when archetype is set. null clears it (only when the post has no archetype). One of: vertical-short, long-video, micro-clips, ephemeral-daily, swipe-static, text. |
article_kind | string | no | Kind of an ARTICLE piece: only with archetype x-article or linkedin-article. The values are the article_kinds of list_archetypes (tutorial, opiniao, build-log, caso, comparacao); the server refuses any other value and any other archetype. null clears it. |
revise_post_in_review
Rewrite a post that is still in the queue — typically after a reviewer left review_notes, or when a rejected post is being redone.write
revise_post_in_reviewRevise a post that has not been approved yet
Rewrite a post that is still in the queue — typically after a reviewer left review_notes, or when a rejected post is being redone. Only draft, awaiting_review and rejected posts can be revised: once a person has approved it, the text they read is the text that goes out. Status is never changed here. An Instagram caption takes at most 5 hashtags: a body with more than 5 on an Instagram channel is refused and nothing is saved. auto_cover: true makes the automatic Thumbify cover now (after the other changes) — the retry when draft_post_for_review answered auto_cover.status = failed. suggested_topic_id links the post to its pauta (from list_suggested_topics), also after the post was created; null removes the link (the pauta stays). An id that is not a pauta you can see is refused before anything is saved (dfl-campaigns answers 400 unknown_topic if it still sees none), and the result carries pauta_link_note when the stored post does not show the change. youtube_tags replaces the YouTube keywords ([] clears). thread_items replaces the X thread (omitted leaves it, [] clears it; item 1 is the root tweet and the post body is not published for a thread). x_long_video sets the X long video upload (null clears it). channel_texts sets or clears the caption (and title) of networks the post already has — a caption per platform; the Instagram 5-hashtag cap is checked on each network's own text. dictated_by: null clears it, "me" sets it to the connecting person (metadata, keeps an approval). Check the result with get_post_dispatch_preview (sends nothing). Returns review_url for the same stored Campaigns post UUID. If the response identity is invalid after a write, inspect the post rather than retrying blindly.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | — |
title | string | no | — |
body | string | no | — |
scheduled_for | string | no | New ISO date-time. |
link_url | string | no | INTERNAL note only, never published — the dispatch sends title, body and media to Zernio and nothing else. To change the link the network actually sees, edit body. null clears this note. |
media_id | string | no | null clears the media. |
cover_media_id | string | no | Reel cover (JPEG/PNG public.media) holding a Thumbify cover — any other file is refused at approval. A YouTube video or an Instagram Reel cannot be approved or scheduled without a cover. null clears it. Not the video. |
cover_url | string | no | Reel cover as a URL, in place of cover_media_id: a public JPEG/PNG of the devfellowship S3 bucket under media/ — typically a Thumbify render output_url (media/renders/<template>/<ts>.png). dfl-campaigns registers it as public.media (owned by you) and stores that id. Other hosts are refused. Never both. Replaces the cover. |
auto_cover | literal(true) | no | Make the automatic cover now: dfl-campaigns renders a Thumbify cover from the title (or auto_cover_text) — 16:9 for a YouTube video, 9:16 for an Instagram Reel, text only — and attaches it. Only a draft or awaiting_review post with one media and NO cover (else refused: clear cover_media_id first to replace one). Never with cover_media_id / cover_url. |
auto_cover_text | string | no | The words of the auto cover, in place of the title. Needs auto_cover: true. |
youtube_visibility | enum | no | New visibility — private, unlisted or public. Also sets TikTok privacy: private = only the creator, unlisted = followers only, public = everyone. One of: private, unlisted, public. |
instagram_collaborators | string[] | no | Replaces the co-author list. An empty array clears it. Instagram co-authors: up to 3 usernames, without the @. A co-authored post appears in the feed AND the grid of BOTH accounts, with both handles in the header and the reach added together — it is what makes a post published by a personal profile also work for the company account, without reposting. Naming the @ in the caption does NOT do this; that is only text. ⚠️ Tagging is not publishing: the tagged account gets an INVITE and has to accept it in the Instagram app, and until it does the post does not appear there. Neither Zernio nor Meta can accept for us. Dispatch sends these as collaborators, so they must be on the post BEFORE dispatch — they cannot be added to a post already sent. |
zernio_profile_id | string | no | Zernio profile of the person or brand this post goes out as ("Criador" in the dfl-campaigns UI), from list_zernio_profiles. null unlinks it. |
assignee_id | string | no | Who is expected to produce the content ("Solicitante" in the UI). null unassigns it. |
suggested_topic_id | string | no | The pauta (suggested topic, from list_suggested_topics) this post is derived from. A UUID links the post, so it shows as a chip on the pauta card; null removes the link (the pauta stays). A pointer only: it changes nothing about status, review or approval. A UUID must be a pauta that you can see (your own session, RLS); otherwise the call is refused and nothing is written. |
youtube_tags | string[] | no | YouTube tags (keywords) of the video: each 1 to 100 characters, at most 500 characters in all by YouTube's count (a comma between tags, quotes around a tag with a space). dfl-campaigns trims them, drops a leading #, removes duplicates, and sends them with the YouTube channel only (Zernio tags). Put the BU keywords here (the primary keyword first). On revise_post_in_review the list REPLACES the stored one; [] clears it. A change after approval sends the post back to review. |
thread_items | object[] | no | X thread: up to 25 items, each { text (max 280 characters), media_ids (up to 4 media uuids, optional) }. An empty text is allowed only when the item has media_ids. Needs an x channel in channels (the server refuses it with 400 otherwise). Item 1 is the root tweet. The post body is NOT published for an X thread (the thread replaces it), so repeat the first tweet as item 1. On revise_post_in_review, omitted leaves the stored thread, [] clears it, and the list REPLACES the stored one. A change after approval sends the post back to review. |
x_long_video | boolean | no | Uses X's long video upload for the video of the X entry (Zernio longVideo). Zernio ignores it on an X account without a paid plan. A change after approval sends the post back to review. On revise_post_in_review, null clears it (false). |
channel_texts | object[] | no | Set or clear the caption (and title) of networks the post ALREADY has, without restating the accounts. Each entry names a network of the post; body_override / title_override set its own text, null resets it to the post text, an omitted key leaves it as it is. A network the post does not have is refused. Changing a network text after approval sends the post back to review. |
dictated_by | literal("me") | string | null | no | Whose spoken words the text is. null CLEARS it (for example the text was marked dictated but you rewrote it). "me" = the person who connected you, when you only transcribed, translated or trimmed their words. A user id must be that same person; the server refuses another user and an agent login. Metadata only: it does not send an approved post back to review. |
archetype | string | no | Content-format archetype of the post, as a lowercase slug (e.g. "talking-head-hook"), max 64 characters. Requires media_group. null clears it. |
media_group | enum | no | Media group of the post: vertical-short | long-video | micro-clips | ephemeral-daily | swipe-static | text. Required when archetype is set. null clears it (only when the post has no archetype). One of: vertical-short, long-video, micro-clips, ephemeral-daily, swipe-static, text. |
article_kind | string | no | Kind of an ARTICLE piece: only with archetype x-article or linkedin-article. The values are the article_kinds of list_archetypes (tutorial, opiniao, build-log, caso, comparacao); the server refuses any other value and any other archetype. null clears it. |
get_post_dispatch_preview
Read-only. The body that dfl-campaigns would send to Zernio for this post, built by the same code as the real dispatch, and sent NOWHERE: no Zernio call, no write, no status change.read
get_post_dispatch_previewPreview what a post would send to Zernio (sends nothing)
Read-only. The body that dfl-campaigns would send to Zernio for this post, built by the same code as the real dispatch, and sent NOWHERE: no Zernio call, no write, no status change. Use it before approval to check what each network will receive: payload.content (the post body), each payload.platforms[] entry with its own customContent (the caption of that network, when it has one) and platformSpecificData (the YouTube title and visibility, Instagram collaborators), and payload.tags (the YouTube tags, only with a YouTube channel). Text fields are exact. Media fields are approximate: the media type, the direct cover URL and the TikTok settings resolve only at dispatch. A network with no account is dropped, as at dispatch.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | — |
approve_post
Record that a PERSON cleared this post for publishing, when they said so to you instead of clicking in the dfl-campaigns UI — the case the queue had no answer for (Tainan asked for a Reel over Telegram, 2026-09-11).write
approve_postRecord a human approval taken outside the review queue
Record that a PERSON cleared this post for publishing, when they said so to you instead of clicking in the dfl-campaigns UI — the case the queue had no answer for (Tainan asked for a Reel over Telegram, 2026-09-11). It does not approve on your behalf: it WRITES DOWN a decision a human already took, and approval_reference is where you point at the message they took it in. Never call this off your own judgement and never invent a reference to satisfy the field — no server can tell a made-up pointer from a real one, which is precisely why the queue exists. If nobody told you to publish, leave the post in awaiting_review and say it is waiting on a person. Restricted to super admins; everybody else is refused and has to approve in the UI — with ONE exception: an AGENT whose super admin approved on Telegram passes approval_channel: "telegram" and an approval_reference that names that Telegram message ("Telegram msg 27277"). The approval is then recorded FOR that human (approved_by = the person, channel telegram); the server, not you, names the person, and only for an agent the person granted "campaigns_approve" on its delegation. Use it only when the person said "approve" in that message. A YouTube video or an Instagram Reel (one video file) needs a cover (cover_media_id) to be approved: without one the call is refused with 409 naming the missing cover (Tainan TG 27243). Set it first with revise_post_in_review (cover_media_id or cover_url). An Instagram caption with more than 5 hashtags is refused with 409 and nothing is approved: fix the body with revise_post_in_review first. The BU publishing rules apply (get_publish_rules): a post that names no account goes out on the BU default channels of its media_group. Without scheduled_for, a future time that obeys the rules stays; a time that breaks a rule, or that has passed, moves to the next free slot, and the answer carries schedule_moved {scheduled_for, reason}: tell the person the new time. A scheduled_for you pass that breaks a rule is refused with 409 naming the next free slot. publish_now: true skips the rules. Approving IS publishing: the same call sends the post to Zernio, scheduled for its scheduled_for, and Zernio publishes it then. If scheduled_for has ALREADY PASSED, the call is refused with 409 (past_schedule) and nothing is approved, because approving would publish at once (incident 2026-10-08). Ask the person which they want, then call again with publish_now: true (publish at once) or with a new future scheduled_for. Never pick for them. If Zernio refuses, this call fails and the post stays approved but NOT scheduled — fix what the error names and retry with dispatch_post. If the error says it cannot tell whether Zernio received the post, do NOT retry: tell the person to check Zernio.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The post the person cleared (from list_posts with status: "awaiting_review") |
approval_reference | string | yes | Where the human said "publish it", in their words or as a locator: "Telegram msg 18508". The only trace of the person on an approval with no click — it must point at something real that someone auditing this post later can go read. |
expected_updated_at | string | yes | The post's updated_at exactly as you read it (get_post / list_posts) when you showed it to the person. If the post was revised since, the server refuses with 409: read it again and get the person's go-ahead on the new content. |
review_notes | string | no | What they said along with it, if anything — kept on the post as the reviewer note. |
approval_channel | literal("telegram") | no | Only "telegram": you are an agent recording the approval your super admin gave on Telegram (Tainan TG 27252 / 27277). approval_reference must then name the message id. The approval is recorded for that person. Leave it out when you are a super admin approving as yourself. |
publish_now | literal(true) | no | Only when scheduled_for has already passed AND the person said to publish at once. Without it (or a new scheduled_for) a past schedule is refused with 409 past_schedule. |
scheduled_for | string | no | A NEW publish time the person chose, ISO 8601 with offset (e.g. "2026-10-08T19:05:00-03:00" for 19:05 Brasília time). Must be in the future. Use it when the old time has passed. |
dispatch_post
Approving a post already sends it to Zernio — you do not need this after approve_post or after a person approves in the UI.write
dispatch_postRetry scheduling an approved post in Zernio
Approving a post already sends it to Zernio — you do not need this after approve_post or after a person approves in the UI. Use it only to RETRY a post that is approved but not scheduled, because Zernio refused it at approval time (the approval error said so). Fix what that error named first, or the retry fails the same way. The server refuses anything that is not approved with a recorded approver, so this can never publish something nobody cleared. A post whose send outcome is unknown stays dispatched without a Zernio id and is refused here on purpose, so it is never published twice — tell the person to check Zernio. A YouTube video or an Instagram Reel without a cover (cover_media_id) is refused with 409 naming the missing cover. Zernio publishes at scheduled_for; a time that already passed goes out now, and the calendar is updated to match.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The approved, not yet scheduled post (list_posts with status: "approved") |
unschedule_post
Stop a post that Zernio is holding from publishing: the server cancels it in Zernio FIRST and only then rewrites the row, which comes back as awaiting_review with the approval trail cleared.
unschedule_postTake a scheduled post back out of Zernio
Stop a post that Zernio is holding from publishing: the server cancels it in Zernio FIRST and only then rewrites the row, which comes back as awaiting_review with the approval trail cleared. It is NOT a rejection and NOT a shortcut around the queue — it only moves a post BACKWARDS, into human review, and someone has to approve it again for it to be scheduled at all. Judging the post is still not something this server does. A new scheduled_for is required because it is what the post holds while it waits (and it has to be in the future). This only works while Zernio still HOLDS the post: once it published — which includes the last few minutes before scheduled_for, when Zernio may already be sending — nothing here takes it back, and the call is refused saying so rather than reporting a cancel that did not happen. Deleting what is already on the network is done in the network itself, by a person.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The scheduled post (from list_posts with status: "dispatched") |
scheduled_for | string | yes | New ISO date-time the post waits for in the queue. Must be in the future — the server refuses a date that already passed. |
review_notes | string | no | Why it was pulled, kept on the post as the reviewer note for whoever reads it next. |
set_post_schedule
Move ONLY the publish time (scheduled_for) of a post a person already approved, and keep the approval — text, media, cover and networks do not change and cannot be passed here.write
set_post_scheduleReschedule an approved post (time only, approval kept)
Move ONLY the publish time (scheduled_for) of a post a person already approved, and keep the approval — text, media, cover and networks do not change and cannot be passed here. An approved post that Zernio does not hold (its schedule failed) only gets the new time; retry the schedule with dispatch_post. A dispatched post that Zernio still holds is CANCELLED in Zernio and SENT AGAIN at the new time, in the same call (Zernio first, then the row). Refused: a published post; a post within 5 minutes of its old time (Zernio may already be publishing); a sent post with no Zernio id; a Story sequence part; and any post that is not approved yet (draft, awaiting_review, rejected — change their time with revise_post_in_review). A post that would fail the new send for a rule (for example a missing cover) is refused BEFORE the cancel, so it stays scheduled at the old time. If Zernio does not confirm the cancel, nothing changes. If the new send fails after the cancel, the post stays approved at the new time with no schedule, and the error says so: fix what it names and call dispatch_post. Only move a time a person asked for.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The approved post (list_posts with status: "approved" or "dispatched") |
scheduled_for | string | yes | The new publish time, ISO 8601 with offset (e.g. "2026-11-08T19:00:00-03:00" for 19:00 Brasília time). Must be in the future. |
expected_updated_at | string | no | The updated_at of the post as get_post returned it. When it is set and the post changed since, the call is refused (409) and nothing moves. Recommended: read the post, then pass this. |
reject_post
Move a post that YOU created from awaiting_review to rejected — for example a smoke or test post, or a post the person told you to drop.write
reject_postWithdraw one of your own posts from the review queue
Move a post that YOU created from awaiting_review to rejected — for example a smoke or test post, or a post the person told you to drop. It refuses any post created by somebody else: rejecting another person's post is a judgement on content, and a person does that in the dfl-campaigns UI. It also refuses a draft (delete it with delete_post), an approved post, and a scheduled or published post (unschedule_post takes a scheduled post back to the queue). The reason is optional; when given it is stored as the post's review_notes. A rejected post never publishes; delete_post then removes it.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | Your post, from list_posts with status: "awaiting_review". |
reason | string | no | Optional (Tainan TG 27244). Why the post leaves the queue, kept as review_notes: "smoke test post, not for publishing". Left out or blank, the post is rejected with no note. |
delete_post
Permanently delete a post that YOU created, while it is a draft or rejected — for example a smoke or test post.write
delete_postDelete one of your own draft or rejected posts
Permanently delete a post that YOU created, while it is a draft or rejected — for example a smoke or test post. The post and its channels go; this cannot be undone. It refuses a post created by somebody else, a post in the review queue (reject it with reject_post first), and every approved, scheduled or published post.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | Your draft or rejected post. |
archive_post
Hide an approved or PUBLISHED post from dfl-campaigns — the calendar, the profile pages (recent posts, top posts, cadence, counts) and analytics — while KEEPING its metric snapshots in the database.
archive_postArchive a published post (admin only) — hide it, keep its metrics
Hide an approved or PUBLISHED post from dfl-campaigns — the calendar, the profile pages (recent posts, top posts, cadence, counts) and analytics — while KEEPING its metric snapshots in the database. Use it for a published post that should not be in the lists, for example a test post that already went live. It is a soft delete that records who archived the post and why; it does not delete anything and it does not touch Zernio or the social network (the post stays live there, or has already expired). There is no un-archive tool. Restricted to global admins (IAM level 80 or higher): everybody else gets 403. It refuses a draft or rejected post (use delete_post), a post in the review queue (reject_post, then delete_post), and a post still scheduled in Zernio (unschedule_post first). Only call it when a person asked for the post to go, and put where they asked in the reason.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The approved or published post to hide. |
reason | string | yes | Why the post leaves the lists, pointing at the decision: "Test Stories, Tainan TG msg 19998/20007". Stored on the post for whoever audits it later. |
set_post_zernio_id
Repair a post that is "dispatched" (or published) in dfl-campaigns but has NO zernio_post_id — the calendar says it was sent, but unschedule_post and revisions cannot find it in Zernio.
set_post_zernio_idLink a sent post to its Zernio post (admin only, repair)
Repair a post that is "dispatched" (or published) in dfl-campaigns but has NO zernio_post_id — the calendar says it was sent, but unschedule_post and revisions cannot find it in Zernio. The server reads the Zernio post list and links the row only when exactly one Zernio post has the same accounts, the same media and a creation time near the approval. It writes zernio_post_id, dispatched_at and scheduled_for (the time Zernio holds), and returns the per-network ids and links. Nothing is sent or published. Zero or several matches link nothing and say so. Run it with dry_run: true first to see the match. Restricted to global admins (IAM level 80 or higher).
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The sent post with no Zernio id. |
dry_run | boolean | no | true = show the match and write nothing. |
set_post_keywords
Replace the SEO keywords linked to a post, in any status — including posts already dispatched, so older content can be mapped to keywords.write
set_post_keywordsLink a post to the SEO keywords it was written for
Replace the SEO keywords linked to a post, in any status — including posts already dispatched, so older content can be mapped to keywords. It never changes the post itself and never touches its approval. The first keyword is the primary one.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | — |
keyword_ids | string[] | yes | — |
set_post_content_tag
Write media_group + archetype on ONE post, in any status — published posts included.write
set_post_content_tagSet the content-format tag of a post (any status)
Write media_group + archetype on ONE post, in any status — published posts included. It writes those two fields and nothing else: title, text, media, schedule and approval stay as they are. The creator of a post may tag it; any other post needs a global admin (IAM level >= 80). The pair must match the content-visual taxonomy (e.g. vertical-short + talking-head; archetype null is a media-group-only tag). Pass dry_run: true to see the before/after and the authority check without writing.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | — |
media_group | enum | yes | Media group: vertical-short | long-video | micro-clips | ephemeral-daily | swipe-static | text. One of: vertical-short, long-video, micro-clips, ephemeral-daily, swipe-static, text. |
archetype | string | yes | Archetype slug of that media group, from the dfl-campaigns content taxonomy (e.g. talking-head, framework-carousel, news-carousel, selfie-proof-story). An unknown slug is refused with the list of known ones. null = media group only. |
dry_run | boolean | no | true = check and show the change, write nothing. |
set_post_published_manual
WRITE DOWN that a person already published this post BY HAND on the network (they typed it in the browser or the app).write
set_post_published_manualRecord a post that a person published by hand
WRITE DOWN that a person already published this post BY HAND on the network (they typed it in the browser or the app). It sends NOTHING to any network and never calls Zernio: it sets the post to published with published_via browser, the URL and the time you give. Use it only when a person told you they published it and gave you the link; never invent a URL or a time. published_url must be an https URL of one of the networks the post goes to (an x.com URL for an X post); published_at is when it went live (ISO date-time, not in the future). Allowed for a draft, a post in review, or an approved post that Zernio never held. Refused for a post that is already published, rejected, dispatched, or has a Zernio id. The approval trail: a post that a person already approved keeps it. A post with no approval needs one: a person records it in the dfl-campaigns post page; an agent passes approval_reference naming the Telegram message where the person said they published it ("Telegram msg 27277"). The server then records the approval FOR that person, and only for an agent whose super admin granted it "campaigns_approve" on its delegation (the same gate as approve_post). Do not invent a reference.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | The post the person published by hand. |
published_url | string | yes | The https link of the live post on its network. |
published_at | string | yes | ISO date-time when the post went live (not in the future) |
approval_reference | string | no | For an agent, when the post has no approval yet: the Telegram message where the person said they published it, for example "Telegram msg 27277". Leave it out when a person already approved the post. |
list_archetypes
The catalog of content formats that a post can carry: the media groups (vertical-short, long-video, micro-clips, ephemeral-daily, swipe-static, text), the archetype slugs of each (for example talking-head…read
list_archetypesList the content formats: media groups, archetypes and article kinds
The catalog of content formats that a post can carry: the media groups (vertical-short, long-video, micro-clips, ephemeral-daily, swipe-static, text), the archetype slugs of each (for example talking-head, framework-carousel, x-tweet, x-thread, x-article, linkedin-article), and the article kinds. Use it BEFORE you pass media_group + archetype to draft_post_for_review, revise_post_in_review or set_post_content_tag, so you do not invent a slug. An article_kind (tutorial, opiniao, build-log, caso, comparacao) goes only with an archetype that has accepts_article_kind: true (x-article, linkedin-article); the server refuses any other value or archetype. The media group text has no publishing rules yet. Read-only.
| Parameter | Type | Required | Description |
|---|---|---|---|
media_group | string | no | Only the archetypes of this media group (for example text). Omit it for the whole catalog. |
Analytics
Section titled “Analytics”Post metrics per account and platform. See Analyze content performance below.
How the posts did: rank an account's posts, see the history of one post, and read 30 days of account numbers.
list_campaign_accounts
List each platform and Zernio account combination that has stored post metric snapshots.read
list_campaign_accountsList campaign analytics accounts
List each platform and Zernio account combination that has stored post metric snapshots. Accounts stay separate even when they use the same platform. An RLS-safe database RPC excludes soft-deleted posts before it computes the summaries.
| Parameter | Type | Required | Description |
|---|---|---|---|
platform | enum | no | Filter to one social platform. One of: instagram, facebook, linkedin, tiktok, youtube, x, threads, pinterest, reddit, bluesky, telegram, discord, whatsapp, google_business. |
rank_account_posts
Rank one Zernio account's campaigns posts.read
rank_account_postsRank posts for one account
Rank one Zernio account's campaigns posts. lifetime uses the latest absolute counter. period_gain subtracts the baseline from the latest observation inside the requested period and can be negative. The RLS-safe database RPC computes and bounds the ranking.
| Parameter | Type | Required | Description |
|---|---|---|---|
account_id | string | yes | Exact Zernio account ID from list_campaign_accounts. |
platform | enum | yes | Exact platform from list_campaign_accounts. One of: instagram, facebook, linkedin, tiktok, youtube, x, threads, pinterest, reddit, bluesky, telegram, discord, whatsapp, google_business. |
metric | enum | yes | One of: views, likes, comments. |
basis | enum | no | One of: lifetime, period_gain. Default: "lifetime". |
start_date | string | no | Period start date, required for period_gain. |
end_date | string | no | Period end date, required for period_gain. |
limit | number | no | Default: 10. |
get_post_metric_history
Return stored daily absolute counters for one campaigns post.read
get_post_metric_historyGet post metric history
Return stored daily absolute counters for one campaigns post. Account and platform targets are required so separate publication targets are never combined. Reads fail explicitly above 10,000 visible snapshots; use a smaller date range.
| Parameter | Type | Required | Description |
|---|---|---|---|
post_id | string | yes | campaigns.posts ID. |
account_id | string | yes | Exact Zernio account ID. |
platform | enum | yes | Exact publication platform. One of: instagram, facebook, linkedin, tiktok, youtube, x, threads, pinterest, reddit, bluesky, telegram, discord, whatsapp, google_business. |
start_date | string | no | — |
end_date | string | no | — |
get_account_analytics
The last 30 São Paulo days of ONE Zernio account on ONE platform, the same numbers as the Analytics page of dfl-campaigns.read
get_account_analyticsGet 30-day analytics for one account
The last 30 São Paulo days of ONE Zernio account on ONE platform, the same numbers as the Analytics page of dfl-campaigns. daily: for each day, the sum over this account's posts of each post's latest cumulative views on or before that day (a post counts from its first snapshot in the window). top: the 5 posts with the most latest views. median_views: median latest views of posts dispatched with scheduled_for inside the window. Never add two accounts or platforms together; call once per account. truncated=true means the page cap was hit and totals may be low.
| Parameter | Type | Required | Description |
|---|---|---|---|
account_id | string | yes | Exact Zernio account ID from list_campaign_accounts. |
platform | enum | yes | Exact platform from list_campaign_accounts. One of: instagram, facebook, linkedin, tiktok, youtube, x, threads, pinterest, reddit, bluesky, telegram, discord, whatsapp, google_business. |
get_business_unit_analytics
Read-only. One analytics page of ONE business unit for a date window, the same sections the dfl-campaigns pages SEO & Ads show (and the same JSON as GET /api/analytics/<page>), read as the caller so RLS decides which…read
get_business_unit_analyticsGet business unit analytics
Read-only. One analytics page of ONE business unit for a date window, the same sections the dfl-campaigns pages SEO & Ads show (and the same JSON as GET /api/analytics/<page>), read as the caller so RLS decides which units are visible. Pages: overview (KPIs, funnel with targets, origins, friction, source health), acquisition (Google Ads), web, behavior, revenue (DFL-wide). Every section carries its own status (ok, empty, unconfigured, warming, not_supported, unavailable, error): read the status before reading numbers, and never fill a missing section with a guess. Money is in the unit of the section (BRL or minor units, as the section says). truncated=true on a section means the read cap was hit and the numbers are a lower bound.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid from list_post_business_units. "all" is accepted on the revenue page only: every unit the caller can read. |
from | string | yes | First São Paulo day of the window, YYYY-MM-DD. |
to | string | yes | Last São Paulo day of the window (inclusive), YYYY-MM-DD. The span is at most 400 days. |
page | enum | yes | Which dfl-campaigns analytics page to read. One of: overview, acquisition, web, behavior, revenue. |
compare | boolean | no | Also compute the equally long previous window (default true) |
include_internal | boolean | no | Include internal traffic (web, behavior) or internal records (revenue). Default false. |
site | enum | no | Which site of the unit the web and behavior pages read. Default landing. One of: landing, app. |
ads_source_id | string | no | Pick one Google Ads account when the unit has several (analytics source uuid) |
Account mapping
Section titled “Account mapping”Map each Zernio account to a business unit and an owner.
Say which business unit and which person own each social account.
list_social_accounts
List campaigns.social_accounts: each Zernio account with its business unit (name, logo) and its owner (name, avatar).read
list_social_accountsList Zernio account mappings
List campaigns.social_accounts: each Zernio account with its business unit (name, logo) and its owner (name, avatar). All filters combine with AND. unmapped_only returns the accounts with no business_unit_id. Write a mapping with set_social_account_mapping.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | no | Only accounts of this BU. |
owner_user_id | string | no | Only accounts owned by this user. |
zernio_profile_id | string | no | Only accounts of this Zernio profile. |
unmapped_only | boolean | no | Only accounts with no business_unit_id. |
status | enum | no | Only accounts with this status. Omit to list both. One of: active, archived. |
set_social_account_mapping
Create or update the campaigns.social_accounts row of one Zernio account (idempotent UPSERT on zernio_account_id).
set_social_account_mappingSet the BU and owner of a Zernio account
Create or update the campaigns.social_accounts row of one Zernio account (idempotent UPSERT on zernio_account_id). It maps the account to a business unit (strategy.business_units) and to the person who owns it (public.profiles). An omitted optional field keeps its stored value; an explicit null clears business_unit_id or owner_user_id. Take zernio_account_id, zernio_profile_id and platform from list_zernio_accounts. The BU must exist: find it with list_canvas_business_units on the strategy MCP, or create a creator BU there with create_canvas_business_unit — this server does not create BUs. Optional status: "archived" archives the account (archived_at is set to now), "active" restores it (archived_at is cleared); the two columns always change together, and an omitted status leaves both alone. Runs with your JWT; RLS allows the write only to global admins.
| Parameter | Type | Required | Description |
|---|---|---|---|
zernio_account_id | string | yes | Zernio account id (the conflict key) |
zernio_profile_id | string | yes | Zernio profile id of the account. |
platform | string | yes | Zernio platform string, e.g. instagram, youtube. Stored lowercase. |
handle | string | no | Zernio username. Omit to keep the stored value; null clears it. |
display_name | string | no | Zernio displayName. Omit to keep the stored value; null clears it. |
avatar_url | string | no | Zernio profilePicture URL. Omit to keep the stored value; null clears it. |
business_unit_id | string | no | strategy.business_units id. Omit to keep; null clears (account not clickable). |
owner_user_id | string | no | User id of the person who owns the account (public.profiles id). Omit to keep; null clears. |
status | enum | no | archived sets archived_at = now(); active sets archived_at = NULL. Omit to keep both. One of: active, archived. |
Google Ads
Section titled “Google Ads”Read-only. The ads of one business unit (the ad text and the totals per ad, as the Analytics > Ads page shows them), the numbers per ad per day, and the search terms (the real queries people typed into Google before an ad was shown, totalled per ad group over a window). The three tools run with your JWT, so only a global admin or a viewer of the business unit sees rows. Nothing here calls Google Ads or changes an ad.
Read the Google Ads ads of a business unit: the ad text, the totals per ad, the numbers per ad per day, and the search terms people typed. Read-only.
list_ads
Read-only. The Google Ads ads of ONE business unit, as the dfl-campaigns page Analytics > Ads shows them: per ad the responsive search ad text (headlines[], descriptions[]), the final URL, the status label, and the…read
list_adsList Google Ads ads
Read-only. The Google Ads ads of ONE business unit, as the dfl-campaigns page Analytics > Ads shows them: per ad the responsive search ad text (headlines[], descriptions[]), the final URL, the status label, and the numbers totalled over from..to (impressions, clicks, ctr_pct in percent, cost in the account currency, conversions). Read as the caller, so RLS decides: only a global admin or a viewer of the business unit sees rows. Read status first: anything other than "ok" (unconfigured, not_supported, empty, error, …) means there are no numbers to read, never zero. collected_at and stale say how fresh the ingest is. For the per-day series use list_ad_daily_metrics. Nothing here changes Google Ads.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid from list_post_business_units. |
from | string | yes | First day of the metrics window, YYYY-MM-DD. |
to | string | yes | Last day of the metrics window (inclusive), YYYY-MM-DD. The span is at most 400 days. |
ads_source_id | string | no | Pick one Google Ads account (analytics source uuid, see accounts[] in the answer) when the unit has several. |
campaign_name | string | no | Keep only the ads of this campaign (exact name, case-insensitive) |
ad_group_external_id | string | no | Keep only the ads of this Google ad group id. |
include_drafts | boolean | no | Also return the draft ads that wait in dfl-campaigns (never live in Google). Default false. |
list_ad_daily_metrics
Read-only. One row per Google ad per day for ONE business unit, from campaigns.ads_ad_daily (filled by the dfl-campaigns ingest): impressions, clicks, ctr_pct (percent, null with 0 impressions), cost_micros, cost…read
list_ad_daily_metricsList daily Google Ads metrics per ad
Read-only. One row per Google ad per day for ONE business unit, from campaigns.ads_ad_daily (filled by the dfl-campaigns ingest): impressions, clicks, ctr_pct (percent, null with 0 impressions), cost_micros, cost (account currency), conversions. Ordered by ad_external_id, then day. Read as the caller, so RLS decides: only a global admin or a viewer of the business unit sees rows, and 0 rows can mean "no access" as well as "no data". A day with no row had no traffic or is not collected yet. truncated=true means the row cap was hit: narrow the window or pass ad_external_ids. Ad text lives in list_ads.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid from list_post_business_units. |
from | string | yes | First day, YYYY-MM-DD. |
to | string | yes | Last day (inclusive), YYYY-MM-DD. The span is at most 400 days. |
ads_source_id | string | no | Only this Google Ads account (analytics source uuid, from list_ads accounts[]) |
ad_external_ids | string[] | no | Only these Google ad ids (ad_external_id from list_ads). Default: every ad of the unit. |
list_ads_search_terms
Read-only. The Google Ads search terms of ONE business unit: the real queries that people typed into Google before an ad was shown, totalled per ad group and search term over the window, from…read
list_ads_search_termsList Google Ads search terms per ad group
Read-only. The Google Ads search terms of ONE business unit: the real queries that people typed into Google before an ad was shown, totalled per ad group and search term over the window, from campaigns.analytics_daily_metrics (filled by the dfl-campaigns ingest). Each row: search_term, ad_group_external_id, campaign_external_id and campaign_name (null when no ad of the group is known), impressions, clicks, ctr_pct (percent, null with 0 impressions), cost_micros, cost (account currency), conversions, keyword_id (the keyword that matched, null when not recorded). Ordered by impressions, then clicks, then term. Read as the caller, so RLS decides: only a global admin or a viewer of the business unit sees rows, and 0 rows can mean "no access" as well as "no data". A campaign filter that matches no ad group gives 0 rows. truncated=true means the list was cut: more than limit terms exist, or the row cap was hit and the totals are lower bounds; narrow the window, filter by campaign or raise limit. Nothing here calls Google Ads, and nothing writes. Ad text lives in list_ads; the numbers per ad per day in list_ad_daily_metrics.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid from list_post_business_units. |
from | string | yes | First day, YYYY-MM-DD. |
to | string | yes | Last day (inclusive), YYYY-MM-DD. The span is at most 400 days. |
ads_source_id | string | no | Only this Google Ads account (analytics source uuid, from list_ads accounts[]) |
campaign | string | no | Only the ad groups of this campaign: the exact campaign_name (case-insensitive) or the campaign_external_id, as list_ads shows them. No match gives 0 rows. |
limit | number | no | Rows to return, after the sort. 1 to 500, default 100. |
Experiments
Section titled “Experiments”An experiment is one row of work.hypotheses. The Campaigns page “Experimentos”
(/analytics/experiments) shows the same rows. The seven tools below let an agent
do what the page does: pick a metric, record a hypothesis, start the test, read the
result, and close it with a decision. Every tool runs with your JWT. A viewer of
the business unit reads. An editor writes. Nothing here calls Google Ads or changes
an ad.
Record growth hypotheses and experiments for a business unit: pick a metric that exists, start the test, read the readout date, and close it with a decision.
list_campaign_metrics
Read-only. The metric catalog of ONE business unit: the distinct metric keys that exist in campaigns.analytics_daily_metrics (each with entity, metric, dimension, unit and the newest day that has a row) and in…read
list_campaign_metricsList the metrics a hypothesis can point to
Read-only. The metric catalog of ONE business unit: the distinct metric keys that exist in campaigns.analytics_daily_metrics (each with entity, metric, dimension, unit and the newest day that has a row) and in campaigns.analytics_targets (target bands). Read as the caller, so RLS decides what is visible. Use it BEFORE create_hypothesis: copy one row into metric_source_ref as {"source_schema":"campaigns","source_table":<source_table>,"source_selector":{"entity","metric","dimension"}}. Per-arm numbers of an experiment use dimension "variant" (rows appear after the test starts). Every event_<name> and sessions_<name> row also carries definition: the Events Dictionary row of that event (meaning, count_unit event or person, fires_when, status), or null when nobody defined it yet ("Sem definição"). event_* counts events and sessions_* counts unique sessions. A metric that is not derived from an event (visits, cost, ...) has no definition key. create_hypothesis refuses an event_* metric whose definition is null (ADR-13): define it first with upsert_event_definition. If the metric you need is not in that list, register it first as a collector spec in dfl-campaigns-ingest (devfellowship/dfl-services, path services/dfl-campaigns-ingest/src/collectors/<vendor>/, the map.ts and jobs.ts of the vendor), so a collector writes its rows into campaigns.analytics_daily_metrics; then create the hypothesis. A new metric is a PR there, not free text here. truncated=true means the read cap stopped the scan: filter by entity or metric.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
entity | string | no | Only this entity, e.g. web_dimension, behavior, ads_campaign. |
metric | string | no | Only this metric key. |
dimension | string | no | Only this dimension ("" = rows with no dimension) |
list_hypotheses
Read-only. Hypotheses and experiments from work.hypotheses (the rows of the Campaigns "Experimentos" page), newest first, read as the caller so RLS decides which business units are visible (viewer role).read
list_hypothesesList hypotheses and experiments
Read-only. Hypotheses and experiments from work.hypotheses (the rows of the Campaigns "Experimentos" page), newest first, read as the caller so RLS decides which business units are visible (viewer role). Each row carries title, secondary_metrics, parked_reason and depends_on_id (a parked row waits for that hypothesis), the arms with image_url and preview_url, readout_date (started_at + window_days) and closed. Filter by business unit, status, area or experiment_key. has_more=true means more rows match: call again with offset.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | no | Only this business unit (from list_post_business_units) |
status | enum[] | no | Only these statuses: proposed, open, parked, testing, confirmed, refuted, inconclusive. |
area | enum | no | Only this area. One of: acquisition, activation, conversion, cost, reliability, learning. |
experiment_key | string | no | Only the hypothesis with this experiment_key. |
limit | number | no | Rows per call, default 50. |
offset | number | no | Rows to skip, default 0. |
get_hypothesis
Read-only. One row of work.hypotheses by id, read as the caller (RLS: viewer of the business unit).read
get_hypothesisGet one hypothesis
Read-only. One row of work.hypotheses by id, read as the caller (RLS: viewer of the business unit). It carries the metric selector (metric_source_ref), the secondary_metrics, the arms (with image_url and preview_url when set), the window, the status, parked_reason and depends_on_id when parked, the title, the result and readout_date (started_at + window_days).
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The hypothesis id (from list_hypotheses) |
create_hypothesis
Create one row in work.hypotheses (the Campaigns "Experimentos" page) as the caller: you need the editor role on the business unit, and you are recorded as created_by.write
create_hypothesisCreate a hypothesis or an experiment
Create one row in work.hypotheses (the Campaigns "Experimentos" page) as the caller: you need the editor role on the business unit, and you are recorded as created_by. An agent is recorded in proposed_by_actor_id. Two fields are REQUIRED and describe the experiment itself: varied_dimension = the ONE dimension this experiment changes while all the others stay the same (open text, not a BM Canvas block; e.g. "content topic" when a microlearning unit moves from HTML/CSS/JS to harness engineering with the format kept, or "teaching format" when it moves from microlearning to 15 min or 1 h courses with the content kept); implementation_cost = low, medium or high, the work to BUILD the change, not money (free trial 3 -> 4 days = low; a big refactor = high). The metric is a SELECTOR, never free text: call list_campaign_metrics first and copy one row into metric_source_ref. A metric that does not exist for the business unit is refused, with the way to register it. Returns the row with readout_date (started_at + window_days). Nothing here touches Google Ads or the landing code. Status starts as proposed unless you pass open, parked or testing. Optional: title (at most 120 characters), secondary_metrics (secondary and guardrail selectors), depends_on_id (a hypothesis of the same business unit this one waits for) and, with status parked, parked_reason. Arms may carry image_url and preview_url (https). When the business unit already has an open or running hypothesis in the same area, the answer warns and names it (older hypotheses go before new ones); the row is still saved. Optional decision_id links the experiment to the strategy decision it tests (a decision of the same business unit; refused otherwise). Metric rule (ADR-7): an experiment metric counts unique sessions (or visitors), in the segment where the change is visible, so set source_selector.segment. An event_* metric counts events, not people: the answer warns (it never refuses) until a per-session metric exists in list_campaign_metrics. Definition lock (ADR-13): an event_* metric (primary or secondary) whose event has no definition in the Events Dictionary is REFUSED; define it first with upsert_event_definition (list_campaign_metrics shows definition: null). Any other metric with no definition only warns.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units). You need the editor role on it. |
area | enum | yes | acquisition, activation, conversion, cost, reliability or learning. One of: acquisition, activation, conversion, cost, reliability, learning. |
observation | string | yes | What you saw, with the number and its source ("0 of 11 mobile Ads sessions touched the game") |
statement | string | yes | The hypothesis: "if we change X, metric M moves to T, because Y". |
varied_dimension | string | yes | REQUIRED. The ONE dimension of the business that this experiment changes, while all the other dimensions stay the same. Open text, a short noun phrase (at most 120 characters); it is NOT a BM Canvas block. Name the dimension, not the new value: the values go in statement and change_summary. Examples for a microlearning business unit: "content topic" (the lessons move from HTML/CSS/JS to harness engineering or teaching AI, the format stays microlearning); "teaching format" (microlearning flopped, so try long courses of 15 min or 1 h, while the content can stay HTML/CSS). Other examples: "price", "free trial length", "landing headline", "acquisition channel". |
implementation_cost | enum | yes | REQUIRED. How much work it takes to BUILD the change: low, medium or high. It is the build effort, not money and not the media budget. Examples: "change the free trial from 3 to 4 days" = low (one config value); a new page or a new email sequence = medium; a big refactor or a new product feature = high. One of: low, medium, high. |
title | string | no | Optional short title for the card (not blank, at most 120 characters) |
metric_source_ref | object | yes | Where the metric is read from (ADR-4). Copy the fields from one row of list_campaign_metrics. Example: {"source_schema":"campaigns","source_table":"analytics_daily_metrics","source_selector":{"entity":"web_dimension","metric":"event_sandbox_answered","dimension":"variant"}}. |
secondary_metrics | object[] | no | Secondary and guardrail metrics: [{role, metric_source_ref, limit?}]. Each metric_source_ref is a selector copied from list_campaign_metrics, validated like the primary one. Send the FULL list: it replaces the stored one. [] clears it. |
metric_key | string | no | A readable name for the metric. Default: entity.metric of the selector. It is a label; the selector decides where the numbers come from. |
baseline_value | number | yes | The value of the metric before the change. |
change_summary | string | no | What changes, per arm; guardrail metrics go here as text. |
target_value | number | no | The value that counts as a win. |
target_direction | enum | no | Is a higher (up) or lower (down) value better. One of: up, down. |
window_days | number | no | The readout window in days (3, 5 or 7 for a fast cycle). Readout date = started_at + window_days. |
min_samples_per_arm | number | no | Minimum sample per arm before a decision. |
arms | object[] | no | The arms compared, e.g. [{"key":"A","label":"video first"},{"key":"B","label":"game first","image_url":"https://...","preview_url":"https://..."}]. image_url and preview_url are optional https URLs (at most 2000 characters) and are the only arm keys a running test may change. |
artifact_refs | object[] | no | Links to the change: [{type, id, url}], e.g. a landing PR. |
test_type | enum | no | ab_split, multivariate, before_after, feature_toggle, platform_experiment (a split that an external platform runs, e.g. Google Ads) or qualitative. One of: ab_split, multivariate, before_after, feature_toggle, platform_experiment, qualitative. |
experiment_key | string | no | Stable slug of the experiment, the key in the code registry and the Umami "variant" value (e.g. home-game-first). Unique per business unit: every test needs a new key. |
status | enum | no | proposed (default), open, parked (waits; needs parked_reason, usually with depends_on_id) or testing (the test runs now; started_at defaults to now) One of: proposed, open, parked, testing. |
parked_reason | string | no | Why the row waits. Required with status parked; refused with any other status. |
depends_on_id | string | no | The hypothesis this one waits for: a hypothesis of the SAME business unit (never itself). With status parked, the row waits until that one closes ("park until X closes") |
decision_id | string | no | The BM Canvas strategy decision that this experiment tests (strategy.decisions id, from strategy.list_decisions). It must belong to the SAME business unit as the hypothesis; the service refuses another unit. |
started_at | string | no | When the test began, ISO 8601. Needed for status testing (default now) |
loop_id | string | no | Optional: the work.loops row this hypothesis belongs to. |
actor_slug | string | no | First-party sessions only: the agent slug that proposed it (e.g. claude-main), recorded in proposed_by_actor_id. An OAuth session records its grant actor by itself. |
update_hypothesis
Change one row of work.hypotheses as the caller (editor role on the business unit).write
update_hypothesisUpdate, start or close a hypothesis
Change one row of work.hypotheses as the caller (editor role on the business unit). Start a test: status testing (started_at defaults to now). Close it: status confirmed, refuted or inconclusive with result_value and decision_reason (closed_at defaults to now). Rules: a closed row is the record and keeps its status, result and metric (only text, title and links can be corrected); a running test keeps its arms, metric, secondary_metrics, baseline, test_type and experiment_key (a new test needs a new hypothesis and a new experiment_key), except the image_url and preview_url of its existing arms, which may change at any time; a new metric_source_ref or secondary_metrics is validated like create_hypothesis (see list_campaign_metrics), including the definition lock (ADR-13): a CHANGED event_* metric with no definition in the Events Dictionary is refused; a row that keeps the metric it already has is not checked. Park: status parked with parked_reason (from proposed or open; a running test never parks); optionally depends_on_id, a hypothesis of the same business unit to wait for. Resume: status proposed from parked; refused while depends_on_id is still open unless you pass resume_reason. Leaving parked clears parked_reason. A close may carry learning: one plain sentence (1..280 characters) of what the test taught; decision_reason keeps the why with the per-arm n. closed_by is set from the caller on a close and cannot be sent. varied_dimension (the ONE dimension the experiment changes, the others fixed) and implementation_cost (low, medium or high build effort) can be set or corrected on any row, closed or running; they cannot be cleared. decision_id links the experiment to the strategy decision it tests (same business unit; null clears it); it can be set on any row, closed or running. business_unit_id, loop_id, created_by and proposed_by_actor_id cannot change.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The hypothesis id (from list_hypotheses) |
status | enum | no | Move the status. testing = start the test (sets started_at to now unless given). confirmed, refuted or inconclusive = close it: needs result_value and decision_reason (closed_at defaults to now). parked = wait: needs parked_reason (from proposed or open only). proposed from parked = resume ("Retomar"): allowed when the row has no depends_on_id, or that hypothesis is closed or gone, or you pass resume_reason. A closed row does not change status; a running test only closes. One of: proposed, open, parked, testing, confirmed, refuted, inconclusive. |
parked_reason | string | no | Why the row waits. Required to park; refused unless the row is or becomes parked. Cleared when the row leaves parked. |
resume_reason | string | no | Resume (status proposed) a parked row whose depends_on_id is still open: why you resume before it closes. Not stored as a column; returned in notes. |
varied_dimension | string | no | The ONE dimension of the business that this experiment changes, while all the other dimensions stay the same. Open text, a short noun phrase (at most 120 characters); it is NOT a BM Canvas block. Name the dimension, not the new value: the values go in statement and change_summary. Examples for a microlearning business unit: "content topic" (the lessons move from HTML/CSS/JS to harness engineering or teaching AI, the format stays microlearning); "teaching format" (microlearning flopped, so try long courses of 15 min or 1 h, while the content can stay HTML/CSS). Other examples: "price", "free trial length", "landing headline", "acquisition channel". Cannot be cleared (create_hypothesis requires it) |
implementation_cost | enum | no | How much work it takes to BUILD the change: low, medium or high. It is the build effort, not money and not the media budget. Examples: "change the free trial from 3 to 4 days" = low (one config value); a new page or a new email sequence = medium; a big refactor or a new product feature = high. Cannot be cleared (create_hypothesis requires it) One of: low, medium, high. |
title | string | no | Short title for the card (not blank, at most 120 characters); null clears it. |
depends_on_id | string | no | The hypothesis this one waits for: same business unit, never itself; null clears it. |
decision_id | string | no | The strategy decision that this experiment tests (same business unit; the service refuses another unit). null clears the link. Allowed on a closed row (it is a link) |
secondary_metrics | object[] | no | Secondary and guardrail metrics: [{role, metric_source_ref, limit?}]. Each metric_source_ref is a selector copied from list_campaign_metrics, validated like the primary one. Send the FULL list: it replaces the stored one. [] clears it. |
result_value | number | no | The measured value at the readout (needed to close) |
decision_reason | string | no | Why the result is what it is, with the per-arm n (needed to close) |
learning | string | no | One plain sentence of what the test taught (1..280 characters). Send it with the close; an editor may fix it later. The why with the per-arm n stays in decision_reason. |
closed_at | string | no | When the decision was taken, ISO 8601 (default now when closing) |
started_at | string | no | When the test began, ISO 8601 (default now when starting) |
area | enum | no | One of: acquisition, activation, conversion, cost, reliability, learning. |
observation | string | no | — |
statement | string | no | — |
metric_source_ref | object | no | Where the metric is read from (ADR-4). Copy the fields from one row of list_campaign_metrics. Example: {"source_schema":"campaigns","source_table":"analytics_daily_metrics","source_selector":{"entity":"web_dimension","metric":"event_sandbox_answered","dimension":"variant"}}. |
metric_key | string | no | — |
baseline_value | number | no | — |
change_summary | string | no | — |
target_value | number | no | — |
target_direction | enum | no | One of: up, down. |
window_days | number | no | — |
min_samples_per_arm | number | no | — |
arms | object[] | no | The arms compared, e.g. [{"key":"A","label":"video first"},{"key":"B","label":"game first","image_url":"https://...","preview_url":"https://..."}]. image_url and preview_url are optional https URLs (at most 2000 characters) and are the only arm keys a running test may change. |
artifact_refs | object[] | no | Links to the change: [{type, id, url}], e.g. a landing PR. |
test_type | enum | no | One of: ab_split, multivariate, before_after, feature_toggle, platform_experiment, qualitative. |
experiment_key | string | no | — |
delete_hypothesis
Permanently delete one row of work.hypotheses.write
delete_hypothesisPermanently delete your own unclosed hypothesis
Permanently delete one row of work.hypotheses. It cannot be undone. Only YOUR OWN row (you are its created_by) that is NOT closed, and only while you hold the editor role on its business unit. A closed row (confirmed, refuted, inconclusive) is the durable record and is refused: it stays in the learnings log. Use it to remove a draft made by mistake or an end-to-end test row. To give up a real test, close it as inconclusive with update_hypothesis instead.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The hypothesis id (from list_hypotheses) |
update_hypothesis_status
The two status moves that update_hypothesis refuses, as one explicit correction of work.hypotheses, written as the caller (editor role on the business unit; RLS decides).write
update_hypothesis_statusReopen a closed hypothesis or park a running test (recorded correction)
The two status moves that update_hypothesis refuses, as one explicit correction of work.hypotheses, written as the caller (editor role on the business unit; RLS decides). action reopen: a closed row (confirmed, refuted or inconclusive) goes back to testing, when the decision was wrong (for example the test still runs). It clears result_value, decision_reason, learning, closed_at and closed_by, takes optional new arms and window_days, and sets started_at (default now). action park: a running test (testing) goes to parked with reason as parked_reason, when it is superseded before its readout; started_at is cleared, so a later start sets a new one. from_status is the status you read: the write happens only while the row still has it. Each call appends one dated history entry to change_summary with the caller id, the reason and the previous values (a reopen keeps the closed record there). Text fields (observation, change_summary) are edited afterwards with update_hypothesis. Data corrections go by this tool, never by a migration.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The hypothesis id (from list_hypotheses) |
action | enum | yes | reopen = a closed row (confirmed, refuted or inconclusive) goes back to testing; park = a running test (testing) goes to parked. One of: reopen, park. |
from_status | enum | yes | The status you read (get_hypothesis). The write happens only while the row still has it. One of: testing, confirmed, refuted, inconclusive. |
reason | string | yes | Why this correction is right (who decided it, and the evidence). Written to the history entry; for park it is also parked_reason. |
arms | object[] | no | reopen only: the arms of the reopened test. REPLACES the stored arms. Absent = keep them. |
started_at | string | no | reopen only: when the reopened test began, ISO 8601 (default now) |
window_days | number | no | reopen only: the new window (absent = keep it) |
set_analytics_target
Create or update one row of campaigns.analytics_targets (the Metas page): the target band low to high of one metric of one business unit, valid from valid_from.
set_analytics_targetSet the target band of one metric of a business unit
Create or update one row of campaigns.analytics_targets (the Metas page): the target band low to high of one metric of one business unit, valid from valid_from. Idempotent on (business_unit_id, metric, valid_from): the same call twice returns outcome "unchanged". The call sets the whole band, so an omitted valid_to or note is stored as null. Returns the row read back from the database. Runs with your JWT. You need the editor role on the business unit or a global admin; today RLS lets only a global admin write, so a business-unit editor gets a clear refusal. A target band is also a metric that create_hypothesis accepts: list_campaign_metrics shows it under targets, and a hypothesis points to it with {"source_schema":"campaigns","source_table":"analytics_targets","source_selector":{"metric":<metric>}}.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
metric | enum | yes | The metric key. The database accepts only this list. One of: ctr, click_to_lp, lp_to_paid, churn_first_renewal, cpc, cac, monthly_paid_subscriptions, bounce_rate, pages_per_visit, visit_to_signup_rate, monthly_subscribers_gained. |
low | number | yes | Low end of the band. |
high | number | yes | High end of the band (at least low) |
unit | enum | yes | pct (a percentage), brl (money) or count. One of: pct, brl, count. |
valid_from | string | no | First day the band applies, YYYY-MM-DD. Default: today (UTC). Part of the key. |
valid_to | string | no | Last day the band applies, YYYY-MM-DD, or null (open). Default: null. |
note | string | no | Why this band (source of the goal). Default: null. |
upsert_manual_daily_metrics
Write daily rows of campaigns.analytics_daily_metrics for a metric that no collector measures, as the caller.write
upsert_manual_daily_metricsWrite daily values of a manual metric of a business unit
Write daily rows of campaigns.analytics_daily_metrics for a metric that no collector measures, as the caller. You need the editor role on the business unit (or be a global admin). The rows belong to a source of kind manual: pass source_id of an existing manual source, or source_name to use the manual source "<business_unit_id>:<source_name>" of the unit (created disabled, with no credential, on the first call). A source of any other kind is refused: collector rows are never written here. Idempotent per (source, day, entity, entity_id, segment, dimension, dimension_value, currency, metric): a new key is inserted, a changed value is updated, an equal value is left unchanged. At most 400 rows per call. event_* and sessions_* metric names are refused (they are counted from app events). The written metric appears in list_campaign_metrics, so create_hypothesis and the experiment form can use it. A manual row is a normal row of the table. So the entities that a reader sums with no source filter are refused (revenue, organic_page, organic_site, web_stats, web_dimension, ads_search_term); the default entity is "behavior". Delete rows with delete_manual_daily_metrics.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units). You need the editor role on it. |
source_id | string | no | An existing manual source of the unit. Give this or source_name. |
source_name | string | no | The name of the manual source in the unit (external_ref "<business_unit_id>:<source_name>"); created on first use. |
source_label | string | no | A human label for a NEW source. Default "Manual - <source_name>". |
rows | object[] | yes | The daily values. |
delete_manual_daily_metrics
Delete rows of campaigns.analytics_daily_metrics that belong to ONE manual source, as the caller (editor of the business unit or global admin).write
delete_manual_daily_metricsDelete daily values of a manual metric source
Delete rows of campaigns.analytics_daily_metrics that belong to ONE manual source, as the caller (editor of the business unit or global admin). A source of any other kind is refused: collector rows are never deleted here. Filter by from/to day, entity and metric; with no filter every row of the source is deleted. The source itself stays (no tool deletes a source). Returns the number of deleted rows; 0 when nothing matched.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid of the source. |
source_id | string | yes | A manual source of the unit (from upsert_manual_daily_metrics) |
from | string | no | First day, inclusive. |
to | string | no | Last day, inclusive. |
entity | enum | no | One of: ads_campaign, ads_conversion_action, ads_keyword, ads_budget, behavior, youtube_channel, youtube_video, youtube_audience, ga4_audience. |
metric | string | no | — |
The order of calls
Section titled “The order of calls”list_post_business_unitsgives thebusiness_unit_id.list_campaign_metricslists the metrics that exist for that unit. Copy one row intometric_source_ref. Never type a metric name by hand.create_hypothesissaves the row. The status starts asproposed. When the unit already has an open or running hypothesis in the same area, the answer warns and names it: older hypotheses go before new ones. Park the new one behind it withstatus: "parked",parked_reasonanddepends_on_id.update_hypothesiswithstatus: "testing"starts the test.started_atis now.list_hypothesesorget_hypothesisreturns the row withreadout_date. The page shows the per-arm numbers (see below).update_hypothesiswithstatus: "confirmed","refuted"or"inconclusive", plusresult_valueanddecision_reason, closes the test.delete_hypothesisremoves a draft or a test row. It works only on your own row that is not closed.
{ "business_unit_id": "<uuid from list_post_business_units>", "area": "activation", "observation": "0 of 11 mobile Ads sessions touched the game (Umami, last 7 days)", "statement": "If the home shows the game first, sandbox_answered per exposed session goes from 4% to 8%, because the visitor tries before reading", "metric_source_ref": { "source_schema": "campaigns", "source_table": "analytics_daily_metrics", "source_selector": { "entity": "web_dimension", "metric": "event_sandbox_answered", "dimension": "variant" } }, "baseline_value": 4, "target_value": 8, "target_direction": "up", "window_days": 7, "min_samples_per_arm": 100, "test_type": "ab_split", "experiment_key": "home-game-first", "title": "Home: game before video", "secondary_metrics": [ { "role": "guardrail", "metric_source_ref": { "source_schema": "campaigns", "source_table": "analytics_daily_metrics", "source_selector": { "entity": "behavior", "metric": "rage_clicks" } }, "limit": 3 } ], "arms": [ { "key": "A", "label": "video first", "preview_url": "https://itera.dev/?variant=A" }, { "key": "B", "label": "game first", "image_url": "https://media.devfellowship.com/game-first.png" } ]}title (at most 120 characters), secondary_metrics and the arm image_url /
preview_url (https, at most 2000 characters) are optional. Each secondary metric
is a selector like the primary one, with a role of secondary or guardrail and
an optional limit.
The answer holds the saved row, readout_date (null until the test starts), and
warnings when the call saved something that needs your attention.
The metric selector
Section titled “The metric selector”metric_source_ref is a selector: {source_schema, source_table, source_selector}.
It has two shapes.
source_table | source_selector | Use |
|---|---|---|
analytics_daily_metrics | entity, metric, optional dimension, optional dimension_value | A daily number. The usual case. |
analytics_targets | metric only | A target band of the business unit (the Metas page). |
create_hypothesisrefuses a metric that does not exist for the unit. The error nameslist_campaign_metricsand the place to register a new metric: a collector spec indfl-campaigns-ingest(a PR indevfellowship/dfl-services).- A metric that exists, with a
dimensionthat has no row yet, is accepted with a warning. The per-arm rows come after the test starts. - The input is strict. A free-text metric, or an unknown field, fails at the input.
- Read the real names from
list_campaign_metrics. For example, the rows ofweb_dimensionuse the metriccount, split by a dimension such asdeviceorevent. They do not use a metric calledevents.
Per-arm numbers
Section titled “Per-arm numbers”The Itera landing sends the Umami event property variant, with the value
<experiment_key>:<arm> (for example home-game-first:B), and one exp_exposed
event per session. The ingest writes these as rows with entity = web_dimension,
dimension = variant, dimension_value = <experiment_key>:<arm> and
metric = event_<event> (for example event_exp_exposed, event_sandbox_answered).
The rows split in four segments (all, internal, mobile, mobile_internal).
The segments overlap: read one segment, never the sum.
The page reads these rows through the selector of the experiment. It has no
automatic link. The experiment_key and the arm key of the row must match the
variant value. The values are event counts, not distinct sessions.
Target-based experiments and set_analytics_target
Section titled “Target-based experiments and set_analytics_target”A target band is also a metric a hypothesis can point to. Use it when the experiment has no per-arm numbers, for example a qualitative test. The page then shows the readout state “A métrica não aponta para analytics_daily_metrics”. You read the result at the source and write it when you close the row.
set_analytics_target writes one band (low, high, unit, valid_from) for a
metric of one unit. It is idempotent on (business_unit_id, metric, valid_from): the
same call twice returns unchanged. The answer is the row read back from the
database. Today the database lets only a global admin write a band. A business
unit editor gets a clear refusal. list_campaign_metrics shows the bands under
targets.
Status rules
Section titled “Status rules”| Rule | What the tool does |
|---|---|
| Start | status: "testing" sets started_at to now, unless you pass it. Without window_days the answer warns: no readout date. |
| Readout date | started_at + window_days. A window of 3, 5 or 7 days is the fast cycle. |
| Park | status: "parked" from proposed or open. Needs parked_reason. Optional depends_on_id: a hypothesis of the same business unit this one waits for (never itself). A running test and a closed row never park. |
| Resume | status: "proposed" from parked (“Retomar”). Allowed when the row has no depends_on_id, or that hypothesis is closed or gone. While it is still open, pass resume_reason: the answer returns it in notes. Leaving parked clears parked_reason. |
| Running test | It keeps arms, metric_source_ref, secondary_metrics, metric_key, baseline_value, test_type and experiment_key. One exception: image_url and preview_url of the existing arms may change (same arms, same order, same key and label). It only closes. A new test needs a new row and a new experiment_key. |
| Close | confirmed, refuted or inconclusive. Needs result_value and decision_reason. closed_at defaults to now. |
| Closed row | The record. Only its text, title and links change. It cannot be deleted. |
| Delete | Your own row, not closed. The database enforces it with a policy. Another user’s row, or a viewer, deletes zero rows. |
Access
Section titled “Access”You need a role on the business unit, not only a login. A viewer reads. An editor
writes. A global admin does both. A zero-row answer can mean no access, so check the
role first. A global admin grants a role on one unit with the ops host tool
add_resource_grant (resource_type: strategy.business_unit, role viewer or
editor). That call grants access: use it with care.
The tools degrade with care when the database is older than the tool. If the three
columns test_type, started_at and experiment_key are not live, the tools read
and write the base columns and set experiment_columns_live: false on each row. A
call that sends one of the three gets a readable refusal. The tool never drops a
value without telling you.
For the page, the per-arm readout and the badge states, see docs/experiments.md in the
dfl-campaigns repository.
Events Dictionary
Section titled “Events Dictionary”campaigns.event_definitions holds what each analytics event means: one row per analytics source and event
name. The two tools below read and write it with your JWT. A viewer of the business unit reads. An editor
writes. Nothing is deleted: a retired event gets the status deprecated.
upsert_event_definition needs meaning and count_unit for a new row (event: every send counts; person:
one per visitor or session). A new row starts as draft until the business unit owner confirms it (active).
where_surfaces is the fixed “Onde ocorre” list; where_location and where_route say where on the surface.
Every change appends one dated entry to the history. effective_date (a day, not in the future) dates an entry
that took effect before it was written; the real write time stays in recorded_at. A call with a
history_note and no field change records a past change without touching the meaning. An event that list_campaign_metrics shows and
list_event_definitions does not show has no definition.
Write and read what each analytics event means: the meaning, whether it counts events or people, where it fires, its properties and a dated change history. A definition starts as a draft until the business unit owner confirms it.
list_event_definitions
Read-only. The rows of campaigns.event_definitions of ONE business unit, ordered by analytics source and event name: meaning, count_unit (event or person), label, fires_when, properties, where_surfaces, where_location…read
list_event_definitionsList the event definitions of a business unit (Events Dictionary)
Read-only. The rows of campaigns.event_definitions of ONE business unit, ordered by analytics source and event name: meaning, count_unit (event or person), label, fires_when, properties, where_surfaces, where_location, where_route, status (draft, active, planned, deprecated) and the dated history. Read as you, so RLS decides what is visible (viewer role on the business unit). An event that is in list_campaign_metrics but not here has no definition ("Sem definição"). Filter by source_id, event_name or status. truncated=true means the limit stopped the list. Write with upsert_event_definition.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
source_id | string | no | Only this analytics source. |
event_name | string | no | Only this raw event name. |
status | enum | no | Only this status. One of: draft, active, planned, deprecated. |
limit | number | no | Maximum rows (default 200, at most 500) |
upsert_event_definition
Write one row of campaigns.event_definitions as the caller (editor role on the business unit): the meaning of one event of one analytics source.write
upsert_event_definitionCreate or update the definition of one event (Events Dictionary)
Write one row of campaigns.event_definitions as the caller (editor role on the business unit): the meaning of one event of one analytics source. The key is (source_id, event_name); event_name is the raw name the source reports (e.g. sandbox_completed) and never changes. Call it again with the same key to update: send only the fields that change; a call that changes nothing writes nothing. A new row needs meaning and count_unit (event = every send counts, person = one per visitor or session); its status defaults to draft (written from a code reading, not confirmed by the business unit owner). Other statuses: active (confirmed), planned (defined, not sent yet), deprecated (no longer sent: the row stays, there is no delete). where_surfaces is the fixed "Onde ocorre" list (landing, app, server, global, google_ads, youtube, ga4, clarity, search_console); one event may have several. where_location is the place on the surface (e.g. "Jogo da landing"), where_route the route that fires it (e.g. "/"). properties is the list of property names the event carries: copy them from the tracking code, never guess. Every change appends one dated entry to history (history_note, or a generated "Updated: <fields>"). effective_date (YYYY-MM-DD, not in the future) dates that entry when the change took effect before you wrote it; the real write time stays in recorded_at. A call that changes no field but sends history_note appends that note as one entry (use it to record a past change without touching the meaning); the same note on the same day is not written twice. Read the rows back with list_event_definitions. Data goes by this tool, never by a migration seed.
| Parameter | Type | Required | Description |
|---|---|---|---|
source_id | string | yes | The analytics source (campaigns.analytics_sources.id) that reports the event. |
event_name | string | yes | The raw event name as the source reports it. Immutable. |
business_unit_id | string | no | Optional: checked against the business unit of the source. |
meaning | string | no | What the event means, in plain language. Required on create. |
count_unit | enum | no | event (every send counts) or person (one per visitor or session). Required on create. One of: event, person. |
label | string | no | A short name for the dictionary card; null clears it. |
fires_when | string | no | The moment the event fires; null clears it. |
properties | string[] | no | Property names the event carries. REPLACES the list. |
where_surfaces | enum[] | no | Onde ocorre: the surfaces that send it. REPLACES the list. |
where_location | string | no | Onde ocorre: the place on the surface; null clears it. |
where_route | string | no | The route that fires it, e.g. "/" or "/perguntas"; null clears it. |
status | enum | no | draft (default on create), active, planned or deprecated. One of: draft, active, planned, deprecated. |
history_note | string | no | The note of the dated history entry that this write appends. |
effective_date | string | no | The day the change took effect, YYYY-MM-DD, not in the future. Dates the history entry; the real write time stays in recorded_at. |
SEO pages
Section titled “SEO pages”A SEO page is one logical page of a business unit: one question, one URL per language
(campaigns.seo_pages + seo_page_urls, plan 20261028-campaigns-paginas-seo). The ten
tools run with your JWT: a viewer of the business unit reads, an editor writes, and
nobody deletes (a page leaves by status). ingest_seo_pages_from_sitemap reads the sitemap
(and a sitemap index), groups the hreflang alternates into one page each, and with
dry_run=false inserts them as inventory_draft; it skips every URL that already exists.
add_keyword_link_suggestions only suggests: reason is required, a keyword of another unit
is refused, and a pair a person already rejected is refused. There is no tool that confirms,
rejects or weighs a link: that decision is a person’s, in dfl-campaigns.
get_seo_source_status says which traffic sources the unit has (Umami present or absent;
Search Console is not_available today: the source registry has no such kind), and
get_seo_page_series returns the daily rows per URL per source, never mixed, or an
explicit not_available with the reason.
The SEO pages of a business unit: import them from the sitemap, see which keyword each page targets and which keywords have no page, propose a keyword for a page (a person confirms it), note what changed on a page, and read its daily traffic per source.
list_seo_pages
Read-only. The logical SEO pages of ONE business unit (campaigns.seo_pages), each with its URLs grouped by locale, its primary keyword and the count of its secondary keywords.read
list_seo_pagesList the SEO pages of a business unit
Read-only. The logical SEO pages of ONE business unit (campaigns.seo_pages), each with its URLs grouped by locale, its primary keyword and the count of its secondary keywords. Only CONFIRMED keyword links count unless include_suggested=true. Read as the caller, so RLS decides: you need the viewer role on the business unit (or a global admin); zero rows can mean no access. Filter by status (inventory_draft, active, consolidated, archived) and page_type. has_more=true means more rows match: call again with offset. Pages come from ingest_seo_pages_from_sitemap or create_seo_page; get_seo_page gives one page with every link and annotation.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
status | enum[] | no | Only these statuses; default every status. |
page_type | enum[] | no | Only these page types: article, question, landing, home, category, other. |
include_suggested | boolean | no | true also counts SUGGESTED keyword links (status suggested) in primary_keyword and secondary_keyword_count; default confirmed only. Default: false. |
limit | number | no | Pages per call, default 50. |
offset | number | no | Pages to skip, default 0. |
get_seo_page
Read-only. One logical SEO page by id: the page, its URLs (every locale), its keyword links of EVERY status (suggested, confirmed, rejected, each with role, reason, confidence, who suggested and who decided) and its…read
get_seo_pageGet one SEO page
Read-only. One logical SEO page by id: the page, its URLs (every locale), its keyword links of EVERY status (suggested, confirmed, rejected, each with role, reason, confidence, who suggested and who decided) and its annotations (business milestones, oldest first). Read as the caller (RLS: viewer of the business unit). A rejected link stays visible on purpose: add_keyword_link_suggestions refuses to propose that pair again.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The SEO page id (from list_seo_pages) |
list_keyword_coverage
Read-only. For ONE business unit, every strategy.keywords row with its coverage state: covered (a CONFIRMED link to a page that is not archived), suggestion_pending (only suggested links), or no_page (no link, or only…read
list_keyword_coverageKeyword coverage of a business unit
Read-only. For ONE business unit, every strategy.keywords row with its coverage state: covered (a CONFIRMED link to a page that is not archived), suggestion_pending (only suggested links), or no_page (no link, or only rejected ones). It also lists the keywords that are duplicates by text_normalized (same locale, same lower-case unaccented text) and the pages with no confirmed keyword. Read as the caller (RLS: viewer of the business unit). Before the P2 migration of strategy.keywords the duplicate key is computed locally (normalized_by says which). Use it to pick what to propose with add_keyword_link_suggestions; it writes nothing.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
locale | string | no | Only keywords of this locale (pt-BR, en, es). Ignored before the P2 migration. |
state | enum[] | no | Only keywords in these states; default every state. |
include_archived_pages | boolean | no | true also counts links to archived pages as coverage; default false. Default: false. |
get_seo_source_status
Read-only. Which SEO traffic sources exist for ONE business unit, from the source registry campaigns.analytics_sources read as the caller: umami (present, with each Umami site, its site_role landing/app and is_enabled…read
get_seo_source_statusWhich traffic sources a business unit has
Read-only. Which SEO traffic sources exist for ONE business unit, from the source registry campaigns.analytics_sources read as the caller: umami (present, with each Umami site, its site_role landing/app and is_enabled, plus the newest day that has a web row), and search_console. Each source has its own status: present, absent, not_available (the registry has no such source kind today, with the reason) or unknown (RLS hides the registry from you, with the reason). The tool never guesses: read the status before get_seo_page_series.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
list_collector_runs
Read-only. The newest runs of the dfl-campaigns-ingest collectors (campaigns.analytics_collector_runs), read as the caller: you need the viewer role on the business unit, or be a global admin; RLS hides the rest.read
list_collector_runsThe newest runs of the analytics collectors
Read-only. The newest runs of the dfl-campaigns-ingest collectors (campaigns.analytics_collector_runs), read as the caller: you need the viewer role on the business unit, or be a global admin; RLS hides the rest. Each run has the job, the source (kind and label), the status (ok, partial, error, skipped, running), rows_upserted, api_calls, the closed error_code and error_detail (which call failed and with which HTTP status or code; never a response body). A partial run with rows delivered some data; a skipped run made no call on purpose and collected nothing. Filter by business unit, source kind, job, status and start time. Newest first. An empty list is not proof of a stall: read caller_access first.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | no | Business unit uuid (from list_post_business_units). Omit to read every unit that RLS shows you. |
source_kind | enum | no | Only runs of sources of this kind, for example clarity. One of: google_ads, umami, clarity, billing, youtube, ga4, search_console, contacts. |
job | enum | no | Only this job, for example clarity or umami_stats. One of: ads_structure, ads_daily, ads_late_conversions, ads_keyword_metrics, umami_stats, umami_dimensions, clarity, revenue_export, events_ingest, youtube_channel, ga4_report, organic_search_daily. |
status | enum | no | Only runs with this status. One of: running, ok, partial, error, skipped. |
since | string | no | Only runs that started at or after this instant (ISO 8601, for example 2026-11-03T00:00:00Z) |
limit | number | no | How many runs, newest first. Default 30, at most 200. Default: 30. |
get_seo_page_series
Read-only. The daily series of ONE SEO page (every URL of it) or of ONE URL, per traffic source, from campaigns.analytics_daily_metrics read as the caller.read
get_seo_page_seriesDaily traffic series of a SEO page
Read-only. The daily series of ONE SEO page (every URL of it) or of ONE URL, per traffic source, from campaigns.analytics_daily_metrics read as the caller. Every series is labelled with its source and its source_id; the tool NEVER mixes two sources in one series and never sums them. Umami rows are the web_dimension rows with dimension "path" whose dimension_value equals the URL path (with or without the trailing slash), for ONE audience segment (default all; the segments overlap, so never add them). A source with no row answers status not_available with the reason (no Umami site registered, no per-path row in the window, or search_console: no such source kind exists today). Call get_seo_source_status first. Window: from/to as YYYY-MM-DD, default the last 28 days, at most 400 days.
| Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | no | The SEO page id (from list_seo_pages): every URL of the page. One of page_id or url_id. |
url_id | string | no | One URL id (from get_seo_page). One of page_id or url_id. |
from | string | no | First day of the window, YYYY-MM-DD (default to minus 27 days) |
to | string | no | Last day of the window, inclusive, YYYY-MM-DD (default today, UTC) |
segment | enum | no | The ONE audience segment to read: all (default), internal, mobile, mobile_internal. They overlap: never sum them. One of: all, internal, mobile, mobile_internal. Default: "all". |
source | enum | no | Only this source (umami or search_console); default both, each labelled. One of: umami, search_console. |
get_search_console_performance
Read-only. Google Search Console performance of ONE business unit, read as the caller (viewer role on the business unit).read
get_search_console_performanceSearch Console clicks, impressions, CTR and position of a business unit
Read-only. Google Search Console performance of ONE business unit, read as the caller (viewer role on the business unit). Scope: web search only, no country, no device (ADR-5 of plan 20261028-campaigns-paginas-seo). group_by total (default: one row of totals), day, page or query; page and query rows are the top N by clicks. EXACT numbers: group_by total, day and page read the stored Search Console totals (campaigns.analytics_daily_metrics, entity organic_site, or organic_page for page and page_url), which match the Search Console totals; the answer says totals_basis site_total or page_total. group_by query reads campaigns.organic_search_query_daily, which holds the VISIBLE queries only (Search Console leaves anonymized queries out): its sums are lower than the real totals, so the answer says totals_basis visible_queries_only and totals_exact false. When a window has no stored total yet, total, day and page fall back to the visible-query sums with the same label. Optional page_url keeps one page (matched on its url key: scheme, www, query string and trailing slash do not matter). Default window: the 28 days that end on the last complete day (today minus 3: Search Console lags 2 to 3 days). The answer is always labelled source search_console. A window with no row answers status "n/d" and every number "n/d": it NEVER answers 0, because 0 is a measurement and an empty window is not. A business unit with no search_console source, or a database without the table, answers status not_available with the reason. CTR = clicks / impressions. Position = impression-weighted mean of the row positions; it can differ a little from the Search Console UI, which aggregates by query and page. This is the only Search Console performance tool of the fleet (shared with plan 20261027-dados-de-busca-via-mcp).
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
from | string | no | First day, YYYY-MM-DD (default: to minus 27 days) |
to | string | no | Last day, inclusive, YYYY-MM-DD (default: today minus 3 days, UTC) |
group_by | enum | no | total (default), day, page or query. One of: total, day, page, query. Default: "total". |
page_url | string | no | Keep one page: any URL form of it (matched on the url key) |
limit | number | no | Rows returned for group_by page or query (top by clicks), default 25. Default: 25. |
list_hero_pages
Read-only. The daily hero score of the SEO pages of ONE business unit, from campaigns.seo_page_scores read as the caller (viewer role on the business unit).read
list_hero_pagesHero pages (the SEO pages that rank best) of a business unit
Read-only. The daily hero score of the SEO pages of ONE business unit, from campaigns.seo_page_scores read as the caller (viewer role on the business unit). The score job in dfl-services writes one row per page per day; this tool reads ONE day (default: the newest day with a row). heroes_only=true (default) returns the heroes; false returns every ranked page. Each row has rank, score (0 to 100), is_hero, the four terms with their status (active, pending or disabled) and the weight they really had, the raw numbers, formula_version and traffic_source. Every row is labelled with its traffic_source: umami rows are PROVISIONAL (is_provisional=true) and a ranking of one source is never merged with another. The answer says "Pouco dado para ranquear" (score null) when fewer than 3 pages have traffic. The weights and the cutoff come from get_hero_score_config. has_more=true means call again with offset. A business unit with no score row answers status no_scores, never an empty ranking.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
day | string | no | Score day, YYYY-MM-DD (default: the newest day with a score row) |
heroes_only | boolean | no | true (default): only the heroes. false: every ranked page. Default: true. |
limit | number | no | Pages per call, default 50. |
offset | number | no | Pages to skip, default 0. |
get_hero_score_config
Read-only. The hero score settings of ONE business unit from campaigns.seo_hero_config, read as the caller (viewer role on the business unit): the weights of the four terms C (traffic), V (conversions), K (keywords) and…read
get_hero_score_configHero score weights and cutoff of a business unit
Read-only. The hero score settings of ONE business unit from campaigns.seo_hero_config, read as the caller (viewer role on the business unit): the weights of the four terms C (traffic), V (conversions), K (keywords) and T (trend), top_n, score_cutoff, min_clicks, the brand terms (branded_patterns) and the config version. config_source is "row" when the business unit has a row, or "defaults" when it has none: then the job uses the initial proposal (0.40 / 0.30 / 0.20 / 0.10, top 5, cutoff 70, min 10 clicks). The answer also carries the formula and the hero rule in words, so a reader can say why a page is or is not a hero. A person changes these settings in dfl-campaigns; no MCP tool writes them. The scores come from list_hero_pages.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
get_seo_change_impact
Read-only. For each annotation of ONE SEO page (a change you or a person noted with add_seo_page_annotation), compares Search Console in the window_days (default 28) BEFORE the change with the window_days AFTER it, as…read
get_seo_change_impactBefore and after impact of the changes noted on a SEO page
Read-only. For each annotation of ONE SEO page (a change you or a person noted with add_seo_page_annotation), compares Search Console in the window_days (default 28) BEFORE the change with the window_days AFTER it, as the caller. D is the UTC day of occurred_at and is in neither window: before = D-N..D-1, after = D+1..D+N. Each side has from, to, clicks, impressions, avg_position (weighted by impressions, never an average of averages; null without impressions) and days_with_data. delta = clicks (after - before), clicks_pct (null when before has no clicks) and avg_position (after - before: NEGATIVE is BETTER, a lower position number is a higher rank). status measuring = the after window is not closed yet (it closes when D+N is at most today minus 3 days, Search Console lags): days_remaining says how long, and the numbers are PARTIAL, do not conclude from them. status closed = both sides measured. status not_available + reason = no search_console source for the business unit, table_missing, no row at all, or no baseline. A side with no row has days_with_data 0 and null numbers: missing data is never 0. annotation_id keeps one annotation; an annotation with a url_id uses only that URL, otherwise every URL of the page. Scope: web search only, no country, no device (ADR-5 of plan 20261028-campaigns-paginas-seo). Source is always search_console; Umami is never mixed in. A before/after difference is a hint, not proof that the change caused it.
| Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The SEO page id (from list_seo_pages) |
annotation_id | string | no | Only this annotation (from get_seo_page); default every annotation of the page. |
window_days | number | no | Days on each side of the change, 7 to 90, default 28. Default: 28. |
list_seo_signals
Read-only. The daily SEO signals of ONE business unit, from campaigns.seo_signals read as the caller (viewer role on the business unit).read
list_seo_signalsSEO signals of a business unit (cannibalization, decay, striking distance, CTR gap)
Read-only. The daily SEO signals of ONE business unit, from campaigns.seo_signals read as the caller (viewer role on the business unit). The signals job in dfl-services writes them from Search Console; this tool reads ONE day (default: the newest day with a row), most severe first. Kinds: cannibalization (two or more pages of the same locale rank for one query), decay (28-day clicks fell to 0.7 times the 12-month peak or less, on two checks in a row), striking_distance (average position 4 to 15 with impressions at the business-unit percentile), ctr_gap (CTR below the business unit own curve at the same position). Every signal carries its evidence: the rule, the window, the numbers that crossed the threshold and the threshold itself, exactly as the job wrote them, and the formula_version. Filters: kind, page_id, locale. counts_by_kind counts the whole day (after the page_id and locale filters, before the kind filter), so an agent sees the other kinds too. has_more=true means call again with offset. Status ok, no_signals (the day has no row for the filters), not_available (table missing) or unknown (no viewer role). A day with no row is not proof that the page is healthy: A signal row is written only when a rule fires, so no row can mean "nothing fired" or "the job has not run / there is no Search Console data". Check get_seo_source_status before you read "no row" as "healthy". This tool only reads. It confirms nothing and changes no page; the thresholds are the job config, and the signals are hints for a person.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units) |
day | string | no | Signal day, YYYY-MM-DD (default: the newest day with a signal row) |
kind | enum | no | Only this kind (default: every kind) One of: cannibalization, decay, striking_distance, ctr_gap. |
page_id | string | no | Only the signals of this SEO page (from list_seo_pages) |
locale | string | no | Only this locale, for example pt-BR. |
limit | number | no | Signals per call, default 50. |
offset | number | no | Signals to skip, default 0. |
ingest_seo_pages_from_sitemap
Read a sitemap XML (a urlset, or a sitemap index of urlsets) and turn its URLs into logical SEO pages of ONE business unit: the URLs that name each other as xhtml:link rel="alternate" hreflang are ONE page with one URL…write
ingest_seo_pages_from_sitemapImport SEO pages from a sitemap
Read a sitemap XML (a urlset, or a sitemap index of urlsets) and turn its URLs into logical SEO pages of ONE business unit: the URLs that name each other as xhtml:link rel="alternate" hreflang are ONE page with one URL per locale (locale from the hreflang; x-default keeps the locale of the URL it duplicates, or default_locale). dry_run=true (the DEFAULT) fetches and groups but writes NOTHING: it answers the page and URL counts and the grouping, with the action a real run would take per page. dry_run=false inserts the pages with status inventory_draft and their URLs, as the caller (RLS: editor of the business unit). It is idempotent on (business_unit_id, url_key): a URL that exists is skipped; a cluster with new URLs next to one existing page attaches them to it; a cluster that spans two existing pages is a conflict and is skipped. Titles come from the URL path; fix them with update_seo_page. The site root gets page_type home, every other page default_page_type. Run the dry run first and read warnings.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units). The real run needs the editor role on it. |
sitemap_url | string | yes | The sitemap URL (sitemap.xml or a sitemap index) |
dry_run | boolean | no | true (default) groups and reports without any write; false inserts. Default: true. |
default_locale | string | no | The locale of a URL that no hreflang names. Default pt-BR. Default: "pt-BR". |
default_page_type | enum | no | page_type of every page that is not the site root (the root is home). Default article. One of: article, question, landing, home, category, other. Default: "article". |
max_pages | number | no | Stop after this many logical pages (default 500, max 2000). The answer says when the cap hit. Default: 500. |
create_seo_page
Create ONE logical SEO page of a business unit by hand (a page the sitemap does not list, or a page planned before it exists), with its URLs, one per locale.write
create_seo_pageCreate one SEO page
Create ONE logical SEO page of a business unit by hand (a page the sitemap does not list, or a page planned before it exists), with its URLs, one per locale. Written as the caller: you need the editor role on the business unit. Status starts as inventory_draft unless you pass active. A URL whose url_key (no scheme, www, query or trailing slash) already exists in the unit is refused: read list_seo_pages first, or use ingest_seo_pages_from_sitemap, which skips what exists. No keyword is linked here: use add_keyword_link_suggestions. Nothing here confirms anything.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units). You need the editor role on it. |
title | string | yes | The page title (the question it answers) |
page_type | enum | no | article (default), question, landing, home, category, other. One of: article, question, landing, home, category, other. |
status | enum | no | inventory_draft (default) or active. One of: inventory_draft, active. |
notes | string | no | Free notes for the team. |
urls | object[] | no | The URLs of the page, one per locale (at most 20). URLs are added here or by the sitemap import; update_seo_page does not change them. |
update_seo_page
Change the title, page_type, status or notes of ONE SEO page, as the caller (RLS: editor of the business unit).write
update_seo_pageUpdate one SEO page
Change the title, page_type, status or notes of ONE SEO page, as the caller (RLS: editor of the business unit). Every UPDATE leaves a version in seo_pages_history. There is NO delete: a page leaves by status archived, or by status consolidated with consolidated_into_page_id (the page of the same business unit that now answers the question). Omitted fields keep their value; notes=null clears the notes. URLs and keyword links are not changed here.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The SEO page id (from list_seo_pages) |
title | string | no | — |
page_type | enum | no | article, question, landing, home, category, other. One of: article, question, landing, home, category, other. |
status | enum | no | inventory_draft, active, archived, or consolidated (with consolidated_into_page_id) One of: inventory_draft, active, consolidated, archived. |
consolidated_into_page_id | string | no | With status consolidated only: the page that absorbs this one (same business unit) |
notes | string | no | Free notes; null clears them. |
add_keyword_link_suggestions
SUGGEST that ONE SEO page targets one or more keywords: it inserts seo_page_keywords rows with status suggested ONLY, as the caller (RLS: editor of the business unit).write
add_keyword_link_suggestionsPropose keyword links for a SEO page
SUGGEST that ONE SEO page targets one or more keywords: it inserts seo_page_keywords rows with status suggested ONLY, as the caller (RLS: editor of the business unit). A person confirms or rejects each suggestion in dfl-campaigns; no tool on this server confirms, rejects or weighs a link. reason is REQUIRED and is the one text the reviewer reads: say what in the page and in the keyword makes the match. Refused before any write: an empty reason, a keyword of ANOTHER business unit, an unknown keyword, and a (page, keyword) pair a person already REJECTED (a rejection is a decision). A pair that is already suggested or confirmed is skipped and reported. All or nothing: one refusal writes no row. AUTHOR: suggested_by stays the token user (RLS); in a connector (OAuth) session whose grant acts as an agent, each new row ALSO records that agent in public.actor_links (linked_table 'campaigns.seo_page_keywords'), written first: if the database refuses that link, nothing is saved.
| Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The SEO page id (from list_seo_pages) |
links | object[] | yes | The keywords to propose (1 to 50) |
reason | string | yes | Why these keywords fit this page, for the person who decides. Required. |
add_seo_page_annotation
Append ONE business milestone to a SEO page (published, rewritten, title_changed, redirected, merged, ...): what happened and WHEN it happened (occurred_at, the business date, not now), optionally on one URL of the page…write
add_seo_page_annotationAdd an annotation to a SEO page
Append ONE business milestone to a SEO page (published, rewritten, title_changed, redirected, merged, ...): what happened and WHEN it happened (occurred_at, the business date, not now), optionally on one URL of the page and linked to a work.hypotheses row. Annotations are append-only: no tool edits or removes one, and the database has no UPDATE or DELETE for them. Written as the caller (RLS: editor of the business unit). They show on the traffic charts.
| Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The SEO page id (from list_seo_pages) |
kind | string | yes | What happened: published, rewritten, title_changed, redirected, merged, or another lowercase snake_case word. |
occurred_at | string | yes | When it happened, ISO 8601 with offset (the business date) |
note | string | no | Detail for the team. |
url_id | string | no | One URL of this page the milestone is about (from get_seo_page); omitted means the whole page. |
hypothesis_id | string | no | The work.hypotheses row this milestone belongs to (from list_hypotheses) |
register_analytics_source
Write one row of the source registry campaigns.analytics_sources as the caller: you need the editor role on the business unit (or be a global admin).write
register_analytics_sourceRegister one analytics source of a business unit
Write one row of the source registry campaigns.analytics_sources as the caller: you need the editor role on the business unit (or be a global admin). A source is one external account the dfl-campaigns-ingest collectors read: a Search Console property (kind search_console, external_ref such as sc-domain:iterahq.dev), an Umami site, a GA4 property, a Google Ads customer. A contacts source (kind contacts, external_ref a stable emitter name such as itera-api) receives a signed contacts webhook; it takes no site_role and no currency. The row is always created DISABLED and with no credential reference: no collector runs for it until an operator turns it on with the ingest CLI (bun run sources:enable <source_id>), and the credential lives in the ingest environment, never here. The key is (kind, external_ref): calling again with the same pair in the same business unit changes nothing and returns the row (action unchanged). A source is never moved to another business unit and this tool never updates or deletes one. Read the registry with get_seo_source_status. Data goes by this tool, never by a migration seed.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | Business unit uuid (from list_post_business_units). You need the editor role on it. |
kind | enum | yes | The source kind, for example search_console. One of: google_ads, umami, clarity, billing, youtube, ga4, search_console, contacts. |
external_ref | string | yes | The id of the account at the provider: sc-domain:iterahq.dev, a Umami site uuid, a GA4 property id. |
label | string | yes | A human name, for example "Itera - Search Console". |
site_role | enum | no | Only for a web source: landing or app. Not for contacts. One of: landing, app. |
timezone | string | no | IANA timezone of the source days. Default America/Sao_Paulo. |
currency | string | no | Only for a source that carries money. Not for contacts. |
config | object | no | Source settings (for search_console, config.site_url may replace external_ref). Never put a secret here. |
upsert_seo_page_rewrite
Put the rewrite of ONE SEO page on the Curadoria board of /posts/pautas in the column "Aguardando aprovação" (awaiting_approval), for a person to approve.write
upsert_seo_page_rewritePut a page rewrite in the approval column (create or update)
Put the rewrite of ONE SEO page on the Curadoria board of /posts/pautas in the column "Aguardando aprovação" (awaiting_approval), for a person to approve. It publishes nothing and it has no status argument: the card always lands in that column, and a person moves it out. The card is titled "Reescrita SEO: <page title>", belongs to the page's business unit and carries the page URLs as reference links. A rewrite up to 4200 characters goes into the card text. A longer one (up to 200000) needs document_url: first store the full text with upload_file and pass its link; the card keeps the start of the text and the link. Call it again for the same page and it updates the same card (no duplicate). Run get_seo_page first to read the page. A rewrite leaves awaiting_approval ONLY by a person: no agent moves the card out of that column and no agent publishes a rewrite. A refusal says do not retry unchanged; only a temporary failure may be retried.
| Parameter | Type | Required | Description |
|---|---|---|---|
page_id | string | yes | The SEO page id (from list_seo_pages) |
rewrite | string | yes | The rewritten page text, markdown, in the page language. |
document_url | string | no | Link to the full text stored with upload_file. Required when rewrite is over 4200 characters. |
note | string | no | One short note for the reviewer: what changed and why. |
The sales CRM of DFL (campaigns.crm_*, plan 20261103-crm-twenty-into-campaigns): companies, contacts,
deals on a kanban pipeline. Every tool runs with your JWT; RLS lets a DFL member read and write.
external_id is the CNPJ as 14 digits and legal_rep_cpf is 11 digits; a mask is removed and another length is refused.
With twenty_id the upsert tools write on that key, so an import can run again without duplicates.
There is no activities table: a note or a task is a markdown block in the notes column.
add_crm_note adds one block and is idempotent on source_ref; update_crm_notes replaces the text and needs
expected_updated_at. archive_crm_company is a soft delete.
A file of any size (also over the 6 MB limit of upload_file, up to 100 MB) takes two steps:
create_crm_file_upload returns a presigned S3 PUT URL for a private object, you PUT the bytes, then
add_crm_attachment with media_id and upload_key registers the media row and links it to a company, deal or contact.
The S3 key stays in dfl-render; this host forwards your JWT only.
remove_crm_attachment with an attachment_id detaches a file (archives the link row, the row is kept with deleted_at set); it never deletes the media row or the stored object.
The sales CRM of DFL: companies, contacts, deals on a kanban pipeline, markdown notes and tasks. Find which CNPJs are already Leads. Writes are upserts, so an import can run again.
list_crm_pipeline_stages
The CRM sales stages (kanban columns) ordered by position: key, label, position, kind (open, won or lost).read
list_crm_pipeline_stagesList CRM pipeline stages
The CRM sales stages (kanban columns) ordered by position: key, label, position, kind (open, won or lost). Use the keys with list_crm_deals, upsert_crm_deal and set_crm_deal_stage. Edit them with upsert_crm_pipeline_stage.
Takes no parameters.
upsert_crm_pipeline_stage
Upsert one sales stage on key (upper-case letters, digits and underscore, e.g. MEETING).write
upsert_crm_pipeline_stageCreate or update a CRM pipeline stage
Upsert one sales stage on key (upper-case letters, digits and underscore, e.g. MEETING). label is the display name, position orders the kanban columns, kind is open, won or lost. A rename of the label needs no migration. Read the stages with list_crm_pipeline_stages.
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | yes | — |
label | string | yes | — |
position | number | yes | — |
kind | enum | yes | One of: open, won, lost. |
list_crm_companies
The CRM companies (campaigns.crm_companies), by name.read
list_crm_companiesList CRM companies
The CRM companies (campaigns.crm_companies), by name. Each row carries stage_key (the stage of the latest OPEN deal, null when none) and the counts of contacts, deals and attachments. search matches name, legal name and CNPJ. stage_key keeps only the companies that have a deal in that stage. has_cnpj true/false filters on the CNPJ being set. Page with limit (max 200) and offset. One company in full: get_crm_company. The stages: list_crm_pipeline_stages. Archived companies are not listed.
| Parameter | Type | Required | Description |
|---|---|---|---|
search | string | no | Part of the name, legal name or CNPJ. |
stage_key | string | no | Pipeline stage key, e.g. MEETING. |
has_cnpj | boolean | no | — |
limit | number | no | Default: 50. |
offset | number | no | Default: 0. |
get_crm_company
One CRM company with its contacts, its deals (each with stage_key and stage_label), its attachments (media_id, name, mime_type) and its notes markdown.read
get_crm_companyGet one CRM company
One CRM company with its contacts, its deals (each with stage_key and stage_label), its attachments (media_id, name, mime_type) and its notes markdown. Identify it with exactly one of id, twenty_id (the id in the old Twenty CRM) or external_id (the CNPJ, with or without mask). Returns company: null when none matches. To write notes use add_crm_note; to find companies use list_crm_companies.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | no | — |
twenty_id | string | no | — |
external_id | string | no | CNPJ, 14 digits or masked. |
upsert_crm_company
Write one CRM company. With id: update that row.write
upsert_crm_companyCreate or update a CRM company
Write one CRM company. With id: update that row. With twenty_id (and no id): upsert on twenty_id, so an import can run again without duplicates. With neither: insert. A new company needs name. external_id is the CNPJ (14 digits; a mask is removed; other lengths are refused) and is unique among live companies. legal_rep_cpf is 11 digits. updated_at is set to now() unless you give it; created_at/updated_at may be given so an import keeps the Twenty timestamps. An omitted field keeps its value; null clears a nullable one. Notes are not written here: use add_crm_note. Remove a company with archive_crm_company.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | no | — |
twenty_id | string | no | — |
name | string | no | — |
legal_name | string | no | Omit to keep the stored value; null clears it. |
external_id | string | no | CNPJ. Omit to keep the stored value; null clears it. |
person_id | string | no | campaigns.persons id of the Leads row. Omit to keep the stored value; null clears it. |
links | object | no | Same keys as campaigns.persons.links (site, linkedin, ...) |
emails | object | no | {principal, financeiro, representante}. |
address | object | no | {street, number, complement, district, city, state, cep, country}. |
legal_rep_name | string | no | Omit to keep the stored value; null clears it. |
legal_rep_cpf | string | no | CPF, 11 digits. PII. Omit to keep the stored value; null clears it. |
owner_id | string | no | auth user id. Omit to keep the stored value; null clears it. |
created_at | string | no | — |
updated_at | string | no | — |
archive_crm_company
Soft delete: sets deleted_at on the company, so it disappears from every CRM tool; the row and its history stay in the database.write
archive_crm_companyArchive a CRM company
Soft delete: sets deleted_at on the company, so it disappears from every CRM tool; the row and its history stay in the database. cascade_deals true archives its deals too (default false: the deals stay and keep the company id). The archived company is not read back (it no longer passes RLS), so the answer carries only the id and the number of archived deals. A person restores a company in the database.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | — |
cascade_deals | boolean | no | Default: false. |
upsert_crm_contact
Write one CRM contact (a person of a company).write
upsert_crm_contactCreate or update a CRM contact
Write one CRM contact (a person of a company). With id: update. With twenty_id (no id): upsert on twenty_id. With neither: insert. A new contact needs name. company_id may be null for a contact with no company. emails/phones keep the Twenty shape ({primaryEmail, additionalEmails[]} and {primaryPhoneNumber, ...}). created_at/updated_at may be given for an import. Notes: add_crm_note.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | no | — |
twenty_id | string | no | — |
company_id | string | no | crm_companies id. Omit to keep the stored value; null clears it. |
name | string | no | — |
job_title | string | no | Omit to keep the stored value; null clears it. |
emails | object | no | — |
phones | object | no | — |
links | object | no | — |
city | string | no | Omit to keep the stored value; null clears it. |
created_at | string | no | — |
updated_at | string | no | — |
list_crm_deals
The CRM deals, ordered by stage position and then deal position (the kanban order).read
list_crm_dealsList CRM deals
The CRM deals, ordered by stage position and then deal position (the kanban order). Filter by stage_key and/or company_id. Each deal carries stage_key and stage_label. Move one with set_crm_deal_stage; write one with upsert_crm_deal.
| Parameter | Type | Required | Description |
|---|---|---|---|
stage_key | string | no | — |
company_id | string | no | — |
upsert_crm_deal
Write one CRM deal (opportunity).write
upsert_crm_dealCreate or update a CRM deal
Write one CRM deal (opportunity). With id: update. With twenty_id (no id): upsert on twenty_id. With neither: insert. A new deal needs a stage: give stage_key (e.g. NEW) or stage_id, not both; an unknown stage is refused with the list of known keys. amount is in MAJOR units (1500.50) and needs a 3-letter currency (BRL, USD). name may be empty. position orders the deal inside its column. created_at/updated_at may be given for an import. To change only the stage, set_crm_deal_stage is simpler. Notes: add_crm_note.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | no | — |
twenty_id | string | no | — |
company_id | string | no | crm_companies id. Omit to keep the stored value; null clears it. |
name | string | no | Omit to keep the stored value; null clears it. |
stage_key | string | no | — |
stage_id | string | no | — |
amount | number | no | Major units. Omit to keep the stored value; null clears it. |
currency | string | no | — |
close_date | string | no | — |
point_of_contact_id | string | no | — |
position | number | no | — |
created_at | string | no | — |
updated_at | string | no | — |
set_crm_deal_stage
Change the stage of one deal: give stage_key or stage_id (exactly one).write
set_crm_deal_stageMove a CRM deal to another stage
Change the stage of one deal: give stage_key or stage_id (exactly one). position is the place inside the target column; when omitted the deal goes to the end. The answer is the deal with its new stage_key. The stages: list_crm_pipeline_stages. Other deal fields: upsert_crm_deal.
| Parameter | Type | Required | Description |
|---|---|---|---|
deal_id | string | yes | — |
stage_key | string | no | — |
stage_id | string | no | — |
position | number | no | — |
add_crm_note
Append ONE markdown block to the notes text of a company, a deal or a contact (there is no activities table).write
add_crm_noteAppend one note or task block to a CRM record
Append ONE markdown block to the notes text of a company, a deal or a contact (there is no activities table). Identify the target with target + exactly one of id or twenty_id. The block is: a header line "### YYYY-MM-DD · author · note" (or "task (STATUS)", plus " · contact: name"), an optional title line, the body, and an optional "<!-- source:REF -->" line. Blocks are separated by one blank line. Idempotent: when source_ref is given and its marker is already in the notes, nothing is written and the answer is {appended:false}. So an import can run again. A concurrent edit is handled with an optimistic lock on updated_at and up to 3 retries. To replace the whole text use update_crm_notes. A note of a contact that has a company goes to the company (target "company") with contact_name set.
| Parameter | Type | Required | Description |
|---|---|---|---|
target | enum | yes | One of: company, deal, contact. |
id | string | no | — |
twenty_id | string | no | — |
body_markdown | string | yes | — |
title | string | no | — |
author | string | yes | — |
occurred_at | string | yes | ISO date-time; only the date goes in the header. |
kind | enum | yes | One of: note, task. |
task_status | string | no | For kind task, e.g. TODO, IN_PROGRESS, DONE. |
contact_name | string | no | — |
source_ref | string | no | Stable id of the origin (e.g. twenty:note:<uuid>). Makes the call idempotent. |
update_crm_notes
Replace the entire notes text of one company, deal or contact.write
update_crm_notesReplace the whole notes text of a CRM record
Replace the entire notes text of one company, deal or contact. expected_updated_at is the updated_at you read with the notes (get_crm_company, or the answer of add_crm_note): the write happens only if the row still has that value, and fails with a clear error if somebody changed it. Then read again and merge. To add one block without replacing, use add_crm_note. Pass an empty string to clear the notes.
| Parameter | Type | Required | Description |
|---|---|---|---|
target | enum | yes | One of: company, deal, contact. |
id | string | yes | — |
notes | string | yes | — |
expected_updated_at | string | yes | — |
create_crm_file_upload
Step 1 of 2 to attach a file of ANY size (also over the 6 MB limit of upload_file, up to 100 MB) to a CRM company, deal or contact.write
create_crm_file_uploadCreate a signed upload for a CRM file
Step 1 of 2 to attach a file of ANY size (also over the 6 MB limit of upload_file, up to 100 MB) to a CRM company, deal or contact. Returns media_id, key, upload_url, headers and expires_at (15 minutes). Then PUT the raw bytes to upload_url with exactly these headers and a Content-Length equal to size_bytes, for example curl -fsS -X PUT -H 'Content-Type: <content_type>' -T <file> '<upload_url>'. S3 refuses any other size or type. Step 2: add_crm_attachment with media_id and upload_key = key. The file is private (visibility private, or members); its link is https://media.devfellowship.com/<media_id>. The upload_url is a short-lived capability: do not print it, log it or store it.
| Parameter | Type | Required | Description |
|---|---|---|---|
file_name | string | yes | Original file name, e.g. "Contrato TerraVitta.pdf". |
size_bytes | number | yes | Exact byte size of the file. |
content_type | string | no | MIME type. Omit to derive it from the extension. |
visibility | enum | no | One of: private, members. Default: "private". |
add_crm_attachment
Write one campaigns.crm_attachments row that links a public.media file to a company, a deal and/or a contact (give at least one).write
add_crm_attachmentAttach a file to a CRM company, deal or contact
Write one campaigns.crm_attachments row that links a public.media file to a company, a deal and/or a contact (give at least one). After create_crm_file_upload and the PUT, pass upload_key: the tool first checks the stored object and registers its media row with your JWT, then attaches it. For a file you uploaded with upload_file, pass only its media_id. name defaults to the uploaded file name (required without upload_key). With twenty_id: upsert on twenty_id, so an import can run again. Without it, the same media on the same target is returned as it is (created: false). get_crm_company lists the files.
| Parameter | Type | Required | Description |
|---|---|---|---|
media_id | string | yes | public.media id (from create_crm_file_upload or upload_file). |
upload_key | string | no | — |
company_id | string | no | — |
deal_id | string | no | — |
contact_id | string | no | — |
name | string | no | — |
file_category | string | no | e.g. TEXT_DOCUMENT, IMAGE, PRESENTATION (Twenty fileCategory). |
twenty_id | string | no | Attachment id in the old Twenty CRM: the import key. |
created_at | string | no | — |
updated_at | string | no | — |
remove_crm_attachment
Detach one file: archives one campaigns.crm_attachments link row (deleted_at is set, the row is kept), so it disappears from get_crm_company and attachments_count.write
remove_crm_attachmentRemove a file from a CRM company, deal or contact
Detach one file: archives one campaigns.crm_attachments link row (deleted_at is set, the row is kept), so it disappears from get_crm_company and attachments_count. It never deletes the public.media row or the stored object: the file and its https://media.devfellowship.com/<media_id> link stay valid for anything else that uses them, such as a scheduled post. Give the attachment id (get_crm_company lists them), not the media id. Runs with your JWT: it refuses when you cannot see the row or have no write access. Returns the removed row as it was read, with deleted_at set to the time of the removal. To attach the same file again, call add_crm_attachment.
| Parameter | Type | Required | Description |
|---|---|---|---|
attachment_id | string | yes | campaigns.crm_attachments id (the id of an item in get_crm_company attachments), not a media id. |
check_cnpj_leads
Check up to 200 CNPJs against the Leads data of dfl-campaigns (GET /api/leads/by-ids, with your session).read
check_cnpj_leadsFind which CNPJs are Leads
Check up to 200 CNPJs against the Leads data of dfl-campaigns (GET /api/leads/by-ids, with your session). Each CNPJ is normalised to 14 digits (mask removed); an item with another length is listed in invalid and not sent. The answer: matched (one row per CNPJ found: cnpj as 14 digits, razao_social, nome_fantasia, uf, municipio, situacao_cadastral) and unmatched (CNPJs with no lead). When the Leads source is down the tool fails with its error. Use it before upsert_crm_company to fill person_id or to see which CRM companies are not Leads yet. It writes nothing.
| Parameter | Type | Required | Description |
|---|---|---|---|
cnpjs | string[] | yes | — |
Agenda settings
Section titled “Agenda settings”The settings of your own daily pautas agenda (“Hoje”), one row per user in campaigns.agenda_settings
(plan 20261110-campaigns-pautas-daily-agenda, task S1).
get_agenda_settings returns your row, or the defaults (agenda off) with configured: false.
set_agenda_settings creates or changes it: enabled, timezone (IANA name), run_at_local (HH:MM),
keyword_bu_ids (replaces the list), build_in_public_bu_id and github_login (null clears them).
A key that you leave out stays as it is. Both tools run with your JWT and RLS lets you touch only your own row,
so there is no user_id argument. A row is never deleted: set enabled to false.
Read and set your own daily pautas agenda: on or off, time zone, run time, the business units that get a keyword pauta, and the GitHub login for build-in-public.
get_agenda_settings
Read-only. The daily pautas agenda ("Hoje") settings of the CALLER: enabled, timezone, run_at_local (HH:MM, local time of the timezone), keyword_bu_ids (business units that get a keyword pauta each day)…read
get_agenda_settingsGet my daily agenda settings
Read-only. The daily pautas agenda ("Hoje") settings of the CALLER: enabled, timezone, run_at_local (HH:MM, local time of the timezone), keyword_bu_ids (business units that get a keyword pauta each day), build_in_public_bu_id and github_login (the login whose merged PRs feed the build-in-public pautas). configured is false when the caller never saved settings: then settings holds the defaults (agenda off). It reads only the caller's own row (RLS); there is no way to read another person's settings.
Takes no parameters.
set_agenda_settings
Write. Create or change the daily pautas agenda settings of the CALLER (one row per user; keys that you leave out stay as they are, and a new row starts from the defaults: enabled false, America/Sao_Paulo, 06:00).write
set_agenda_settingsSet my daily agenda settings
Write. Create or change the daily pautas agenda settings of the CALLER (one row per user; keys that you leave out stay as they are, and a new row starts from the defaults: enabled false, America/Sao_Paulo, 06:00). Pass at least one key. enabled turns the agenda on or off. timezone is an IANA name. run_at_local is HH:MM (24 h). keyword_bu_ids replaces the whole list (up to 20 business unit uuids, from list_post_business_units). build_in_public_bu_id and github_login take null to clear them. Answers the saved row. It writes only the caller's own row (RLS); it cannot change another person's settings and it cannot delete the row (set enabled false instead).
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled | boolean | no | true turns the daily agenda on for the caller. |
timezone | string | no | IANA time zone, for example America/Sao_Paulo. |
run_at_local | string | no | Local time of day when the agenda runs, HH:MM. |
keyword_bu_ids | string[] | no | Business unit uuids that get a keyword pauta each day (replaces the list) |
build_in_public_bu_id | string | no | Business unit uuid that gets the build-in-public pautas; null clears it. |
github_login | string | no | GitHub login whose merged PRs feed build-in-public; null clears it. |
Short links
Section titled “Short links”Our own link shortener at https://go.iterahq.dev/<code> (campaigns.short_links, plan 20261105-go-iterahq-shortener).
Use a short link for every iterahq.dev link in a video description, a caption or a first comment.
create_short_link takes an iterahq.dev url and utm_source, utm_medium, utm_campaign (plus optional
utm_content, utm_term), puts the UTM parameters into the stored target, and returns short_url.
The target must be https on iterahq.dev or a subdomain, so the host is never an open redirect.
A link is not edited: archive_short_link switches it off (404) and you create a new one.
list_short_links returns each link with click_count (redirects served, not unique people).
Every tool runs with your JWT; RLS lets a DFL member read and write.
Make go.iterahq.dev short links with the UTM tags inside, see how many clicks each one got, and switch a link off.
create_short_link
Create a short link https://go.iterahq.dev/<code> for an iterahq.dev page, with the UTM parameters baked into the stored target (the short link itself stays clean).write
create_short_linkCreate a go.iterahq.dev short link
Create a short link https://go.iterahq.dev/<code> for an iterahq.dev page, with the UTM parameters baked into the stored target (the short link itself stays clean). Use it for every iterahq.dev link in a video description, a caption or a first comment. url must be https on iterahq.dev or a subdomain. With youtube_video_id (11 characters, the video the link is printed in) the UTM is built from the video: utm_source=youtube, utm_medium=placement (description, pinned_comment or shorts_caption), utm_campaign=video_slug, utm_content=channel_handle, no utm_term. Send placement, video_slug and channel_handle instead of utm_*; a utm_* on a video link is refused. Any other link takes free-form utm_source, utm_medium and utm_campaign (required), with optional utm_content and utm_term. With no code, a random 6-character code is generated. A link cannot be edited later: disable it and create a new one (archive_short_link). A UTM set already used by another live link is refused. Returns short_url, code, the exact target_url and youtube_video_id.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | yes | The destination, e.g. https://iterahq.dev/hackathon. |
utm_source | string | no | Non-video links only. Where the click comes from, e.g. instagram, tiktok, linkedin. |
utm_medium | string | no | Non-video links only. The kind of placement, e.g. caption, first_comment, bio. |
utm_campaign | string | no | Non-video links only. The campaign, e.g. hackathon-2026-11. |
utm_content | string | no | Non-video links only. Optional: which post, e.g. its slug. |
utm_term | string | no | Non-video links only. Optional: a keyword. |
placement | enum | no | Video links: where the link is printed (description, pinned_comment or shorts_caption); becomes utm_medium. One of: description, pinned_comment, shorts_caption. |
video_slug | string | no | Video links: the slug of the video; becomes utm_campaign. |
channel_handle | pipeline | no | Video links: the YouTube channel handle; becomes utm_content. |
code | string | no | Optional custom code (the path after go.iterahq.dev/). Omit for a random one. |
label | string | no | Optional note for people, e.g. the video title. |
youtube_video_id | string | no | Optional: the YouTube video this link is printed in, e.g. dQw4w9WgXcQ. |
list_short_links
List go.iterahq.dev short links, newest first, each with short_url, target_url, label and click_count (redirects served, not unique people) and youtube_video_id.read
list_short_linksList go.iterahq.dev short links
List go.iterahq.dev short links, newest first, each with short_url, target_url, label and click_count (redirects served, not unique people) and youtube_video_id. search matches code, label or target_url. Disabled links are hidden unless include_disabled is true.
| Parameter | Type | Required | Description |
|---|---|---|---|
search | string | no | Substring of code, label or target_url. |
include_disabled | boolean | no | Also list disabled links. |
limit | number | no | Max rows (default 50) |
archive_short_link
Archive a short link by code (sets disabled_at): go.iterahq.dev/<code> answers 404 within about a minute.write
archive_short_linkArchive (disable) a go.iterahq.dev short link
Archive a short link by code (sets disabled_at): go.iterahq.dev/<code> answers 404 within about a minute. The row and its clicks stay. An archived link is not restored; create a new link instead.
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | yes | The code to archive. |
set_short_link_video
Set (or clear) the youtube_video_id of a go.iterahq.dev short link by code.write
set_short_link_videoSet the YouTube video of a short link
Set (or clear) the youtube_video_id of a go.iterahq.dev short link by code. Use it for a link that is already printed in a YouTube video description: the target of a link never changes, and this id is what ties a lead's first-touch UTM to the video. youtube_video_id is the 11-character id (the v= value of the video URL), or null to clear it. The same id writes nothing. Returns code, short_url, youtube_video_id and changed.
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | yes | The code of the link. |
youtube_video_id | string | yes | The 11-character YouTube video id, or null to clear. |
Contacts
Section titled “Contacts”The people who gave an e-mail to a business unit (BU) (plan 20261021-campaigns-contacts-itera-leads, tables
campaigns.contacts and campaigns.contact_activities). One contact is one person in ONE BU; the same person in
two BUs is two contacts. The dfl-campaigns-ingest receiver writes the e-mail, the profile, the lifecycle and the consents.
list_contacts filters by BU, lifecycle (lead, subscriber, past_due, canceled, or the Portuguese names
assinante, inadimplente, cancelado), owner and a search text; erased contacts are not listed.
get_contact shows one contact_id with its manual tags, e-mail consent, suppression and timeline.
The lifecycle (shown as itera:assinante and so on) belongs to its source and is read-only.
set_contact_tags changes manual tags only (no :). set_contact_owner sets the owner (Responsável).
set_contact_suppression marks the contact do-not-contact; there is no tool to lift it.
Every tool runs with your JWT: a BU viewer reads, and a BU editor writes.
Find the people on a business unit list, see their tags, consent and timeline, set the owner, add manual tags, and mark a person do-not-contact.
list_contacts
List contacts, newest seen first.read
list_contactsList contacts
List contacts, newest seen first. One contact is one person in one business unit (BU); the same person in two BUs is two contacts. Each row has contact_id, email, full_name, business_unit_id, source (the feed that created it), lifecycle (lead, subscriber, past_due or canceled), cycle (the same state in Portuguese: lead, assinante, inadimplente, cancelado), tags (manual tags), owner_user_id, last_seen_at, suppressed and outbound_status (the latest outbound activity: outbound_drafted, outbound_sent, reply_received or opt_out; null when none). Erased contacts are not listed. Filters: business_unit_id, lifecycle (the Portuguese names work too), owner_user_id, and q (part of the e-mail or of the name). Page with limit (max 200) and offset. The call runs with your own login, so row-level security shows only the BUs where you are a viewer or a global admin. One contact in full: get_contact.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | no | Only this business unit. |
lifecycle | string | no | lead, subscriber, past_due or canceled (or assinante, inadimplente, cancelado) |
owner_user_id | string | no | Only the contacts that this user owns. |
q | string | no | Part of the e-mail or of the name. |
limit | number | no | Default: 50. |
offset | number | no | Default: 0. |
get_contact
One contact, by contact_id (from list_contacts): the profile, lifecycle, manual tags, owner, the e-mail consent (the current state and its evidence), the suppression (suppressed, suppressed_at, suppression_reason) and…read
get_contactGet one contact
One contact, by contact_id (from list_contacts): the profile, lifecycle, manual tags, owner, the e-mail consent (the current state and its evidence), the suppression (suppressed, suppressed_at, suppression_reason) and the timeline (contact_activities, newest first, at most 100). Rows of kind touchpoint carry a label: a readable sentence for the journey step; the raw data stays. Row-level security applies with your own login. Returns contact: null when the contact does not exist, you cannot see it, or it was erased.
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | The contact_id from list_contacts. |
set_contact_tags
Add and remove MANUAL tags of one contact, by contact_id.write
set_contact_tagsAdd or remove manual tags of a contact
Add and remove MANUAL tags of one contact, by contact_id. A manual tag slug has no ":" (for example "vip" or "webinar-nov"): 1-80 characters, lower-case letters, digits, "_" and "-". A contact holds at most 50 tags. The lifecycle (lead, subscriber, past_due, canceled; shown as itera:assinante and so on) is read-only: a slug with ":" is refused, because only its source changes it. A tag already on the contact (add) or not on it (remove) is skipped and listed. A change is recorded as a tag_changed activity with you as the actor. You need the editor role on the BU; otherwise row-level security refuses the write.
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | The contact_id from list_contacts. |
add | string[] | no | Manual tag slugs to add. Default: []. |
remove | string[] | no | Manual tag slugs to remove. Default: []. |
set_contact_owner
Set the owner ("Responsavel") of one contact, by contact_id.write
set_contact_ownerSet the owner of a contact
Set the owner ("Responsavel") of one contact, by contact_id. owner_user_id is the auth user id of the person; pass null to clear it. Nothing happens when the owner is already that user (changed is false). A change is recorded as an owner_changed activity with you as the actor. You need the editor role on the BU; otherwise row-level security refuses the write.
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | The contact_id from list_contacts. |
owner_user_id | string | yes | Auth user id of the new owner, or null to clear. |
set_contact_suppression
Mark one contact do-not-contact, by contact_id: it sets suppressed_at and suppression_reason, and no marketing e-mail goes to it from its BU.write
set_contact_suppressionDo not contact a contact (suppress)
Mark one contact do-not-contact, by contact_id: it sets suppressed_at and suppression_reason, and no marketing e-mail goes to it from its BU. reason is manual (a person decided) or unsubscribed (the person asked). It is idempotent: when the contact is already suppressed, suppressed_now is false, the first reason stays, and nothing is written. A new suppression is recorded as a suppressed activity with you as the actor. You need the editor role on the BU; otherwise row-level security refuses the write. A bounce or a complaint is recorded by the receiver, not by this tool. There is no tool to lift a suppression.
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | The contact_id from list_contacts. |
reason | enum | yes | manual or unsubscribed. One of: manual, unsubscribed. |
erase_contact
Erase one contact for good, by contact_id, when the person asks for it (LGPD).write
erase_contactErase a contact (LGPD erasure on request)
Erase one contact for good, by contact_id, when the person asks for it (LGPD). It cannot be undone. The e-mail, phone, name, locale, first-touch UTM, consents, lifecycle, tags and the whole timeline are deleted. What stays has no personal data: the row as a tombstone (the e-mail hash, so a re-import stays suppressed), the suppression "erased", erased_at, and one erasure record (a suppressed activity, reason erased) with you as the actor. Afterwards get_contact returns null and list_contacts hides it. It is idempotent: an erased contact answers erased_now false and nothing is written. The dfl-campaigns-ingest service does the write with your own login, so row-level security decides: you need the editor role on the BU of the contact, or global admin. A viewer is refused (forbidden), and a contact you cannot see is not_found. Use set_contact_suppression instead when the person only asks not to be contacted.
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | The contact_id from list_contacts. |
Publishing rules
Section titled “Publishing rules”The publishing rules of a business unit (plan 20261105-content-process-plan-create-publish P4), the same rules
as the Configurações tab of the BU page in Campaigns. Slots are windows in local time per Zernio account (and
optionally per content kind). Cadence limits one account and one content kind: max_per_day and
min_gap_minutes (for example at most 1 Reel per day and 1200 minutes between two); it counts every post on that
account, from any BU. Default channels say which accounts a content kind goes to when nobody says.
get_next_free_slot returns the first window open on every account of the post that breaks no cadence rule, with a
random minute inside; pass scheduled_for to check a time (violations). set_publish_rules replaces whole lists;
only an editor of the BU or a global admin writes. The rules are computed in dfl-campaigns, never in SQL.
Read and set the publishing windows, the cadence and the default channels of a business unit, and get the next free publish time under those rules.
get_publish_rules
The publishing rules of one BU: slots (windows in local time; a post with no explicit time goes to a random minute of the next free window), cadence (per Zernio account and content kind: max_per_day and min_gap_minutes…read
get_publish_rulesRead the publishing rules of a business unit
The publishing rules of one BU: slots (windows in local time; a post with no explicit time goes to a random minute of the next free window), cadence (per Zernio account and content kind: max_per_day and min_gap_minutes, applied to every post on that account from any BU) and default_channels (the accounts a content kind goes to when nobody says). Also returns the mapped accounts (pickers) and can_edit. supported: false means the tables are not in the database yet (dfl-schema#1310 not merged): there are no rules, which is not the same as an empty rule set. Before you choose channels or a time for a post, read these rules and follow them.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | The business unit (from list_post_business_units) |
set_publish_rules
Replace the slots, the cadence rules and/or the default channels of one BU.write
set_publish_rulesReplace the publishing rules of a business unit
Replace the slots, the cadence rules and/or the default channels of one BU. Each list you send REPLACES that list for the BU (an empty list clears it); a list you omit stays as it is. Read get_publish_rules first and send the whole list back with your change. Every account must be mapped in campaigns.social_accounts (set_social_account_mapping). Only an editor of the BU or a global admin may write (403 otherwise). Runs with your JWT through dfl-campaigns, the same route as the Settings tab of the BU page. Example (Tainan, TG 27428): Instagram Reels 06:30–07:30, 12:00–14:00, 18:30–19:15; at most 1 Reel per day and 1200 minutes (20 h) between two; vertical-short goes to IG + TikTok of Tainan + YouTube of DevFellowship; long-video goes to YouTube only.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | The business unit (from list_post_business_units) |
slots | object[] | no | — |
cadence | object[] | no | — |
default_channels | object[] | no | — |
get_next_free_slot
The next free publish time of a post of one BU under its publishing rules: the first window that is open on every account of the post and breaks no cadence rule, with a random minute inside it.read
get_next_free_slotNext free publish time under the BU rules (and check a time)
The next free publish time of a post of one BU under its publishing rules: the first window that is open on every account of the post and breaks no cadence rule, with a random minute inside it. Omit zernio_account_ids to use the BU default channels of media_group (the answer names them). Pass scheduled_for to CHECK a time as well: violations lists each rule it breaks (outside_window, min_gap, max_per_day, with the post that holds the place) and ok is false. Pass post_id when you move an existing post, so it does not collide with itself. Posts in review, approved, sent or published hold their time; drafts do not. Use the returned scheduled_for in draft_post_for_review when the person gave no time. supported: false = the rules tables are not in the database yet. Read-only.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | The business unit (from list_post_business_units) |
media_group | enum | no | Content kind, the campaigns.posts.media_group vocabulary: vertical-short (Reel / Short / TikTok), long-video, micro-clips, ephemeral-daily (Stories), swipe-static (carousel / image). Also text (an X or LinkedIn post): a slot with media_group null applies to it, so pass text with the X account id to get the X slots. text has no default channels: pass zernio_account_ids. Required when zernio_account_ids is omitted. One of: vertical-short, long-video, micro-clips, ephemeral-daily, swipe-static, text. |
zernio_account_ids | string[] | no | The accounts the post goes out on. Omitted = the BU default channels of media_group. |
scheduled_for | string | no | A time to check, ISO 8601 with offset (e.g. "2026-11-08T19:00:00-03:00"). |
after | string | no | Look for a slot from this time on. |
post_id | string | no | The post being scheduled, if it exists. |
Test units
Section titled “Test units”cleanup_test_rows deletes the probe rows that speed tests and smokes leave on a test business unit (today only
Smoke Lab): disabled analytics_sources, seo_pages and the suggested links of seo_page_keywords, matched by a
case-insensitive name prefix. The default is a dry run: the service runs the deletes and rolls them back, so the
counts are those of the real run. The write lives in the cleanup_test_rows command of dfl-os-commands; the tool only
forwards it with your JWT. You need the editor role on the unit or a global admin, and the DELETE policies of
dfl-schema#1664 (true only for the test units) decide each row. max_rows (default 500) caps each target.
Clean up the probe rows that tests leave on a test business unit (Smoke Lab): a dry run first, then the delete.
cleanup_test_rows
Default is a DRY RUN: nothing is deleted.write
cleanup_test_rowsDelete the probe rows of a test business unit
Default is a DRY RUN: nothing is deleted. Pass dry_run:false to delete. Deletes the probe rows that tests leave on a TEST business unit only (Smoke Lab (d32d7385-ae90-4e50-98f4-ac7f8cccb4bf)); any other unit is refused (not_a_test_unit). Targets: analytics_sources, seo_pages, seo_page_keywords (suggested links), analytics_targets. Rows match by a case-insensitive name PREFIX. Runs with your JWT in one transaction: you must be an editor of the unit or a global admin (else not_editor), and the database policies decide each row. max_rows (default 500) caps each target: more matches refuse the whole call (too_many_rows). The answer lists, per target: matched, deleted (in a dry run: would delete), remaining, up to 5 sample names, and the refused sources (has_dependent_rows, rls_refused). Do a dry run first, read the counts, then delete.
| Parameter | Type | Required | Description |
|---|---|---|---|
business_unit_id | string | yes | The test business unit. Only these are accepted: Smoke Lab (d32d7385-ae90-4e50-98f4-ac7f8cccb4bf). |
targets | enum[] | yes | The tables to clean. analytics_sources: label or external_ref starts with a prefix. seo_pages: title starts with a prefix (its links go with it). seo_page_keywords: the links with status "suggested" on the pages whose title starts with a prefix (the pages stay). analytics_targets: the note starts with a prefix. |
name_prefixes | string[] | yes | 1 to 10 name prefixes, 3 to 80 characters each. Case-insensitive PREFIX match; % and _ are literal. |
dry_run | boolean | no | Default true: a DRY RUN, nothing is deleted. Pass dry_run:false to delete. Default: true. |
max_rows | number | no | Per target, 1 to 2000 (default 500). A target that matches more refuses the whole call; nothing is deleted. Default: 500. |
Session
Section titled “Session”See which actor, OAuth client and scope this connection uses on this host.
get_current_actor
Returns who this MCP session acts as on this host: actor {id, slug, display_name, type}, client {id, name} (the OAuth client; name is null when the provider does not show it), scope ("read" or "read+write"), and source.read
get_current_actorGet Current Actor
Returns who this MCP session acts as on this host: actor {id, slug, display_name, type}, client {id, name} (the OAuth client; name is null when the provider does not show it), scope ("read" or "read+write"), and source. source "oauth_grant": an OAuth session, the actor is the grant actor (null when the grant has no actor, which makes the session read-only). source "agent_login": a first-party dfl-auth login of an agent user; the actor is that user's own agent actor, client and scope are null. source "first_party_login": a first-party login with no own agent actor (a human user); all three are null. source "unresolved": this host could not resolve the actor. Read-only.
Takes no parameters.
Analyze content performance
Section titled “Analyze content performance”Start with list_campaign_accounts. Use its exact account_id in
rank_account_posts. Pass its exact account_id and platform. Keep each
account and platform separate. Two Instagram accounts are two analysis groups.
These tools require the analytics schema from devfellowship/dfl-schema PR
#993. Before that schema is applied, the MCP returns a readiness error. It
does not convert a missing function or table into an empty result.
Choose the ranking basis explicitly:
lifetimeuses the latest stored absolute counter. Use it for the first retrospective report after the historical bootstrap. It does not accept dates.period_gainsubtracts the latest snapshot at or beforestart_datefrom the latest observation inside the inclusive date range. Both dates are required.
The initial historical bootstrap cannot reconstruct old daily gains. A post can
have a current lifetime total without a baseline for last week. In this case,
the tool returns coverage_status: "missing_baseline" and a
coverage_warning. Do not describe that lifetime total as weekly gain.
A post with only pre-period snapshots has no period result. The tool returns
coverage_status: "missing_period_observation" and a warning. It does not
invent a zero gain from the baseline.
Counter decreases stay negative. The tool does not apply an absolute value or
clamp the result to zero. Use get_post_metric_history to inspect a decrease or
another material anomaly.
The first delivery supports views, likes, and comments.
Each ranking row contains the campaigns post ID, the Zernio post ID, the
platform, the account ID, the planned publish time from scheduled_for, a short content excerpt, the chosen
metric, and snapshot coverage. It excludes full content and unrelated identity
data.
Account summaries and rankings use RLS-safe SECURITY INVOKER database RPCs.
The ranking RPC applies the requested limit before it returns data. It excludes
soft-deleted posts.
Metric history has a 10,000-snapshot hard cap. The server returns an explicit
error above the cap before it loads row data. Below the cap, it pages by the
unique collected_for date and requires the fetched total to match an exact
PostgREST count. It repeats the count after paging and rejects concurrent
count changes. A smaller server page cap cannot silently truncate history.
Narrow the date range and retry when the count or pages change.
What this server deliberately cannot do
Section titled “What this server deliberately cannot do”There is no reject_post, and approve_post cannot decide anything — it only
writes down what a human decided. The judgement stays in the dfl-campaigns UI.
The rule from the plan is the AI never posts on its own: a generated post waits
in awaiting_review until a person reads it. The JWT reaching this server is the
user’s own — nothing here can tell “Samuel clicking” apart from “Samuel’s agent
calling a tool”. So the boundary is not a permission check, it is the tool
surface itself: the agent that wrote the post has no call available that
judges it.
Why approve_post is not a hole in that
Section titled “Why approve_post is not a hole in that”There was no approve tool at all until 2026-09-11. What changed is not the rule — it is where a person is allowed to say the words.
Tainan asked his agent, over Telegram, to post a Reel on his own Instagram. The
agent drafted it and stopped dead: dispatch_post refuses anything that is not
approved, and there was nowhere to record that he had already said yes. The
decision existed; the only thing missing was a place to write it down.
So the tool records rather than decides, and two things the dfl-campaigns
server enforces keep it honest:
- Super admin only (
get_my_iam_role()≥ 100). Everyone else is refused with 403, not 503 — for an agent, “unavailable” is an invitation to retry forever, and a permission refusal has to read as one. approval_referenceis required, and it is the whole point: on an approval with no click it is the only trace of the person. It has to point at something real — “Telegram msg 18508” — that someone auditing the post later can go read. No check on either server can tell a fabricated pointer from a genuine one, which is exactly why the tool description tells the agent, in as many words, never to invent one.
The row then carries approval_channel (ui or mcp) next to approved_by, so
a click and a conversation are never the same record after the fact. Approving in
the queue still needs no special role: whoever clicks is reading the post.
Approving schedules (since 2026-09-15)
Section titled “Approving schedules (since 2026-09-15)”There is no cron and no separate send step. Approving a post, in the UI or with
approve_post, sends it to Zernio with status: "scheduled" for its
scheduled_for, and Zernio publishes it then; a time that already passed goes
out now. If Zernio refuses, the post stays approved with no Zernio id, which
the UI shows as not scheduled, and dispatch_post is the retry. A post nobody
approves before its time does not go out and shows as missed in the calendar.
Why dispatch_post is not a hole in that
Section titled “Why dispatch_post is not a hole in that”Dispatch was on this list until 2026-09-08, when Tainan moved it: “o approve é uma boa manter na UI mesmo samu, todo o resto ser possível fazer via agent (inclusive publicacao/envio dos approved)”.
Sending is not judging. canDispatch in dfl-campaigns refuses any post that is
not approved with approved_by and approved_at recorded. Those fields
are written by a person clicking in the queue, or by approve_post recording a
decision they already gave you — never by dispatch_post itself. An agent
calling it on something it just drafted still gets “Só um post aprovado por uma
pessoa pode ser enviado.” The human gate shrank to the approval; it did not
move.
revise_post_in_review closes the same door from the other side. Editing the
body of an already-approved post would ship text nobody read, without ever
calling approve — so it refuses anything past approved. To change an approved
post, a reviewer moves it back to the queue in the UI first.
reject_post and delete_post reach only your own posts
Section titled “reject_post and delete_post reach only your own posts”Added 2026-09-25, because agents left smoke drafts in the human review
queue and the dfl-campaigns API deletes only a draft or a rejected post. Both
tools read the post first and refuse unless its created_by is the caller’s
user id. The database RLS on campaigns.posts is by role (iam.is_member()),
not by owner, so this check is what keeps an agent from rejecting another
person’s post — that stays a judgement a person makes in the UI.
reject_post {post_id, reason}sends the samePATCH status: "rejected"the UI sends, with the caller’s JWT. It accepts onlyawaiting_review.delete_post {post_id}callsDELETE /api/posts/:id. The API accepts onlydraftandrejected, and the DELETE filters on the same states.- A post with no
created_by, or a session with no known caller, is refused.
archive_post hides a published post and keeps its numbers
Section titled “archive_post hides a published post and keeps its numbers”Added 2026-09-29 (Tainan TG msg 20007). delete_post never reaches a post
that went out, and a hard delete would take its post_metric_snapshots with it
by FK cascade. archive_post {post_id, reason} calls
POST /api/posts/:id/archive with the caller’s JWT. The server checks
iam.get_global_level() >= 80 before it reads the post (so a member gets 403
for any id), requires the reason, and sets deleted_at, archived_by and
archive_reason. RLS enforces the same gate again (dfl-schema
posts_archive_admin_self). The post leaves the calendar, the profiles and
analytics; the snapshots stay.
Why unschedule_post is not the reject tool
Section titled “Why unschedule_post is not the reject tool”Approving schedules, so a post a person cleared is already in Zernio’s hands, and until
2026-09-16 the only way to take it back was the UI. unschedule_post is that action,
and it moves in one direction only: the server cancels the post in Zernio first, then
rewrites the row to awaiting_review with approved_by, approved_at and
zernio_post_id cleared. The post cannot go out again without a new human approval — the
tool spends an approval, it never grants one. Rejecting is a verdict on the content and
still has no tool here.
The new scheduled_for is required, not decoration: it is the date the post holds while
it waits in the queue, and the server refuses one that already passed. Its reach ends
where Zernio publishes — inside the last few minutes before scheduled_for Zernio may
already be sending, so the server refuses rather than report a cancel that did not happen.
What is already on the network comes down in the network, by a person.
Instagram collaborators count as content
Section titled “Instagram collaborators count as content”instagram_collaborators is a list of up to 3 usernames, without the @. A post
with a collaborator shows up in the feed and the grid of both accounts, so it
is not metadata: dfl-campaigns treats a change to the list exactly like a
rewritten body — the approval is dropped and the post returns to
awaiting_review. Both tools pass the list through untouched and let that server
validate it; a username Instagram would not accept comes back as a refusal with
the reason, and nothing is written. The list is never silently trimmed, because a
post the caller believes marks someone and does not is worse than an error.
Marking is an invite: the other account has to accept it in the Instagram app before the post appears there. Neither Zernio nor Meta can accept it for us.
Calendar writes go through the app server
Section titled “Calendar writes go through the app server”Every other package in this fleet talks to Postgres with the caller’s JWT.
The calendar tools talk HTTP to dfl-campaigns. They do not write its tables
directly. This is a security choice.
The approval state machine lives in that repo’s server/post-approval.ts. The
database holds only a handful of CHECK constraints (approved and dispatched
require approved_by + approved_at; an mcp approval requires an
approval_reference) and an RLS policy of WITH CHECK (true) — a direct writer
could insert status = 'approved' with its own user id, skip awaiting_review
entirely, and every constraint would pass. The role gate on approve_post is
server-side for the same reason: it is a check the database does not make.
Going through the same server the UI uses means the agent gets exactly the
actions a person has, under exactly the same guards.
It also keeps the Zernio bearer token out of reach: dispatch happens inside
dfl-campaigns, which is where that credential lives.
Analytics is the read-only exception. The account and ranking tools call
SECURITY INVOKER functions with the caller’s Supabase JWT. Metric history
reads campaigns.post_metric_snapshots with the same JWT. The table’s member
policy controls the rows. The MCP has no service-role client. It exposes no
metric write tool.
The social account mapping is the second exception, and it is a write. The
mapping tools read and write campaigns.social_accounts directly with the
caller’s JWT. That table holds no post, no status and no approval, so it has no
path to the review queue. Its RLS is the whole gate: members read, and only
global admins insert, update or delete. A trigger stamps created_by and
updated_by from auth.uid().