Skip to main content

Overview

The SketricGen Runtime API executes agents that you created in SketricGen. Use it to send a message, continue a conversation, attach previously uploaded files, stream the response, or resume a Human Input pause. The customer-facing Runtime API intentionally exposes one programmatic execution endpoint. Teamspace and agent management belong to the Admin API, while conversational AI management belongs to the SketricGen MCP server. Base URL: https://chat-v2.sketricgen.ai/api/v1

When to use the Runtime API

Use the Runtime API when you want to call an existing SketricGen agent from your own product, backend, workflow runner, or custom UI. Common use cases:
  • Run AI Workforce agents from your own application
  • Add SketricGen agents to an internal product experience
  • Build a custom chat UI instead of using the hosted website widget
  • Trigger an agent from backend jobs or server-side automations
  • Keep conversation identity aligned with users or contacts in your own system
If you only need a copy-paste website chat bubble or iframe, use Deploy an AI Chatbot to a Custom Website instead.

Authentication

Every Runtime API request requires a Teamspace API key with Run agents access. Current keys begin with sk_api_. Create it from Teamspace settings → API keys → Create key. Enable Run agents, choose the narrowest Project and agent scope that supports the integration, and copy the plaintext key when it is shown once. You can also enable Manage resources if the same credential needs Admin API access. Required Header:
The key must have Run agents access. A key with only Manage resources access cannot execute agents through the Runtime API.

Quick start

Keep the Runtime API key on a server or in a secret manager. Do not call the Runtime API directly from public browser code.

Endpoints

Run Workflow

POST /run-workflow Execute an AI workflow using a specified agent to generate intelligent responses based on user input.

Request Headers

Request Body

Example Request

Contact ID and User Grouping

Use contact_id when your product already knows who the end user or contact is. Conversations sent with the same agent_id and contact_id are grouped under the same contact in SketricGen. This is useful when you want to:
  • See all conversations from one customer or app user together
  • Continue reviewing a user’s history across multiple sessions
  • Connect SketricGen conversations back to your CRM, database, or product user record
  • Keep a consistent mapping between SketricGen conversations and your own user records
Use a stable internal ID, UUID, or hashed value. Do not send emails, phone numbers, names, or other directly identifiable personal data as the contact ID. Good examples:
Avoid:

Identity Fields by Deployment Method

contact_id is a Runtime API field. Browser embeds do not accept a caller-supplied contact identifier: API example:
data-contact-id on the embed script and the contactId query parameter on iframe and fullscreen URLs are ignored. Conversations are keyed by contact, so a page-supplied identifier would let any website claim to be one of your known contacts. Embedded widgets receive a server-assigned identity instead, and a returning visitor keeps it through a stored visitor credential.
Use the Runtime API from your backend when conversations must map to your own user records. Requests without contact_id still work; they create conversations with no external user mapping.

Human-in-the-Loop Runs

Human-in-the-loop (HITL) lets an agent pause a Runtime API run and wait for a person to answer a question or approve an action. Use it when your custom application needs to render the request, collect a decision, and continue the same conversation. HITL is disabled by default for Runtime API calls. Set enable_hitl to true on every request where the agent should be allowed to pause, including a request that resumes an earlier pause.
Enabling HITL does not force every run to pause. The run pauses only when the agent reaches a configured HITL-capable tool, such as Human Input or a schedule approval.

1. Start a HITL-enabled run

Send the normal request with enable_hitl: true. HITL works with both non-streaming and streaming responses.
Without enable_hitl: true, HITL-capable tools do not pause the run through the Runtime API.

2. Detect a pause

For a non-streaming request, check run_paused_hitl. When it is true, use the accompanying hitl_request to render the requested decision.
Store the returned conversation_id and hitl_request.request_id. Read action_requests to understand what paused, and use the corresponding review_configs.allowed_decisions entry to determine which decision types your interface can submit. For a streaming request, handle these additional events: After RUN_PAUSED_HITL, close the stream and resume with a new POST /run-workflow request. Runtime API keys do not use the first-party stream attach or cancel path to resume HITL.

3. Submit a decision and resume

Resume through the same POST /run-workflow endpoint. Send the original conversation_id, keep enable_hitl: true, and pass one decision for each pending action in the order returned by action_requests.
Do not send a new user_input when resuming. The decision continues the paused run on the existing conversation. A resumed run can pause again, which is why enable_hitl: true must also be present on the resume request.

Decision types

Use only a decision type returned in review_configs.allowed_decisions. If the pause contains multiple actions, submit the same number of decisions in the same order. Do not infer that approve or reject is supported when the corresponding review configuration allows only respond.

Resume errors

Treat a resume as a single-use operation. Disable duplicate submission in your interface while the resume request is in progress.

Response Formats

The endpoint supports two response modes.

1. Standard Response (stream: false)

HTTP Status: 201 Created Response Body: The response does not echo contact_id. Track the contact identifier you sent in your own system, or read it back from the conversation record. Example Response:

2. Streaming Response (stream: true)

HTTP Status: 200 OK Content-Type: text/event-stream When streaming is enabled, the endpoint returns real-time Server-Sent Events (SSE) as the AI processes the request. Event Types: RUN_FINISHED, RUN_ERROR, RUN_PAUSED_HITL, and RUN_HALTED_OUT_OF_CREDITS are all terminal for the current turn. Treat any of them as the end of the stream rather than waiting for RUN_FINISHED alone. Example Streaming Events: