Turn the AI agent on or off for a chat, or switch it
curl --request PATCH \
--url https://n-api.leadstaker.com/v1/chats/{id}/agent \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"agentId": "<string>"
}
'import requests
url = "https://n-api.leadstaker.com/v1/chats/{id}/agent"
payload = { "agentId": "<string>" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agentId: '<string>'})
};
fetch('https://n-api.leadstaker.com/v1/chats/{id}/agent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://n-api.leadstaker.com/v1/chats/{id}/agent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'agentId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://n-api.leadstaker.com/v1/chats/{id}/agent"
payload := strings.NewReader("{\n \"agentId\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://n-api.leadstaker.com/v1/chats/{id}/agent")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://n-api.leadstaker.com/v1/chats/{id}/agent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}Chats
Turn the AI agent on or off for a chat, or switch it
Sets the AI agent of the chat to ACTIVE or DISABLED. With agentId, switches the chat to that agent of the project (404 when there is none, or it is archived; 422 TEST_CHAT on a test chat): it takes the status given, else the one the chat had, else ACTIVE, and what the previous agent had queued for the chat (follow-ups, a reply being sent) is dropped. The agent the chat already has only changes the status. Answers 204 with no body.
PATCH
/
v1
/
chats
/
{id}
/
agent
Turn the AI agent on or off for a chat, or switch it
curl --request PATCH \
--url https://n-api.leadstaker.com/v1/chats/{id}/agent \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"agentId": "<string>"
}
'import requests
url = "https://n-api.leadstaker.com/v1/chats/{id}/agent"
payload = { "agentId": "<string>" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agentId: '<string>'})
};
fetch('https://n-api.leadstaker.com/v1/chats/{id}/agent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://n-api.leadstaker.com/v1/chats/{id}/agent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'agentId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://n-api.leadstaker.com/v1/chats/{id}/agent"
payload := strings.NewReader("{\n \"agentId\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://n-api.leadstaker.com/v1/chats/{id}/agent")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://n-api.leadstaker.com/v1/chats/{id}/agent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}{
"errorCode": "<string>",
"message": "<string>",
"status": 123,
"errors": [
{
"field": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}Authorizations
Path Parameters
Minimum string length:
1Body
application/json
ACTIVE or DISABLED. Required without agentId; with it, the chat keeps its status when absent (ACTIVE for a chat that had no agent).
Available options:
ACTIVE, DISABLED Switches the chat to this agent of the project. The chat's current agent only changes the status.
Minimum string length:
1Response
No content