Skip to main content

Prompts API

This page documents the 23 gateway endpoints tagged prompts in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
POST/promptsCreate a prompt
GET/prompts/listList stored prompts (admins)
GET/prompts/ops/git_syncsList repository connections for prompts
POST/prompts/ops/git_syncsConnect a repository for prompts
DELETE/prompts/ops/git_syncs/{sync_id}Remove a repository connection
POST/prompts/ops/git_syncs/{sync_id}/pullPull prompts from the repository
POST/prompts/ops/git_syncs/{sync_id}/pushPush prompts to the repository as one commit
GET/prompts/ops/partialsList prompt partials
POST/prompts/ops/partialsSave a new version of a prompt partial
GET/prompts/ops/partials/{name}Read every version of a prompt partial
DELETE/prompts/ops/partials/{name}Delete a prompt partial
GET/prompts/ops/settingsRead the prompt protection and alert settings
PUT/prompts/ops/settingsChange the prompt protection and alert settings
POST/prompts/testRender a prompt and stream a model reply
GET/prompts/{prompt_id}Read one prompt with its template
PUT/prompts/{prompt_id}Save a new version of a prompt
PATCH/prompts/{prompt_id}Change some fields of a prompt as a new version
DELETE/prompts/{prompt_id}Delete a prompt
GET/prompts/{prompt_id}/diffCompare two versions of a prompt
GET/prompts/{prompt_id}/infoRead one prompt with its template
POST/prompts/{prompt_id}/promotePromote a tested prompt version into another environment
GET/prompts/{prompt_id}/versionsList the versions of a prompt
POST/utils/dotprompt_json_converterConvert a .prompt file to JSON

Endpoints​

POST /prompts​

Create a prompt

Store a prompt in the environment named in prompt_info.environment (development when left out) and make it callable by prompt_id at once. A new id starts at version 1, and an id that already exists in that environment gets the next version. spanway_params.prompt_integration picks where the template lives, and for dotprompt the template goes in dotprompt_content. A prompt saved here is always stored with prompt_type db, so it can be changed and deleted later. An api_key for a remote integration is stored encrypted and shown masked. A protected environment (production by default) is refused with 409, promote a tested version into it instead. Proxy admins only. The change is written to the audit log with the template replaced by its hash and reported on the prompt_created alert.

Docs

Example Request:

curl -X POST "http://localhost:4000/prompts" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt_id": "support-reply",
"spanway_params": {
"prompt_integration": "dotprompt",
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\n---\nGreet {{customer_name}}."
},
"prompt_info": {"prompt_type": "db", "environment": "development"}
}'

Request body (application/json, schema Prompt):

FieldTypeRequiredDescription
prompt_idstringYesPrompt Id
prompt_infoPromptInfo or nullNo
spanway_paramsPromptSpanwayParamsYes

Example request:

curl -X POST "http://localhost:4000/prompts" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt_id": "support-reply",
"prompt_info": {
"environment": "development",
"prompt_type": "db"
},
"spanway_params": {
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\ntemperature: 0.3\n---\nYou are a support agent. Greet {{customer_name}} and resolve: {{issue}}.",
"prompt_integration": "dotprompt"
}
}'

Responses:

StatusDescriptionBody
200The prompt version as stored.application/json PromptSpec
400spanway_params.prompt_id is combined with prompt_data keyed by template name.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin.application/json ErrorDetail
409The environment is protected, so it only takes promoted versions.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, so prompts cannot be stored.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
environmentstring or nullNoEnvironment
prompt_idstringYesPrompt Id
prompt_infoPromptInfoYes
spanway_paramsPromptSpanwayParamsYes
updated_atstring or nullNoUpdated At
versioninteger or nullNoVersion

GET /prompts/list​

List stored prompts (admins)

List the latest version of every prompt in each environment, from the config file and the database. Proxy admins and admin viewers only, and an admin key whose prompts field is set sees only those prompts. Filter with environment, for example development, staging or production. A remote integration's api_key is shown masked.

Docs

Example Request:

curl -X GET "http://localhost:4000/prompts/list?environment=production" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Example Response:

