prompt-configs
What it does
CRUD over public.prompt_configs — reusable prompt/model configurations (system_prompt, context_template, model, temperature/token limits, escalation and output bindings, knowledge_sources, available_tools) that agents resolve at run time (see AI and prompts).
Route and methods
/.netlify/functions/prompt-configs, reachable as /api/prompt-configs (/api/* → /.netlify/functions/:splat, .framework/public/_redirects). ?action= is ignored — the dispatcher has only a default branch keyed on method:
| Call | Handler |
|---|---|
GET /api/prompt-configs | list |
GET /api/prompt-configs?id=<uuid> | get |
POST /api/prompt-configs | create |
PATCH /api/prompt-configs (id in body or query) | update |
DELETE /api/prompt-configs?id=<uuid> | remove |
Authentication
Standard createHandler auth: x-api-key → machine principal, x-internal-secret → internal principal, Bearer <jwt> → human; anonymous → 401.
list/createadditionally requirectx.accountId(Account context required).- There is no role check in this file. System admins use
adminDb; everyone else usesctx.db— JWT-scoped (RLS) for humans, service role for machine principals. Non-admin row access is whatever RLS allows, and returned rows are sanitized to{ id }(prompt-config rows carry nodesign_schema).
Request contract
list (query): model, is_active ('true'/'false'), limit (default 100), offset (default 0). Ordered by name.
get (query): id.
create (body): name, slug required. Optional with defaults: app_id null, description/system_prompt/context_template null, model 'gpt-4o', temperature 0.7, max_tokens 4000, is_multi_turn true, max_history_messages 20, confidence_threshold/escalation_action/escalation_target/ output_mode/output_field null, requires_review false, knowledge_sources [], available_tools [], tool_constraints {}, metadata {}. account_id is stamped from context.
update (id in body or query + body): allowlist only — name, slug, description, app_id, system_prompt, context_template, model, temperature, max_tokens, is_multi_turn, max_history_messages, confidence_threshold, escalation_action, escalation_target, output_mode, output_field, requires_review, knowledge_sources, available_tools, tool_constraints, metadata, is_active. Unknown keys are ignored; updated_at is stamped.
remove (query): id — hard delete.
Response contract
Standard { data, error, meta } envelope.
list/get/create/update→ row(s) passed throughsanitizeRecordData: full row for system admins,{ id }for non-admins (first-surface path, nodesign_schemaon the row).remove→{ success: true }.
Side effects
createinserts intopublic.prompt_configswith the caller'saccount_id.removeissues a realDELETE— unliketypes/apps/roles/integrations, deletion here is permanent.emitLogwritesprompt_config.created/.updated/.deletedaudit rows topublic.logs.
Errors
| Condition | HTTP | Message |
|---|---|---|
| No account context (list, create) | 500 | Account context required |
| Missing create fields | 500 | name and slug are required |
Missing id | 500 | Config ID is required |
| Row missing on delete | 500 | Prompt config not found |
| Unmatched method | 500 | Invalid action or method |
Validation failures surface as HTTP 500 — thrown Errors without a statusCode map to 500 in the shared error path.
Agent notes
?action=get&id=…works only by accident — every action value lands in thedefaultbranch. Don't rely on action names here; dispatch is method +idpresence.removeis a hard delete; there is nois_activerestore path. PreferPATCH { is_active: false }if reversibility matters.- Create stamps
account_idfrom the caller's context — there is no way to create a config for another account through this endpoint. - Consumers resolve configs at run time by
prompt_config_idstored on threads/agents, not through this endpoint; this function is pure config management.