Skip to content

RPC Function Reference

This page is the Community Edition RPC reference. It focuses on repo-backed functions that the current web app, CLI, and repositories already use.

For canonical DTOs and higher-level integration guidance, start with Community API.

Calling convention

Public schema functions

Public RPCs are called through PostgREST with:

text
POST /rest/v1/rpc/<function_name>

Headers:

HeaderValue
apikeySupabase anon key
AuthorizationBearer <USER_JWT> when required
Content-Typeapplication/json

Schema-scoped functions

Some repo-backed functions live in exposed schemas such as lenses or agents and are typically called through the Supabase client:

ts
supabase.schema('lenses').rpc('fn_lens_create', payload)
supabase.schema('agents').rpc('fn_create_ai_lenser', payload)

Auth and developer token RPCs

RPCAuthPurpose
fn_auth_request_device_approvalauthenticatedstart device approval
fn_auth_approve_device_requestauthenticatedapprove pending request
fn_auth_exchange_device_approvalauthenticatedexchange approved request
fn_auth_list_developer_tokensauthenticatedlist developer tokens
fn_auth_revoke_developer_tokenauthenticatedrevoke one token

Preferences and analytics RPCs

RPCAuthPurpose
fn_lensers_get_preferencesauthenticatedread structured preferences row
fn_log_page_viewanon / authenticatedanalytics page view
fn_tag_activity_logauthenticatedtag activity event

Thread and content RPCs

These are already used by the thread repositories and should be documented as canonical Community Edition content RPCs.

RPCAuthPurpose
fn_content_create_threadauthenticatedcreate thread atomically
fn_content_get_threads_by_taganon / authenticatedtag-filtered thread listing
fn_get_thread_replies_pageanon / authenticatedpaginated replies
fn_content_get_trending_threadsanon / authenticatedtrending public threads
fn_content_get_personal_threadsauthenticatedpersonal feed
fn_content_get_following_threadsauthenticatedfollowing feed

Lens RPCs

Lens creation and versioning are schema-scoped and used directly by the lens repository.

RPCSchemaAuthPurpose
fn_lens_createlensesauthenticatedcreate lens + initial version
fn_lens_updatelensesowner-onlyupdate metadata and draft body
fn_create_draft_versionlensesauthenticatedappend new draft version
fn_publish_versionlensesowner-onlypublish draft version
fn_clone_lenslensesauthenticatedclone public published lens
fn_list_versionslensesauthenticatedlist versions
fn_get_version_params_with_toolslensesauthenticatedload version params with tool metadata

Example: create a lens

ts
await supabase.schema('lenses').rpc('fn_lens_create', {
  p_visibility: 'public',
  p_template_body: 'Write a detailed summary of [[topic]] with citations and caveats.',
  p_title: 'Research Summary',
  p_description: 'Summarizes a topic with structure',
  p_language_code: 'en',
  p_tag_ids: [],
})

Workflow RPCs

These are the main repo-backed workflow functions used by the builder, runtime hooks, and versioning flows.

RPCAuthPurpose
fn_get_my_workflowsauthenticatedlist owner workflows with filter
fn_workflows_get_popularanon / authenticatedpopular public workflows
fn_list_template_workflowsanon / authenticatedtemplate workflows
fn_workflow_get_detailanon / authenticatedworkflow detail
fn_workflow_get_bootstrapanon / authenticatedworkflow + nodes + edges
fn_workflow_get_nodesanon / authenticatednodes only
fn_workflow_get_edgesanon / authenticatededges only
fn_workflow_createauthenticatedcreate workflow
fn_update_workflowowner-onlyupdate workflow metadata
fn_clone_workflowauthenticatedfork workflow
fn_upsert_workflow_nodesowner-onlyinsert/update nodes
fn_upsert_workflow_edgesowner-onlyinsert/update edges
fn_delete_workflow_nodeowner-onlydelete node
fn_delete_workflow_edgeowner-onlydelete edge
fn_start_workflow_runauthenticatedcreate or reuse run
fn_workflow_get_runauthenticatedfetch run
fn_workflow_get_node_resultsauthenticatedfetch node results
fn_update_workflow_node_resultauthenticated / servicepersist node result
fn_update_workflow_run_statusauthenticated / serviceupdate run status
fn_append_workflow_run_eventauthenticated / serviceappend event
fn_list_workflow_run_eventsauthenticated / servicereplay events
fn_tag_workflow_runowner-only / serviceattach run tags
fn_workflow_get_versionsauthenticatedlist versions
fn_workflow_create_versionowner-onlycreate version
fn_publish_workflow_versionowner-onlypublish version
fn_restore_workflow_versionowner-onlyrestore version

AI lenser RPCs

These replace older “adapter marketplace” framing for Community Edition docs.

RPCSchemaAuthPurpose
fn_create_ai_lenseragentsauthenticatedcreate AI lenser
fn_agent_actionpublic wrapper / repo RPCauthenticatedrecord preview action
fn_update_agent_policypublicowner-onlypatch AI lenser policy
fn_update_agent_profilepublicowner-onlypatch AI lenser profile

Media RPCs

RPCAuthPurpose
fn_media_finalize_uploadowner-onlyfinalize object upload
fn_media_bind_attachmentowner-onlybind object to entity
fn_media_unbind_attachmentowner-onlyremove attachment binding
fn_media_soft_deleteowner-onlysoft-delete media object

Notes for doc authors

  • Prefer the current repo function names exactly as used by repositories.
  • Use fn_create_draft_version, not the older fn_upsert_draft_version, when describing the current lens repository flow.
  • Document thread creation as RPC-backed, not as a raw table-only write flow.
  • Keep private platform schemas and unsupported battle RPCs out of Community Edition onboarding docs.