Docs menu

Regenerate agent message legacy

POST /v1/organisations/{organisation_id}/workspaces/{workspace_id}/conversations/{conversation_id}/messages/{message_id}/regenerate Deprecated

Writes another reply in place of one of the assistant's and streams it, as sendAgentMessage does. The question stays; the earlier reply (with whatever followed it) stays as another version of that point of the chat.

Authentication

Send an API key, or an access token from your organisation’s identity provider, in the Authorization header. How API keys work

Scope the API key needs: conversations:write

Security schemes in the OpenAPI document: session_cookie (cookie __Host-ivy_session)bearer (bearer)api_key (bearer)

Parameters

  • organisation_id path string required
  • workspace_id path string required
  • conversation_id path string required
  • message_id path string required

Request body

application/json RegenerateMessage required

  • model string | null

Responses

  • 200 text/event-stream AgentStreamEvent

    Server-sent events

    Response headers: Ivy-Run-Id

  • 401 application/json ErrorBody

    unauthenticated

  • 402 application/json ErrorBody

    usage_limit_reached, billing_restricted

  • 403 application/json ErrorBody

    workspace_content_restricted, invalid_origin, insufficient_scope; with several people, only the person a reply acted for regenerates it

  • 404 application/json ErrorBody

    No such chat of the caller's in this space, or no such message in its current version

  • 409 application/json ErrorBody

    run_in_progress while the assistant is answering in this chat; workspace_archived

  • 422 application/json ErrorBody

    validation_failed, also when the message isn't the assistant's; invalid_model; agent_unavailable

  • 429 application/json ErrorBody

    rate_limited: the API key's requests per minute are used up; retry after Retry-After seconds

  • 503 application/json ErrorBody

    agent_unavailable; or unavailable: the database is briefly unavailable; retry after Retry-After seconds

Server-sent events

The response is a text/event-stream. Each event is named after one of these, and its data is the JSON of the schema shown.

  • message_start AgentMessageStart

    Data of the message_start SSE event.

  • text_delta AgentTextDelta

    Data of the text_delta SSE event.

  • Data of the thinking SSE event: the summarized progress note so far, replacing the one before it.

  • tool_call AgentToolCall

    Data of the tool_call SSE event.

  • tool_result AgentToolResult

    Data of the tool_result SSE event.

  • tool_progress AgentToolProgress

    Live output of a running tool: a bash command's output, or an event of the code run that run_code started (event is then the run's event name: stdout, stderr, output_file, …).

  • sandbox_status AgentSandboxStatus

    The conversation's sandbox. reason says why it stopped or is unavailable; a new one is started (with a fresh working copy) the next time the assistant needs a shell.

  • app_status AppInstance

    One running copy of an app: in the sandbox session of a conversation, or the space's own.

  • changes_saved AgentChangesSaved

    Files the sandbox created or changed, saved as new versions after a step.

  • changes_pending AgentChangesPending

    Deletes and conflicting overwrites the sandbox made, held until the person confirms them (…/sandbox/changes/{change_set_id}/apply or /discard).

  • Data of the done SSE event.

  • Data of the error SSE event. The stream ends after it.

Example stream
id: 1
event: message_start
data: {"message_id":"message_123","model":"string"}

id: 2
event: text_delta
data: {"text":"Hello, Ivy"}

id: 3
event: thinking
data: {"text":"Hello, Ivy"}

id: 4
event: tool_call
data: {"id":"id_123","input":{},"name":"Ada Lovelace"}

id: 5
event: tool_result
data: {"files":[{"file_id":"file_123","name":"Ada Lovelace","path":"string","space_id":"space_123","version":1,"workspace_id":"workspace_123"}],"id":"id_123","invalidates":["workspaces"],"sources":[{"title":"string","url":"https://example.com"}],"status":"ok","summary":"string","view":{"app_id":"app_123","instance_id":"instance_123","kind":"page","result":{},"source_space_id":"source_space_123","source_workspace_id":"source_workspace_123","ui":"string","version_id":"version_123"}}

id: 6
event: tool_progress
data: {"data":{},"event":"string","tool_use_id":"tool_use_123"}