{
"prompts": [
{
"prompt_id": "support-reply",
"spanway_params": {
"prompt_id": "support-reply",
"prompt_integration": "dotprompt",
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\n---\nGreet {{customer_name}}."
},
"prompt_info": {"prompt_type": "db", "environment": "production"},
"version": 3,
"environment": "production",
"created_by": "admin@example.com"
}
]
}

Parameters:

NameInTypeRequiredDescription
environmentquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/prompts/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json ListPromptsResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
promptsarray of PromptSpecYesPrompts

GET /prompts/ops/git_syncs​

List repository connections for prompts

Lists the GitLab and Bitbucket repositories prompts are synced with, when each was last pulled and pushed, and the last error. The access token is never returned, only whether one is stored. Proxy admins and admin viewers.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#sync-with-a-git-repository)

curl http://localhost:4000/prompts/ops/git_syncs -H "Authorization: Bearer $SPANWAY_API_KEY"

Example request:

curl -X GET "http://localhost:4000/prompts/ops/git_syncs" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json GitSyncListResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins and admin viewers can read repository connectionsapplication/json ErrorDetail
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
syncsarray of GitSyncViewYesEvery repository connection

POST /prompts/ops/git_syncs​

Connect a repository for prompts

Stores a connection to one folder on one branch of a GitLab (gitlab.com or self-managed over https) or Bitbucket Cloud repository. Pulled prompts are saved in environment, which cannot be a protected one, so a change from the repository still goes through promotion before it reaches production. The token needs read and write access to the repository and is stored encrypted. Written to the audit log without the token. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#sync-with-a-git-repository)

curl -X POST http://localhost:4000/prompts/ops/git_syncs -H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "support-prompts", "provider": "gitlab", "repository": "acme/support-prompts",
"branch": "main", "path": "prompts", "environment": "development", "access_token": "'"$GITLAB_TOKEN"'"}'

Request body (application/json, schema GitSyncRequest):

FieldTypeRequiredDescription
access_tokenstringYesA token that may read and write the repository. Stored encrypted
api_basestring or nullNoSelf-managed GitLab API address, https only. Empty for gitlab.com
branchstringNoThe branch to read and write
environmentstringNoWhere pulled prompts are saved. A protected environment is refused
namestringYesA short name for the connection
pathstringNoThe folder that holds .prompt files
providerenum: "gitlab", "bitbucket"Yesgitlab or bitbucket
repositorystringYesgroup/project on GitLab, workspace/repo on Bitbucket

Example request:

curl -X POST "http://localhost:4000/prompts/ops/git_syncs" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"access_token": "example-access-token",
"branch": "main",
"environment": "development",
"name": "support-prompts",
"path": "prompts",
"provider": "gitlab",
"repository": "acme/support-prompts"
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json GitSyncView
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can change repository connectionsapplication/json ErrorDetail
409A repository connection named support-prompts already existsapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_token_setbooleanYesWhether a token is stored. The token itself is never returned
api_basestring or nullNoThe self-managed GitLab API address, if any
branchstringYesThe branch
created_atstring or nullNoWhen it was added
created_bystring or nullNoWho added the connection
environmentstringYesWhere pulled prompts are saved
last_commitstring or nullNoThe commit the last push created
last_errorstring or nullNoWhy the last pull or push failed, if it did
last_pull_atstring or nullNoWhen prompts were last pulled
last_push_atstring or nullNoWhen prompts were last pushed
namestringYesThe connection's name
pathstringYesThe folder that holds .prompt files
providerenum: "gitlab", "bitbucket"Yesgitlab or bitbucket
repositorystringYesThe repository
sync_idstringYesThe connection's id

DELETE /prompts/ops/git_syncs/{sync_id}​

Remove a repository connection

Removes the connection and its stored token. Prompts that were pulled stay as they are. Written to the audit log. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#sync-with-a-git-repository)

curl -X DELETE http://localhost:4000/prompts/ops/git_syncs/$SYNC_ID -H "Authorization: Bearer $SPANWAY_API_KEY"

Parameters:

NameInTypeRequiredDescription
sync_idpathstringYes

Example request:

