Skip to main content
POST
Sends a natural-language instruction to Versive’s study-editing agent. The agent can add, edit, delete, and reorder questions, change logic rules, and update study settings and messages. By default changes are saved immediately (with automatic rollback if anything fails); set auto_save: false to preview the mutations and apply them separately. For both default JSON and streaming requests, a detected disconnect cancels pending work and rolls back an in-progress save. JSON edits no longer continue in the background after the client or proxy disconnects. Set your client timeout above the expected edit duration, or use streaming for long edits. If the save completed before the connection was lost, its acknowledgement may be missing; inspect the study before retrying.
string
required
The study ID.
string
default:"application/json"
Set text/event-stream to stream progress and keepalives while the agent runs. The URL, request body, authentication, and final response fields are unchanged.
string
required
The editing instruction, e.g. “Add an NPS question after the intro and screen out anyone who scores under 3 on Q2.”
boolean
default:"true"
Persist changes before returning. Set false to preview.
string
default:"smart"
smart (higher quality) or fast (lower latency).
string
Language context for the edit.

Response

string | null
The agent’s natural-language summary of what it did.
Mutation[]
The structured change list. Each mutation has id, entity_type (question | logic_rule | study_settings | study_messages), operation (create | update | delete | reorder), entity_id, before, after, and timestamp.
object[]
The study’s questions after the edit, each including a resolved mentions array.
object[]
The study’s logic rules after the edit.
object | null
Updated study settings, when changed.
object[]
Any {{Q:...}} references broken by the edit: question_id, placeholder, error, newly_broken.

Streaming

For long edits, send Accept: text/event-stream. The server responds with Content-Type: text/event-stream, Cache-Control: no-cache, and X-Accel-Buffering: no. After authorization and setup, it immediately sends started, then SSE keepalive comments approximately every 15 seconds while waiting, including during saving.
Each connected stream ends with exactly one terminal event: result or error, followed by connection close. A client can ignore all other events and parse the single data: line on result. Tool progress indicates completed in-memory work; with auto_save: true, mutations are saved before result. With auto_save: false, result is a preview you can apply separately. Authentication, access, entitlement, and request/setup validation failures still return normal HTTP errors before streaming begins. After streaming starts, the HTTP status is already 200, so clients must handle the terminal error event. When the server detects a disconnect, it cancels pending agent work. A cancelled save rolls back changes already applied in that batch. If the connection is lost just after a save completes, the client may miss its result; inspect the study before retrying. This endpoint does not deduplicate retries or resume streams. Treat EOF without a terminal event as an interrupted request with an unknown outcome, and disable automatic retries of this POST.

cURL

Use -N (--no-buffer) to display events as they arrive. Use your regional API host (api-eu.getversive.com for EU studies).

Python

This example uses requests. The read timeout limits idle time between received bytes, rather than the total duration of the edit. The small chunk_size lets short keepalives and events reach the parser immediately.

Proxy requirements

Every proxy between the client and Versive must forward Accept: text/event-stream and stream the response immediately, including SSE comments. Disable response buffering, caching, and compression that buffers small chunks; do not collect the body with .json() or .text() before forwarding it. For nginx, use proxy_buffering off and a suitable proxy_read_timeout. Preserve the upstream content type and cancellation: when the downstream client disconnects, abort the upstream request too. Set idle timeouts comfortably above 15 seconds (for example, 60 seconds) and allow a total request duration long enough for the edit. Heartbeats prevent idle read timeouts only when all intermediaries flush them; they cannot extend an absolute request-duration limit. Cloudflare documents a default 125-second Proxy Read Timeout. A buffering customer proxy can still cause a timeout even when Versive streams. To verify the integration, use a test study and check that started appears promptly, comments arrive during quiet periods, and an edit lasting over 125 seconds still ends in result. On a disposable study, start an edit with auto_save: true, disconnect while generation is in progress, and confirm the study remains unchanged after the request has been cancelled. Also remove the Accept header to confirm the default JSON behavior.