id: 7
event: sandbox_status
data: {"reason":"string","state":"starting"}

id: 8
event: app_status
data: {"access":"read","app_id":"app_123","conversation_id":"conversation_123","frontend":"builtin","id":"id_123","last_active_at":"2026-01-15T09:30:00Z","name":{"de":"string","el":"string","en":"string","es":"string","fr":"string","hu":"string","it":"string"},"owner":"session","reason":"string","snapshot_hash":"string","started_at":"2026-01-15T09:30:00Z","state":"starting","status":{"dropped":["string"],"processes":[{"busy":"string","error":"string","exit_code":1,"id":"id_123","ports":[],"progress":1,"restarts":0,"state":{},"text":"Hello, Ivy"}],"skipped":["string"]},"stopped_at":"2026-01-15T09:30:00Z"}

id: 9
event: changes_saved
data: {"checkpoint":0,"files":[{"change":"created","check":{"file_id":"file_123","kind":{},"path_changes":[],"problems":[],"reference":{},"valid":false,"version_id":"version_123"},"file_id":"file_123","path":"string","version_id":"version_123"}],"skipped":["string"]}

id: 10
event: changes_pending
data: {"change_set_id":"change_set_123","conflicts":[{"base_version_id":"base_version_123","current_version_id":"current_version_123","file_id":"file_123","path":"string"}],"deletes":[{"file_id":"file_123","path":"string"}]}

id: 11
event: done
data: {"message":{"acting_for":{"id":"id_123","type":{}},"ask_id":"ask_123","attachments":[{"file_id":"file_123","name":"Ada Lovelace"}],"author":{"id":"id_123","type":{}},"author_name":"Ada Lovelace","branch":{"count":0,"index":0},"created_at":"2026-01-15T09:30:00Z","deleted_at":"2026-01-15T09:30:00Z","edited_at":"2026-01-15T09:30:00Z","feedback":"up","file_links":[{"file_id":"file_123","name":"Ada Lovelace","path":"string","space_id":"space_123","version":1,"workspace_id":"workspace_123"}],"id":"id_123","in_reply_to":"string","mentions":["string"],"model":"string","notice":{"actor":{},"channel_id":"channel_123","conversation_id":"conversation_123","kind":{},"participants":[],"title":"string"},"origin":{"platform_message_id":"platform_message_123","source":{}},"parts":[{"text":"Hello, Ivy","type":"text"}],"quote":{"author":{},"author_name":"Ada Lovelace","created_at":"2026-01-15T09:30:00Z","deleted":false,"excerpt":"string","message_id":"message_123"},"reactions":[{"emoji":"string","participants":[]}],"read_through":"string","role":"user","stopped_by":{"id":"id_123","type":{}},"thinking":[{"before_part":0,"duration_ms":0,"text":"Hello, Ivy"}]}}

id: 12
event: error
data: {"code":"not_found","message":"A short explanation for people"}

Error codes

Errors come back as an ErrorBody whose code is one of these.

  • 401 unauthenticated
  • 402 usage_limit_reachedbilling_restricted
  • 403 workspace_content_restrictedinvalid_origininsufficient_scope
  • 404 not_found generic code for this status
  • 409 run_in_progressworkspace_archived
  • 422 validation_failedinvalid_modelagent_unavailable
  • 429 rate_limited
  • 503 agent_unavailableunavailable

Examples

curl
curl -X POST -N "$IVY_API_URL/v1/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/conversations/$CONVERSATION_ID/messages/$MESSAGE_ID/regenerate" \
  -H "Authorization: Bearer $IVY_API_KEY" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{}'
JavaScript SDK
import { client, regenerateAgentMessageLegacy } from "@spacivapp/ivy-sdk";

client.setConfig({
  baseUrl: process.env.IVY_API_URL,
  headers: { Authorization: `Bearer ${process.env.IVY_API_KEY}` },
});

const { data, error, response } = await regenerateAgentMessageLegacy({
  path: { organisation_id: organisationId, workspace_id: workspaceId, conversation_id: conversationId, message_id: messageId },
  body: {},
});
Example request body
{
  "model": "string"
}