curl -X DELETE "http://localhost:4000/prompts/ops/git_syncs/sync_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json GitSyncView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can change repository connectionsapplication/json ErrorDetail
404Repository connection 8c1f0e1a-2b7d-4f7e-9a51-1d2a6f3b9c40 not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_token_setbooleanYesWhether a token is stored. The token itself is never returned
api_basestring or nullNoThe self-managed GitLab API address, if any
branchstringYesThe branch
created_atstring or nullNoWhen it was added
created_bystring or nullNoWho added the connection
environmentstringYesWhere pulled prompts are saved
last_commitstring or nullNoThe commit the last push created
last_errorstring or nullNoWhy the last pull or push failed, if it did
last_pull_atstring or nullNoWhen prompts were last pulled
last_push_atstring or nullNoWhen prompts were last pushed
namestringYesThe connection's name
pathstringYesThe folder that holds .prompt files
providerenum: "gitlab", "bitbucket"Yesgitlab or bitbucket
repositorystringYesThe repository
sync_idstringYesThe connection's id

POST /prompts/ops/git_syncs/{sync_id}/pull​

Pull prompts from the repository

Reads every .prompt file under the connection's folder (at most 200, each at most 256 KiB) and saves each one whose text differs from the newest version in the connection's environment as that prompt's next version. The file name without .prompt is the prompt id. Files with another name, prompts stored with a different integration, unreadable files and files that are not valid dotprompt templates (for example broken YAML front matter) are listed under skipped with the reason, and the rest are still imported. Each saved prompt writes its own audit row with source git_sync:<name> and sends the prompt_created or prompt_updated alert. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#sync-with-a-git-repository)

curl -X POST http://localhost:4000/prompts/ops/git_syncs/$SYNC_ID/pull -H "Authorization: Bearer $SPANWAY_API_KEY"

Parameters:

NameInTypeRequiredDescription
sync_idpathstringYes

Request body (application/json, object):

Example request:

curl -X POST "http://localhost:4000/prompts/ops/git_syncs/sync_id-123/pull" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json GitPullResult
400The stored access token cannot be read with this gateway's key. Delete the connection and add it again.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can pull prompts from a repositoryapplication/json ErrorDetail
404Repository connection 8c1f0e1a-2b7d-4f7e-9a51-1d2a6f3b9c40 not foundapplication/json ErrorDetail
409The development environment is protected, so pulled prompts cannot be saved there.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail
502The repository host refused or failed the call.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
createdarray of stringYesPrompts that did not exist and were created
environmentstringYesWhere the prompts were saved
skippedarray of GitSkippedFileYesFiles that were not imported, with the reason
sync_idstringYesThe connection that was pulled
unchangedarray of stringYesPrompts that already matched the repository
updatedarray of stringYesPrompts whose text changed and got a new version

POST /prompts/ops/git_syncs/{sync_id}/push​

Push prompts to the repository as one commit

