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.
| Method | Path | Summary |
|---|---|---|
| POST | /prompts | Create a prompt |
| GET | /prompts/list | List stored prompts (admins) |
| GET | /prompts/ops/git_syncs | List repository connections for prompts |
| POST | /prompts/ops/git_syncs | Connect a repository for prompts |
| DELETE | /prompts/ops/git_syncs/{sync_id} | Remove a repository connection |
| POST | /prompts/ops/git_syncs/{sync_id}/pull | Pull prompts from the repository |
| POST | /prompts/ops/git_syncs/{sync_id}/push | Push prompts to the repository as one commit |
| GET | /prompts/ops/partials | List prompt partials |
| POST | /prompts/ops/partials | Save 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/settings | Read the prompt protection and alert settings |
| PUT | /prompts/ops/settings | Change the prompt protection and alert settings |
| POST | /prompts/test | Render 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}/diff | Compare two versions of a prompt |
| GET | /prompts/{prompt_id}/info | Read one prompt with its template |
| POST | /prompts/{prompt_id}/promote | Promote a tested prompt version into another environment |
| GET | /prompts/{prompt_id}/versions | List the versions of a prompt |
| POST | /utils/dotprompt_json_converter | Convert 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.
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):
| Field | Type | Required | Description |
|---|---|---|---|
prompt_id | string | Yes | Prompt Id |
prompt_info | PromptInfo or null | No | |
spanway_params | PromptSpanwayParams | Yes |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The prompt version as stored. | application/json PromptSpec |
| 400 | spanway_params.prompt_id is combined with prompt_data keyed by template name. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin. | application/json ErrorDetail |
| 409 | The environment is protected, so it only takes promoted versions. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, so prompts cannot be stored. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
environment | string or null | No | Environment |
prompt_id | string | Yes | Prompt Id |
prompt_info | PromptInfo | Yes | |
spanway_params | PromptSpanwayParams | Yes | |
updated_at | string or null | No | Updated At |
version | integer or null | No | Version |
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.
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
environment | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/prompts/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json ListPromptsResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
prompts | array of PromptSpec | Yes | Prompts |
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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json GitSyncListResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins and admin viewers can read repository connections | application/json ErrorDetail |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
syncs | array of GitSyncView | Yes | Every 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):
| Field | Type | Required | Description |
|---|---|---|---|
access_token | string | Yes | A token that may read and write the repository. Stored encrypted |
api_base | string or null | No | Self-managed GitLab API address, https only. Empty for gitlab.com |
branch | string | No | The branch to read and write |
environment | string | No | Where pulled prompts are saved. A protected environment is refused |
name | string | Yes | A short name for the connection |
path | string | No | The folder that holds .prompt files |
provider | enum: "gitlab", "bitbucket" | Yes | gitlab or bitbucket |
repository | string | Yes | group/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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json GitSyncView |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can change repository connections | application/json ErrorDetail |
| 409 | A repository connection named support-prompts already exists | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_token_set | boolean | Yes | Whether a token is stored. The token itself is never returned |
api_base | string or null | No | The self-managed GitLab API address, if any |
branch | string | Yes | The branch |
created_at | string or null | No | When it was added |
created_by | string or null | No | Who added the connection |
environment | string | Yes | Where pulled prompts are saved |
last_commit | string or null | No | The commit the last push created |
last_error | string or null | No | Why the last pull or push failed, if it did |
last_pull_at | string or null | No | When prompts were last pulled |
last_push_at | string or null | No | When prompts were last pushed |
name | string | Yes | The connection's name |
path | string | Yes | The folder that holds .prompt files |
provider | enum: "gitlab", "bitbucket" | Yes | gitlab or bitbucket |
repository | string | Yes | The repository |
sync_id | string | Yes | The 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
sync_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/prompts/ops/git_syncs/sync_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json GitSyncView |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can change repository connections | application/json ErrorDetail |
| 404 | Repository connection 8c1f0e1a-2b7d-4f7e-9a51-1d2a6f3b9c40 not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_token_set | boolean | Yes | Whether a token is stored. The token itself is never returned |
api_base | string or null | No | The self-managed GitLab API address, if any |
branch | string | Yes | The branch |
created_at | string or null | No | When it was added |
created_by | string or null | No | Who added the connection |
environment | string | Yes | Where pulled prompts are saved |
last_commit | string or null | No | The commit the last push created |
last_error | string or null | No | Why the last pull or push failed, if it did |
last_pull_at | string or null | No | When prompts were last pulled |
last_push_at | string or null | No | When prompts were last pushed |
name | string | Yes | The connection's name |
path | string | Yes | The folder that holds .prompt files |
provider | enum: "gitlab", "bitbucket" | Yes | gitlab or bitbucket |
repository | string | Yes | The repository |
sync_id | string | Yes | The 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
sync_id | path | string | Yes |
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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json GitPullResult |
| 400 | The stored access token cannot be read with this gateway's key. Delete the connection and add it again. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can pull prompts from a repository | application/json ErrorDetail |
| 404 | Repository connection 8c1f0e1a-2b7d-4f7e-9a51-1d2a6f3b9c40 not found | application/json ErrorDetail |
| 409 | The development environment is protected, so pulled prompts cannot be saved there. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
| 502 | The repository host refused or failed the call. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created | array of string | Yes | Prompts that did not exist and were created |
environment | string | Yes | Where the prompts were saved |
skipped | array of GitSkippedFile | Yes | Files that were not imported, with the reason |
sync_id | string | Yes | The connection that was pulled |
unchanged | array of string | Yes | Prompts that already matched the repository |
updated | array of string | Yes | Prompts 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
sync_id | path | string | Yes |
Request body (application/json, schema GitPushRequest):
| Field | Type | Required | Description |
|---|---|---|---|
environment | string or null | No | Which environment to write out. The connection's environment when left out |
message | string or null | No | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json GitPushResult |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can push prompts to a repository | application/json ErrorDetail |
| 404 | Repository connection 8c1f0e1a-2b7d-4f7e-9a51-1d2a6f3b9c40 not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
| 502 | The repository host refused or failed the call. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
commit | string or null | No | The new commit, empty when nothing changed |
environment | string | Yes | The environment that was written out |
skipped | array of GitSkippedFile | Yes | Prompts that were not written, with the reason |
sync_id | string | Yes | The connection that was pushed |
written | array of string | Yes | Files 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptPartialListResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins and admin viewers can read prompt partials | application/json ErrorDetail |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
partials | array of PromptPartialSummary | Yes | Every 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):
| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | The reusable text |
description | string or null | No | What the partial is for |
name | string | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptPartial |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can change prompt partials | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | The text of this version |
created_at | string or null | No | When this version was saved |
created_by | string or null | No | Who saved this version |
description | string or null | No | What the partial is for |
name | string | Yes | The partial's name |
version | integer | Yes | The 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
name | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/prompts/ops/partials/name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptPartialVersionsResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins and admin viewers can read prompt partials | application/json ErrorDetail |
| 404 | Partial tone not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
partials | array of PromptPartial | Yes | Every 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
name | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/prompts/ops/partials/name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptPartialDeletedResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can change prompt partials | application/json ErrorDetail |
| 404 | Partial tone not found | application/json ErrorDetail |
| 409 | Partial tone is still used by support-reply (staging), partial greeting. Remove it from those prompts and partials first. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
deleted_versions | integer | Yes | How many versions were removed |
name | string | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptOpsSettingsView |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins and admin viewers can read prompt settings | application/json ErrorDetail |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alert_emails | array of string | No | Who gets an email when a prompt changes. Empty sends no email |
email_on | array of enum: "created", "updated", "deleted", "promoted" | No | Which prompt changes send that email |
protected_environments | array of string | No | Environments that only take promoted versions. Direct saves and deletes there are refused |
require_eval_verdict | boolean | No | When true, promoting into a protected environment needs a passed eval run of that version |
updated_at | string or null | No | When the settings were saved last |
updated_by | string or null | No | Who 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):
| Field | Type | Required | Description |
|---|---|---|---|
alert_emails | array of string | No | Who gets an email when a prompt changes. Empty sends no email |
email_on | array of enum: "created", "updated", "deleted", "promoted" | No | Which prompt changes send that email |
protected_environments | array of string | No | Environments that only take promoted versions. Direct saves and deletes there are refused |
require_eval_verdict | boolean | No | When 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptOpsSettingsView |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins can change prompt settings | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alert_emails | array of string | No | Who gets an email when a prompt changes. Empty sends no email |
email_on | array of enum: "created", "updated", "deleted", "promoted" | No | Which prompt changes send that email |
protected_environments | array of string | No | Environments that only take promoted versions. Direct saves and deletes there are refused |
require_eval_verdict | boolean | No | When true, promoting into a protected environment needs a passed eval run of that version |
updated_at | string or null | No | When the settings were saved last |
updated_by | string or null | No | Who 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):
| Field | Type | Required | Description |
|---|---|---|---|
conversation_history | array of object or null | No | Conversation History |
dotprompt_content | string | Yes | Dotprompt Content |
prompt_variables | object or null | No | Prompt 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:
| Status | Description | Body |
|---|---|---|
| 200 | The model reply as a stream of chat completion chunks, as /chat/completions streams them. | text/event-stream string |
| 400 | The front matter names no model, the template renders no messages, or a variable is missing. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The 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.
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes | |
environment | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/prompts/prompt_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptInfoResponse |
| 400 | No prompt has this id in the environment asked for, or the admin key's prompts field leaves it out. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
environments | array of string or null | No | Environments |
prompt_spec | PromptSpec | Yes | |
raw_prompt_template | PromptTemplateBase or null | No |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes |
Request body (application/json, schema Prompt):
| Field | Type | Required | Description |
|---|---|---|---|
prompt_id | string | Yes | Prompt Id |
prompt_info | PromptInfo or null | No | |
spanway_params | PromptSpanwayParams | Yes |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The prompt version as stored. | application/json PromptSpec |
| 400 | The prompt comes from the config file, which this route cannot change. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin. | application/json ErrorDetail |
| 404 | No prompt has this id. | application/json ErrorDetail |
| 409 | The environment is protected, so it only takes promoted versions. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, so prompts cannot be stored. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
environment | string or null | No | Environment |
prompt_id | string | Yes | Prompt Id |
prompt_info | PromptInfo | Yes | |
spanway_params | PromptSpanwayParams | Yes | |
updated_at | string or null | No | Updated At |
version | integer or null | No | Version |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes | |
environment | query | string or null | No |
Request body (application/json, schema PatchPromptRequest):
| Field | Type | Required | Description |
|---|---|---|---|
prompt_info | PromptInfo or null | No | |
spanway_params | PromptSpanwayParams or null | No |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The prompt version as stored. | application/json PromptSpec |
| 400 | The prompt comes from the config file, which this route cannot change. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin. | application/json ErrorDetail |
| 404 | No version of this prompt exists in the environment. | application/json ErrorDetail |
| 409 | The environment is protected, so it only takes promoted versions. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, so prompts cannot be stored. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
environment | string or null | No | Environment |
prompt_id | string | Yes | Prompt Id |
prompt_info | PromptInfo | Yes | |
spanway_params | PromptSpanwayParams | Yes | |
updated_at | string or null | No | Updated At |
version | integer or null | No | Version |
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.
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes | |
environment | query | string or null | No |
Example request:
curl -X DELETE "http://localhost:4000/prompts/prompt_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every version in the environment, or in every environment, is gone. | application/json PromptDeletedResponse |
| 400 | The prompt comes from the config file. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin. | application/json ErrorDetail |
| 404 | No prompt has this id. | application/json ErrorDetail |
| 409 | The environment is protected, so it only takes promoted versions. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, so prompts cannot be stored. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes | |
from_environment | query | string | No | |
to_environment | query | string or null | No | |
from_version | query | integer or null | No | |
to_version | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/prompts/prompt_id-123/diff" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptDiffResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only proxy admins and admin viewers can compare prompt versions | application/json ErrorDetail |
| 404 | Prompt support-reply has no version 9 in staging | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
from_version | PromptVersionRef | Yes | The version on the left |
prompt_id | string | Yes | The prompt compared |
settings_changed | array of SettingChange | Yes | Settings that differ, such as the model |
template_changed | boolean | Yes | Whether the template text differs |
template_diff | string | Yes | A unified diff of the template text, empty when it is the same |
to_version | PromptVersionRef | Yes | The 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.
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes | |
environment | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/prompts/prompt_id-123/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromptInfoResponse |
| 400 | No prompt has this id in the environment asked for, or the admin key's prompts field leaves it out. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
environments | array of string or null | No | Environments |
prompt_spec | PromptSpec | Yes | |
raw_prompt_template | PromptTemplateBase or null | No |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes |
Request body (application/json, schema PromotePromptRequest):
| Field | Type | Required | Description |
|---|---|---|---|
eval_run_id | string or null | No | A completed eval run of exactly that version |
from_environment | string | Yes | The environment that holds the tested version |
note | string or null | No | Why it is promoted, kept with it |
to_environment | string | Yes | The environment to copy it into, usually production |
version | integer or null | No | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PromotePromptResponse |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 409 | The object already exists or is in a state that does not allow this change | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
promotion | PromotionRecord | Yes | Where it came from and which eval verdict allowed it |
prompt | PromptSpec | Yes | The 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_id | path | string | Yes | |
environment | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/prompts/prompt_id-123/versions" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json ListPromptsResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer. | application/json ErrorDetail |
| 404 | No version of this prompt exists. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
prompts | array of PromptSpec | Yes | Prompts |
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):
| Field | Type | Required | Description |
|---|---|---|---|
file | string | Yes | The .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:
| Status | Description | Body |
|---|---|---|
| 200 | The prompt id and the parsed template, nothing is stored | application/json DotpromptConversion |
| 400 | The upload is not a .prompt file. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The file could not be parsed. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
json_data | object | Yes | The template body as content and the front matter as metadata |
prompt_id | string | Yes | The prompt id, taken from the uploaded file's name |