Skip to main content

Workflow RPCs

Writes go through workflow RPCs — intent-named Postgres functions that own the transition logic. They're the same functions the MCP tools wrap, exposed over PostgREST at /rest/v1/rpc/<function>. Every function is SECURITY INVOKER, so RLS and the transition triggers apply to you as the caller.

curl -X POST \
"https://jionfqfmjinkrmzlsghf.supabase.co/rest/v1/rpc/submit_for_review" \
-H "apikey: $CP_PUBLISHABLE_KEY" \
-H "Authorization: Bearer $CP_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"p_publication":"<uuid>"}'

Every mutation returns the updated row, so you don't need a follow-up read.

Planning

FunctionArgumentsDoes
resolve_projectp_projectResolve a project slug or id to its uuid
create_collectionproject, type, name, dates…New campaign or section
create_stubproject, collection, title, ideaPublication in stub

Publications

FunctionArgumentsTransition
update_draftpublication, title/summary/body/noteswrites content; stub → draft when a body is added
submit_for_reviewp_publicationdraft → reviewing
review_publicationpublication, verdict, notesapprove → approved; request_changes → draft
mark_publishedp_publication, p_canonical_urlpublished (records the Substack URL)
archive_publicationp_publicationarchived
start_promotingp_publicationapproved → promoting; returns channels + per-channel constraints

Promos

FunctionArgumentsTransition
create_promopublication, channel, bodynew promo in draft
update_promopromo, body / scheduled_foredit copy or schedule
submit_promo_for_reviewp_promodraft → reviewing
review_promopromo, verdict, notesapprove / request changes
publish_promop_promo, p_external_urlmanual channels → published

Dashboard

FunctionArgumentsReturns
pipeline_statusp_project (optional)counts by status, upcoming scheduled_for, stale items

Error behavior

An invalid transition returns a structured error that names the current status and the allowed next states, so a client can self-correct. For example, calling start_promoting on a draft returns:

invalid publication transition: draft -> promoting (allowed from draft: reviewing, archived)
These are the same functions MCP calls

The MCP tool surface is a thin, schema-documented layer over exactly these RPCs. If you're building an AI client, use MCP; if you're scripting against the database, call the RPCs directly.