Writes the newest version of every dotprompt prompt in environment (the connection's environment when left out) to <folder>/<prompt id>.prompt as one commit on the connection's branch. Files whose text already matches are left alone, and nothing is committed when nothing changed. Prompts stored with another integration are listed under skipped. Written to the audit log as exported. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#sync-with-a-git-repository)

curl -X POST http://localhost:4000/prompts/ops/git_syncs/$SYNC_ID/push \
-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
-d '{"environment": "production"}'

Parameters:

NameInTypeRequiredDescription
sync_idpathstringYes

Request body (application/json, schema GitPushRequest):

FieldTypeRequiredDescription
environmentstring or nullNoWhich environment to write out. The connection's environment when left out
messagestring or nullNoThe commit message

Example request:

curl -X POST "http://localhost:4000/prompts/ops/git_syncs/sync_id-123/push" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"environment": "production",
"message": "Export production prompts"
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json GitPushResult
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can push prompts to a repositoryapplication/json ErrorDetail
404Repository connection 8c1f0e1a-2b7d-4f7e-9a51-1d2a6f3b9c40 not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail
502The repository host refused or failed the call.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
commitstring or nullNoThe new commit, empty when nothing changed
environmentstringYesThe environment that was written out
skippedarray of GitSkippedFileYesPrompts that were not written, with the reason
sync_idstringYesThe connection that was pushed
writtenarray of stringYesFiles the commit added or changed

GET /prompts/ops/partials​

List prompt partials

Lists every partial with its newest version. A partial is a block of prompt text, such as a house style or a safety notice, that many prompts include with {{> name}} so it is written once. Proxy admins and admin viewers.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#reusable-partials)

curl http://localhost:4000/prompts/ops/partials -H "Authorization: Bearer $SPANWAY_API_KEY"

Example request:

curl -X GET "http://localhost:4000/prompts/ops/partials" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptPartialListResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins and admin viewers can read prompt partialsapplication/json ErrorDetail
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
partialsarray of PromptPartialSummaryYesEvery partial, by name

POST /prompts/ops/partials​

Save a new version of a prompt partial

Saves the text as the next version of the partial, version 1 for a new name. Prompts that use {{> name}} in an unprotected environment render the new text on their next request. Copies in a protected environment keep the version they were promoted with. Written to the audit log with the text replaced by its hash. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#reusable-partials)

curl -X POST http://localhost:4000/prompts/ops/partials -H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "tone", "content": "Answer in a warm, plain tone. Never promise refunds."}'

Request body (application/json, schema PromptPartialRequest):

FieldTypeRequiredDescription
contentstringYesThe reusable text
descriptionstring or nullNoWhat the partial is for
namestringYesThe name prompts use, as {{> name}}

Example request:

curl -X POST "http://localhost:4000/prompts/ops/partials" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Answer in a warm, plain tone. Never promise refunds.",
"description": "House style for support replies",
"name": "tone"
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptPartial
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can change prompt partialsapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
contentstringYesThe text of this version
created_atstring or nullNoWhen this version was saved
created_bystring or nullNoWho saved this version
descriptionstring or nullNoWhat the partial is for
namestringYesThe partial's name
versionintegerYesThe version number, counting from 1

GET /prompts/ops/partials/{name}​

Read every version of a prompt partial

Returns every version of one partial, newest first, with its text. Prompts use the newest version with {{> name}} or pin one with {{> name@2}}. Proxy admins and admin viewers.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#reusable-partials)

curl http://localhost:4000/prompts/ops/partials/tone -H "Authorization: Bearer $SPANWAY_API_KEY"

Parameters:

NameInTypeRequiredDescription
namepathstringYes

Example request:

curl -X GET "http://localhost:4000/prompts/ops/partials/name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptPartialVersionsResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins and admin viewers can read prompt partialsapplication/json ErrorDetail
404Partial tone not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
partialsarray of PromptPartialYesEvery version of the partial, newest first

DELETE /prompts/ops/partials/{name}​

Delete a prompt partial

Deletes every version of the partial. A partial that any stored prompt version or any version of another partial still includes is refused, so deleting it can never break a prompt that is being served. Written to the audit log. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#reusable-partials)

curl -X DELETE http://localhost:4000/prompts/ops/partials/tone -H "Authorization: Bearer $SPANWAY_API_KEY"

Parameters:

NameInTypeRequiredDescription
namepathstringYes

Example request:

curl -X DELETE "http://localhost:4000/prompts/ops/partials/name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptPartialDeletedResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can change prompt partialsapplication/json ErrorDetail
404Partial tone not foundapplication/json ErrorDetail
409Partial tone is still used by support-reply (staging), partial greeting. Remove it from those prompts and partials first.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
deleted_versionsintegerYesHow many versions were removed
namestringYesThe partial that was deleted

GET /prompts/ops/settings​

Read the prompt protection and alert settings

Shows which prompt environments are protected, whether promoting into them needs a passed eval run, and who is emailed when a prompt changes. Until an admin saves settings, production is protected, the eval verdict is required and nobody is emailed. Proxy admins and admin viewers.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#protected-environments)

curl http://localhost:4000/prompts/ops/settings -H "Authorization: Bearer $SPANWAY_API_KEY"

Example request:

curl -X GET "http://localhost:4000/prompts/ops/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptOpsSettingsView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins and admin viewers can read prompt settingsapplication/json ErrorDetail
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
alert_emailsarray of stringNoWho gets an email when a prompt changes. Empty sends no email
email_onarray of enum: "created", "updated", "deleted", "promoted"NoWhich prompt changes send that email
protected_environmentsarray of stringNoEnvironments that only take promoted versions. Direct saves and deletes there are refused
require_eval_verdictbooleanNoWhen true, promoting into a protected environment needs a passed eval run of that version
updated_atstring or nullNoWhen the settings were saved last
updated_bystring or nullNoWho saved the settings last. Empty for the defaults

PUT /prompts/ops/settings​

Change the prompt protection and alert settings

Replaces the settings as a whole. protected_environments lists the environments that only take promoted versions, require_eval_verdict decides whether a promotion into them needs a passed eval run, alert_emails and email_on decide who is emailed about which changes. Every save is written to the audit log with the settings before and after. Proxy admins only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#protected-environments)

curl -X PUT http://localhost:4000/prompts/ops/settings -H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"protected_environments": ["production"], "require_eval_verdict": true,
"alert_emails": ["prompt-owners@example.com"], "email_on": ["promoted", "deleted"]}'

Request body (application/json, schema PromptOpsSettings):

FieldTypeRequiredDescription
alert_emailsarray of stringNoWho gets an email when a prompt changes. Empty sends no email
email_onarray of enum: "created", "updated", "deleted", "promoted"NoWhich prompt changes send that email
protected_environmentsarray of stringNoEnvironments that only take promoted versions. Direct saves and deletes there are refused
require_eval_verdictbooleanNoWhen true, promoting into a protected environment needs a passed eval run of that version

Example request:

curl -X PUT "http://localhost:4000/prompts/ops/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"alert_emails": [
"prompt-owners@example.com"
],
"email_on": [
"promoted",
"deleted"
],
"protected_environments": [
"production"
],
"require_eval_verdict": true
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptOpsSettingsView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can change prompt settingsapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
alert_emailsarray of stringNoWho gets an email when a prompt changes. Empty sends no email
email_onarray of enum: "created", "updated", "deleted", "promoted"NoWhich prompt changes send that email
protected_environmentsarray of stringNoEnvironments that only take promoted versions. Direct saves and deletes there are refused
require_eval_verdictbooleanNoWhen true, promoting into a protected environment needs a passed eval run of that version
updated_atstring or nullNoWhen the settings were saved last
updated_bystring or nullNoWho saved the settings last. Empty for the defaults

POST /prompts/test​

Render a prompt and stream a model reply

Render dotprompt_content with prompt_variables, append conversation_history, and send the result to the model named in the front matter, streaming the reply. Nothing is saved, so you can try a prompt before storing a version. The test chat of the Prompt Studio calls this route. This is a real model call and costs money.

Docs (https://docs.spanway.ai/docs/proxy/prompt_versions)

Example Request:

curl -X POST "http://localhost:4000/prompts/test" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"dotprompt_content": "---\nmodel: gpt-4o\ntemperature: 0.7\n---\n\nUser: Hello {{name}}",
"prompt_variables": {
"name": "World"
}
}'

Request body (application/json, schema TestPromptRequest):

FieldTypeRequiredDescription
conversation_historyarray of object or nullNoConversation History
dotprompt_contentstringYesDotprompt Content
prompt_variablesobject or nullNoPrompt Variables

Example request:

curl -X POST "http://localhost:4000/prompts/test" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"conversation_history": [
{
"content": "I was charged twice",
"role": "user"
}
],
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\ntemperature: 0.3\n---\nYou are a support agent. Greet {{customer_name}} and resolve: {{issue}}.",
"prompt_variables": {
"customer_name": "Jane",
"issue": "double charge on order 4411"
}
}'

Responses:

StatusDescriptionBody
200The model reply as a stream of chat completion chunks, as /chat/completions streams them.text/event-stream string
400The front matter names no model, the template renders no messages, or a variable is missing.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The model call failed.application/json ErrorDetail

GET /prompts/{prompt_id}​

Read one prompt with its template

Read the latest version of a prompt in an environment, with the template text and metadata and the list of environments the prompt exists in. Append .v2 to the id to read one version. Proxy admins and admin viewers only, and an admin key whose own or team prompts field leaves the prompt out gets 400. A remote integration's api_key is shown masked.

Docs

Example Request:

curl -X GET "http://localhost:4000/prompts/support-reply/info?environment=production" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Example Response:

{
"prompt_spec": {
"prompt_id": "support-reply",
"spanway_params": {
"prompt_id": "support-reply",
"prompt_integration": "dotprompt",
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\n---\nGreet {{customer_name}}."
},
"prompt_info": {"prompt_type": "db", "environment": "production"},
"version": 3,
"environment": "production"
},
"raw_prompt_template": {"spanway_prompt_id": "support-reply", "content": "Greet {{customer_name}}."},
"environments": ["development", "production"]
}

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes
environmentquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/prompts/prompt_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptInfoResponse
400No prompt has this id in the environment asked for, or the admin key's prompts field leaves it out.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin or admin viewer.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
environmentsarray of string or nullNoEnvironments
prompt_specPromptSpecYes
raw_prompt_templatePromptTemplateBase or nullNo

PUT /prompts/{prompt_id}​

Save a new version of a prompt

Save the body as the next version of the prompt in the environment named in prompt_info.environment. Earlier versions stay in the history and can still be called by prompt_version. Config file prompts cannot be changed here, and a protected environment (production by default) answers 409, promote a tested version into it instead. Proxy admins only. The change is written to the audit log and reported on the prompt_updated alert.

Docs (https://docs.spanway.ai/docs/proxy/prompt_versions)

Example Request:

curl -X PUT "http://localhost:4000/prompts/support-reply" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt_id": "support-reply",
"spanway_params": {
"prompt_integration": "dotprompt",
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\n---\nGreet {{customer_name}} warmly."
},
"prompt_info": {"prompt_type": "db", "environment": "development"}
}'

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes

Request body (application/json, schema Prompt):

FieldTypeRequiredDescription
prompt_idstringYesPrompt Id
prompt_infoPromptInfo or nullNo
spanway_paramsPromptSpanwayParamsYes

Example request:

curl -X PUT "http://localhost:4000/prompts/prompt_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt_id": "support-reply",
"prompt_info": {
"environment": "development",
"prompt_type": "db"
},
"spanway_params": {
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\ntemperature: 0.3\n---\nYou are a support agent. Greet {{customer_name}} and resolve: {{issue}}.",
"prompt_integration": "dotprompt"
}
}'

Responses:

StatusDescriptionBody
200The prompt version as stored.application/json PromptSpec
400The prompt comes from the config file, which this route cannot change.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin.application/json ErrorDetail
404No prompt has this id.application/json ErrorDetail
409The environment is protected, so it only takes promoted versions.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, so prompts cannot be stored.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
environmentstring or nullNoEnvironment
prompt_idstringYesPrompt Id
prompt_infoPromptInfoYes
spanway_paramsPromptSpanwayParamsYes
updated_atstring or nullNoUpdated At
versioninteger or nullNoVersion

PATCH /prompts/{prompt_id}​

Change some fields of a prompt as a new version

Take the latest version of the prompt in environment (development when left out), or the version named by a .vN suffix on the id, apply only the fields you send, and save the result as the next version in that environment. Earlier versions stay unchanged. spanway_params is merged field by field into the stored parameters. A protected environment (production by default) answers 409. Proxy admins only. The change is written to the audit log and reported on the prompt_updated alert.

Docs (https://docs.spanway.ai/docs/proxy/prompt_versions)

This endpoint allows updating specific fields of a prompt without sending the entire object. Only the following fields can be updated:

  • spanway_params: Spanway parameters for the prompt
  • prompt_info: Additional information about the prompt

Example Request:

curl -X PATCH "http://localhost:4000/prompts/my_prompt_id" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"spanway_params": {
"prompt_integration": "dotprompt",
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\n---\nGreet {{customer_name}} by name."
}
}'

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes
environmentquerystring or nullNo

Request body (application/json, schema PatchPromptRequest):

FieldTypeRequiredDescription
prompt_infoPromptInfo or nullNo
spanway_paramsPromptSpanwayParams or nullNo

