Execute Agent
Executes the specified agent and returns a non-streaming JSON response with the complete agent output. The agent must be active and belong to the specified location, with locationId required in the request body. For initial messages, exclude executionId. The API returns an executionId that identifies the conversation session. Include this ID in follow-up requests to maintain context across interactions.
POST
/
agent-studio
/
public-api
/
agents
/
{agentId}
/
execute
Execute Agent
curl --request POST \
--url https://services.leadconnectorhq.com/agent-studio/public-api/agents/{agentId}/execute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Version: <version>' \
--data '
{
"locationId": "loc_abc123",
"message": "What services do you offer?",
"executionId": "exec_abc123",
"contactId": "contact_abc123"
}
'const options = {
method: 'POST',
headers: {
Version: '<version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
locationId: 'loc_abc123',
message: 'What services do you offer?',
executionId: 'exec_abc123',
contactId: 'contact_abc123'
})
};
fetch('https://services.leadconnectorhq.com/agent-studio/public-api/agents/{agentId}/execute', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://services.leadconnectorhq.com/agent-studio/public-api/agents/{agentId}/execute"
payload = {
"locationId": "loc_abc123",
"message": "What services do you offer?",
"executionId": "exec_abc123",
"contactId": "contact_abc123"
}
headers = {
"Version": "<version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"executionId": "exec_abc123",
"agentId": "<string>",
"response": "<string>",
"actions": [
{
"type": "<string>",
"status": "<string>",
"result": {}
}
],
"metadata": {
"tokensUsed": 123,
"executionTimeMs": 123
}
}{
"statusCode": 400,
"message": "Bad Request"
}{
"statusCode": 401,
"message": "Invalid token: access token is invalid",
"error": "Unauthorized"
}{
"statusCode": 403,
"message": "User lacks required scopes",
"error": "Forbidden"
}{
"statusCode": 404,
"message": "Agent not found",
"error": "Not Found"
}{
"statusCode": 422,
"message": [
"Unprocessable Entity"
],
"error": "Unprocessable Entity"
}{
"statusCode": 500,
"message": "Internal server error",
"error": "Internal Server Error"
}Authorizations
Body
application/json
Response
Agent executed successfully
Last modified on March 7, 2026
Was this page helpful?
Execute Agent
curl --request POST \
--url https://services.leadconnectorhq.com/agent-studio/public-api/agents/{agentId}/execute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Version: <version>' \
--data '
{
"locationId": "loc_abc123",
"message": "What services do you offer?",
"executionId": "exec_abc123",
"contactId": "contact_abc123"
}
'const options = {
method: 'POST',
headers: {
Version: '<version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
locationId: 'loc_abc123',
message: 'What services do you offer?',
executionId: 'exec_abc123',
contactId: 'contact_abc123'
})
};
fetch('https://services.leadconnectorhq.com/agent-studio/public-api/agents/{agentId}/execute', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://services.leadconnectorhq.com/agent-studio/public-api/agents/{agentId}/execute"
payload = {
"locationId": "loc_abc123",
"message": "What services do you offer?",
"executionId": "exec_abc123",
"contactId": "contact_abc123"
}
headers = {
"Version": "<version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"executionId": "exec_abc123",
"agentId": "<string>",
"response": "<string>",
"actions": [
{
"type": "<string>",
"status": "<string>",
"result": {}
}
],
"metadata": {
"tokensUsed": 123,
"executionTimeMs": 123
}
}{
"statusCode": 400,
"message": "Bad Request"
}{
"statusCode": 401,
"message": "Invalid token: access token is invalid",
"error": "Unauthorized"
}{
"statusCode": 403,
"message": "User lacks required scopes",
"error": "Forbidden"
}{
"statusCode": 404,
"message": "Agent not found",
"error": "Not Found"
}{
"statusCode": 422,
"message": [
"Unprocessable Entity"
],
"error": "Unprocessable Entity"
}{
"statusCode": 500,
"message": "Internal server error",
"error": "Internal Server Error"
}