1. AI Agent
  • Getting Started
    • Introduction
    • Quickstart
    • Authentication
    • Status codes
  • Webhook
    • Webhook Setup
    • Webhook Events and Schema
  • SDKs
    • @klink.cloud/call-sdk
  • API Reference
    • Contact
      • Listing
      • Create
      • Filter By SocialPlatformId
      • Form Fields
      • Detail
      • Update
      • Delete
      • Fetch Contact Groups
      • Update tags
      • Filter By Phone Number
    • Tag
      • Listing
    • Channel
      • Listing
      • Create
    • Ticket
      • Listing
      • Create
      • Filter by Contact ID
      • Form Fields
      • Update
      • Update status
    • Category
      • Listing
    • CxLog
      • Listing
      • Get the live transcript
    • Message
      • Send message
      • Create comments
      • Get Comments
      • List WhatsApp templates
    • Media Manager
      • Upload File (multipart)
      • Get Folders
      • Get Folder By ID
      • Create Folder
      • Update Folder
      • Delete Folder
      • Get Files
      • Get File By ID
      • Create File
      • Update File
      • Delete File
    • Agent Activity
      • Get Agents Activities
    • Telephony
      • Get Telephony CDR
    • User
      • Create
      • Listing
      • Detail
      • Update
      • Delete
    • Automation Queue
      • Create
      • Listing
      • Detail
      • Update
      • Delete
      • Add Member
      • Remove Member
    • Role
      • Listing
    • Webchat Identity Verification
      • Get identity verification settings
      • Update identity verification settings
      • Create or rotate the identity secret
    • AI Agent
      • List Models
        GET
      • Listing
        GET
      • Detail
        GET
      • Create
        POST
      • Update
        PATCH
      • Delete
        DELETE
      • Get Flow
        GET
      • List Versions
        GET
      • Update Flow
        PUT
      • Publish
        POST
    • Schemas
      • RequestId
      • CxLogTranscriptResponse
      • IdentityVerificationStatus
      • CxLogTranscript
      • IdentityVerificationUpdate
      • Error
      • IdentityVerificationSettings
      • ValidationError
      • IdentitySecret
      • userToken (JWT claims)
Blog
Github
  1. AI Agent

Update Flow

PUT
/api/v1/ai-agents/{id}/flow
Replaces the agent's whole draft flow. Customers are not affected until you Publish.
Because this is a full replace, send every node and edge. To change one prompt, Get Flow first, edit it, and send everything back. Builder-only settings (integration tools, layout) are kept for nodes whose id and type are unchanged.
Takes about 4 seconds.
Flow rules. Exactly one startingPoint, and it must connect to another node. Node and edge IDs must be unique, and every edge must point at existing nodes. Also follow the builder's wiring rules, which the API does not check: a humanAgentNode may only be reached from a conditionNode; a conditionNode has exactly one outgoing edge and never leads to another conditionNode; an agentNode never connects directly to a knowledgeBaseNode. Typical shape: startingPoint → agentNode → conditionNode → humanAgentNode.

Request

Authorization
Bearer Token
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
or
Path Params

Body Params application/jsonRequired

Examples

Responses

🟢200Success
application/json
The saved draft flow.
Bodyapplication/json

🟠400Bad Request
🟠401Unauthorized
🟠404Not Found
🟠422Unprocessable Entity
🟠429Too Many Requests
🔴502Bad Gateway
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request PUT 'https://apigw.klinkcx.com/api/v1/ai-agents/6ad97ee52845b4f2c8daca55/flow' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gpt-6-luna",
    "nodes": [
        {
            "id": "start",
            "type": "startingPoint",
            "label": "Start",
            "position": {
                "x": 0,
                "y": 0
            }
        },
        {
            "id": "agent-main",
            "type": "agentNode",
            "label": "Sales Assistant",
            "position": {
                "x": 320,
                "y": 0
            },
            "instruction": "You are the sales assistant for Example Co. Reply in the customer'\''s language.\n\nGreet [contact name] and ask how you can help.\nOpening hours: Mon-Fri 9:00-18:00."
        },
        {
            "id": "cond-human",
            "type": "conditionNode",
            "label": "Needs a human",
            "position": {
                "x": 640,
                "y": 0
            },
            "instruction": "The customer asks to talk to a person, wants to place an order, or complains. Otherwise, no."
        },
        {
            "id": "human",
            "type": "humanAgentNode",
            "label": "Sales team",
            "position": {
                "x": 960,
                "y": 0
            },
            "instruction": "Tell the customer a sales specialist will join shortly."
        }
    ],
    "edges": [
        {
            "id": "e1",
            "source": "start",
            "target": "agent-main"
        },
        {
            "id": "e2",
            "source": "agent-main",
            "target": "cond-human"
        },
        {
            "id": "e3",
            "source": "cond-human",
            "target": "human"
        }
    ]
}'
Response Response Example
200 - Example 1
{
    "requestId": "string",
    "data": {
        "id": "string",
        "status": "draft",
        "version": "string",
        "model": "string",
        "savedAt": "string",
        "nodes": [
            {
                "id": "string",
                "type": "startingPoint",
                "label": "string",
                "position": {
                    "x": 0,
                    "y": 0
                },
                "instruction": "string",
                "toolIds": [
                    "string"
                ],
                "tools": [
                    {
                        "id": "string",
                        "name": "string",
                        "description": "string"
                    }
                ],
                "providerTools": [
                    {
                        "id": "string",
                        "name": "string"
                    }
                ],
                "knowledgeSourceIds": [
                    "string"
                ],
                "vectorStoreIds": [
                    "string"
                ],
                "correction": true,
                "correctionGroupIds": [
                    "string"
                ],
                "waitSeconds": 0
            }
        ],
        "edges": [
            {
                "id": "string",
                "source": "string",
                "target": "string",
                "sourceHandle": "string",
                "targetHandle": "string"
            }
        ]
    }
}
Modified at 2026-10-23 02:08:40
Previous
List Versions
Next
Publish
Built with