Example request:

curl -X PATCH "http://localhost:4000/prompts/prompt_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"spanway_params": {
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\ntemperature: 0.3\n---\nYou are a support agent. Greet {{customer_name}} and resolve: {{issue}}.",
"prompt_integration": "dotprompt"
}
}'

Responses:

StatusDescriptionBody
200The prompt version as stored.application/json PromptSpec
400The prompt comes from the config file, which this route cannot change.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin.application/json ErrorDetail
404No version of this prompt exists in the environment.application/json ErrorDetail
409The environment is protected, so it only takes promoted versions.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, so prompts cannot be stored.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
environmentstring or nullNoEnvironment
prompt_idstringYesPrompt Id
prompt_infoPromptInfoYes
spanway_paramsPromptSpanwayParamsYes
updated_atstring or nullNoUpdated At
versioninteger or nullNoVersion

DELETE /prompts/{prompt_id}​

Delete a prompt

Delete every version of a prompt in one environment when environment is given, or in every environment when it is not. Requests that still send the prompt_id fail afterwards. A prompt with a version in a protected environment (production by default) answers 409 when that environment would be emptied. Proxy admins only. The change is written to the audit log and reported on the prompt_deleted alert.

Docs

Example Request:

curl -X DELETE "http://localhost:4000/prompts/my_prompt_id" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Example Response:

{
"message": "Prompt my_prompt_id deleted successfully"
}

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes
environmentquerystring or nullNo

Example request:

curl -X DELETE "http://localhost:4000/prompts/prompt_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Every version in the environment, or in every environment, is gone.application/json PromptDeletedResponse
400The prompt comes from the config file.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin.application/json ErrorDetail
404No prompt has this id.application/json ErrorDetail
409The environment is protected, so it only takes promoted versions.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, so prompts cannot be stored.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage

GET /prompts/{prompt_id}/diff​

Compare two versions of a prompt

Shows what changed between two versions: the template text as a unified diff (lines starting with - were removed, + were added) and every setting that differs, such as the model or temperature in the front matter. Each side is an environment and a version, the newest version when the version is left out, and to_environment defaults to from_environment. Typical uses are what a promotion would change (from_environment=production&to_environment=staging) and what one edit changed (from_environment=development&from_version=2&to_version=3). Reading changes nothing. API keys are shown masked. Proxy admins and admin viewers.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#compare-versions)

curl "http://localhost:4000/prompts/support-reply/diff?from_environment=production&to_environment=staging" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes
from_environmentquerystringNo
to_environmentquerystring or nullNo
from_versionqueryinteger or nullNo
to_versionqueryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/prompts/prompt_id-123/diff" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptDiffResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins and admin viewers can compare prompt versionsapplication/json ErrorDetail
404Prompt support-reply has no version 9 in stagingapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
from_versionPromptVersionRefYesThe version on the left
prompt_idstringYesThe prompt compared
settings_changedarray of SettingChangeYesSettings that differ, such as the model
template_changedbooleanYesWhether the template text differs
template_diffstringYesA unified diff of the template text, empty when it is the same
to_versionPromptVersionRefYesThe version on the right

GET /prompts/{prompt_id}/info​

Read one prompt with its template

Read the latest version of a prompt in an environment, with the template text and metadata and the list of environments the prompt exists in. Append .v2 to the id to read one version. Proxy admins and admin viewers only, and an admin key whose own or team prompts field leaves the prompt out gets 400. A remote integration's api_key is shown masked.

Docs

Example Request:

curl -X GET "http://localhost:4000/prompts/support-reply/info?environment=production" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Example Response:

{
"prompt_spec": {
"prompt_id": "support-reply",
"spanway_params": {
"prompt_id": "support-reply",
"prompt_integration": "dotprompt",
"dotprompt_content": "---\nmodel: claude-sonnet-5-5\n---\nGreet {{customer_name}}."
},
"prompt_info": {"prompt_type": "db", "environment": "production"},
"version": 3,
"environment": "production"
},
"raw_prompt_template": {"spanway_prompt_id": "support-reply", "content": "Greet {{customer_name}}."},
"environments": ["development", "production"]
}

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes
environmentquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/prompts/prompt_id-123/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromptInfoResponse
400No prompt has this id in the environment asked for, or the admin key's prompts field leaves it out.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin or admin viewer.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
environmentsarray of string or nullNoEnvironments
prompt_specPromptSpecYes
raw_prompt_templatePromptTemplateBase or nullNo

