Hello! Anyone know what is the correct API endpoin...
# ask-ai
k
Hello! Anyone know what is the correct API endpoint for: lk dispatch create \ --agent-name test_agent \ --room aloha2 \ --metadata '{"user_id":"123"}' when I use CLI with this command works fine but when I try to do API call to https://my.livekit.cloud/twirp/agentdispatch.AgentDispatchService/CreateDispatch with same JSON body I have status OK but the room is not created.
t
Thanks for reaching out, Lasha. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I looked into the AgentDispatch CreateDispatch behavior you described. You're calling the wrong Twirp path. Use this endpoint: POST https://my.livekit.cloud/twirp/livekit.AgentDispatchService/CreateDispatch Two quick things to check so the API call behaves like the CLI: • Headers: include
Content-Type: application/json
and an Authorization Bearer JWT with appropriate permissions (room admin/join or agent_admin as needed). • Payload shape:
metadata
must be a JSON-encoded string (not an object). Example body:
Copy code
{
  "agent_name": "test_agent",
  "room": "aloha2",
  "metadata": "{\"user_id\":\"123\"}"
}
If you still get 200 OK but no room, please share (sanitized) the exact request headers and JSON body you sent and whether you used the CLI's stored credentials or your own JWT so I can help pinpoint the issue. Sources: Agent dispatch | LiveKit docs | Python SDKs | livekit/livekit_composite | DeepWiki
k
Great! Please give me a JSON body template for generate a JWT token { "jti": , "iat": , "exp": , "iss": , "sub": , "video": { "roomCreate": true, "roomAdmin": true }, "agent": { "dispatch": true } }
t
Thanks — you're asking for a JSON JWT payload template. Below is a correct template you can use to generate a token. I included required claims, video permissions, and the recommended way to configure agent dispatch (note:
agent.dispatch
is not a valid top-level claim).
Copy code
{
  "jti": "unique-token-id",
  "iat": 1700000000,
  "exp": 1700003600,
  "iss": "API_KEY",
  "sub": "participant-identity",
  "video": {
    "roomCreate": true,
    "roomAdmin": true,
    "room": "specific-room-name"
  },
  "metadata": "optional-metadata-string",
  "attributes": {
    "custom-key": "custom-value"
  },
  "room_config": {
    "agents": [
      {
        "agent_name": "test_agent",
        "metadata": "{\"user_id\":\"123\"}"
      }
    ]
  }
}
Key notes: •
iat
and
exp
are Unix epoch timestamps. •
iss
must be your API key;
sub
is the participant identity. •
video.room
is required when
roomCreate
or
roomAdmin
is true. •
metadata
values are strings. For agent metadata, JSON must be encoded as a string (
"{\"user_id\":\"123\"}"
). • Do not use a top-level
"agent": {"dispatch": true}
claim — agent dispatch is configured via
room_config.agents
(embedded in the token) or via the Agent Dispatch API/SDK. If you want a ready-to-use example in a specific SDK (Node/Python/Go) to sign this token, tell me which one and I’ll provide it. Sources: Server-side | livekit/livekit_composite | DeepWiki | server-sdk-kotlin | livekit/livekit_composite | DeepWiki | server-sdk-go | livekit/livekit_composite | DeepWiki