POST /prompts/{prompt_id}/promote​

Promote a tested prompt version into another environment

Copies one tested version, unchanged, into another environment as that environment's next version. This is the only way into a protected environment (production by default). When the target is protected and the eval verdict is required, eval_run_id must name a completed eval run of exactly this prompt, version and environment whose verdict against its quality gate is passed; any other run is refused. The protected copy stores the text with every partial written out, nested ones included, so a later partial change or delete cannot alter it, and a partial version saved after the eval run started is refused because the run never tested it. The new version records where it came from in prompt_info.promotion. Written to the audit log as updated with operation promote, and sent on the prompt_promoted alert. Proxy admins only. The eval check needs an Enterprise license with evals.

Docs (https://docs.spanway.ai/docs/proxy/prompt_operations#promote-a-tested-version)

curl -X POST http://localhost:4000/prompts/support-reply/promote -H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"from_environment": "staging", "version": 3, "to_environment": "production", "eval_run_id": "run_8f2c1a"}'

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes

Request body (application/json, schema PromotePromptRequest):

FieldTypeRequiredDescription
eval_run_idstring or nullNoA completed eval run of exactly that version
from_environmentstringYesThe environment that holds the tested version
notestring or nullNoWhy it is promoted, kept with it
to_environmentstringYesThe environment to copy it into, usually production
versioninteger or nullNoThe version to promote. Latest when left out

Example request:

curl -X POST "http://localhost:4000/prompts/prompt_id-123/promote" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"eval_run_id": "run_8f2c1a",
"from_environment": "staging",
"note": "Shorter greeting, passed the support eval",
"to_environment": "production",
"version": 3
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PromotePromptResponse
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
409The object already exists or is in a state that does not allow this changeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
promotionPromotionRecordYesWhere it came from and which eval verdict allowed it
promptPromptSpecYesThe new version in the target environment

GET /prompts/{prompt_id}/versions​

List the versions of a prompt

List every stored version of a prompt, newest first, with the version number, environment and author of each. Filter with environment. Proxy admins and admin viewers only.

Docs (https://docs.spanway.ai/docs/proxy/prompt_versions)

Example Request:

curl -X GET "http://localhost:4000/prompts/support-reply/versions?environment=production" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Example Response:

{
"prompts": [
{"prompt_id": "support-reply", "version": 2, "environment": "production", "created_by": "admin"},
{"prompt_id": "support-reply", "version": 1, "environment": "production", "created_by": "admin"}
]
}

Parameters:

NameInTypeRequiredDescription
prompt_idpathstringYes
environmentquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/prompts/prompt_id-123/versions" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json ListPromptsResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key is not a proxy admin or admin viewer.application/json ErrorDetail
404No version of this prompt exists.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
promptsarray of PromptSpecYesPrompts

POST /utils/dotprompt_json_converter​

Convert a .prompt file to JSON

Upload a .prompt file as multipart form data and get back prompt_id, taken from the file name, and json_data, which holds the template body as content and the front matter as metadata. Nothing is stored. To create the prompt, send the file's text to POST /prompts as spanway_params.dotprompt_content with prompt_integration set to dotprompt. The Upload .prompt File dialog of the Admin UI calls this route before it creates the prompt. Any authenticated key may call it.

Request body (multipart/form-data, object):

FieldTypeRequiredDescription
filestringYesThe .prompt file to parse

Example request:

curl -X POST "http://localhost:4000/utils/dotprompt_json_converter" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-F file="@file.bin"

Responses:

StatusDescriptionBody
200The prompt id and the parsed template, nothing is storedapplication/json DotpromptConversion
400The upload is not a .prompt file.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The file could not be parsed.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
json_dataobjectYesThe template body as content and the front matter as metadata
prompt_idstringYesThe prompt id, taken from the uploaded file's name