result = niadra.search(
phone("+14155550123"),
"credit for missed technician visit",
max_tokens=300,
conversation_id="call-4471",
voice=True,
)
if result.recurrence:
print(result.recurrence.occurrences, result.recurrence.last_resolution)const { data } = await niadra.search({
subject: handles.phone("+14155550123"),
query: "credit for missed technician visit",
max_tokens: 300,
conversation_id: "call-4471",
});
if (data?.recurrence) {
console.log(data.recurrence.occurrences, data.recurrence.last_resolution);
}curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/history/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subject": {
"type": "phone_e164",
"value": "+14155550123"
},
"query": "credit for missed technician visit",
"max_tokens": 300,
"verification": "V1",
"conversation_id": "call-4471"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subject: {type: 'phone_e164', value: '+14155550123'},
query: 'credit for missed technician visit',
max_tokens: 300,
verification: 'V1',
conversation_id: 'call-4471'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/history/search', 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://{space}.{region}.api.niadra.com/v1/history/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'subject' => [
'type' => 'phone_e164',
'value' => '+14155550123'
],
'query' => 'credit for missed technician visit',
'max_tokens' => 300,
'verification' => 'V1',
'conversation_id' => 'call-4471'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://{space}.{region}.api.niadra.com/v1/history/search"
payload := strings.NewReader("{\n \"subject\": {\n \"type\": \"phone_e164\",\n \"value\": \"+14155550123\"\n },\n \"query\": \"credit for missed technician visit\",\n \"max_tokens\": 300,\n \"verification\": \"V1\",\n \"conversation_id\": \"call-4471\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.post("https://{space}.{region}.api.niadra.com/v1/history/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"subject\": {\n \"type\": \"phone_e164\",\n \"value\": \"+14155550123\"\n },\n \"query\": \"credit for missed technician visit\",\n \"max_tokens\": 300,\n \"verification\": \"V1\",\n \"conversation_id\": \"call-4471\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/history/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subject\": {\n \"type\": \"phone_e164\",\n \"value\": \"+14155550123\"\n },\n \"query\": \"credit for missed technician visit\",\n \"max_tokens\": 300,\n \"verification\": \"V1\",\n \"conversation_id\": \"call-4471\"\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "ep_01J2",
"kind": "episode",
"text": "Technician did not show up · $40 credit on the April bill · settled",
"at": "2026-03-12T14:20:00Z",
"channel": "voice",
"source_id": "src_voice",
"outcome": "resolved",
"confidence": 0.94,
"origin_event_id": "evt_01J2A"
},
{
"id": "ep_01J3",
"kind": "episode",
"text": "Customer confirmed the credit and the new visit",
"at": "2026-03-14T12:02:00Z",
"channel": "whatsapp",
"source_id": "src_whatsapp",
"outcome": "resolved",
"confidence": 0.91,
"origin_event_id": "evt_01J3C"
}
],
"recurrence": {
"category": "technician_visit",
"occurrences": 2,
"window_days": 365,
"last_at": "2026-03-12T14:20:00Z",
"last_outcome": "resolved",
"last_resolution": "$40 credit"
},
"withheld": 0,
"as_of": "2026-09-22T17:07:02Z",
"tokens_used": 61,
"degraded": null
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Buscar no histórico
Busca por palavra e por significado no histórico de um cliente, com recorrência calculada.
result = niadra.search(
phone("+14155550123"),
"credit for missed technician visit",
max_tokens=300,
conversation_id="call-4471",
voice=True,
)
if result.recurrence:
print(result.recurrence.occurrences, result.recurrence.last_resolution)const { data } = await niadra.search({
subject: handles.phone("+14155550123"),
query: "credit for missed technician visit",
max_tokens: 300,
conversation_id: "call-4471",
});
if (data?.recurrence) {
console.log(data.recurrence.occurrences, data.recurrence.last_resolution);
}curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/history/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subject": {
"type": "phone_e164",
"value": "+14155550123"
},
"query": "credit for missed technician visit",
"max_tokens": 300,
"verification": "V1",
"conversation_id": "call-4471"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subject: {type: 'phone_e164', value: '+14155550123'},
query: 'credit for missed technician visit',
max_tokens: 300,
verification: 'V1',
conversation_id: 'call-4471'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/history/search', 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://{space}.{region}.api.niadra.com/v1/history/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'subject' => [
'type' => 'phone_e164',
'value' => '+14155550123'
],
'query' => 'credit for missed technician visit',
'max_tokens' => 300,
'verification' => 'V1',
'conversation_id' => 'call-4471'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://{space}.{region}.api.niadra.com/v1/history/search"
payload := strings.NewReader("{\n \"subject\": {\n \"type\": \"phone_e164\",\n \"value\": \"+14155550123\"\n },\n \"query\": \"credit for missed technician visit\",\n \"max_tokens\": 300,\n \"verification\": \"V1\",\n \"conversation_id\": \"call-4471\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.post("https://{space}.{region}.api.niadra.com/v1/history/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"subject\": {\n \"type\": \"phone_e164\",\n \"value\": \"+14155550123\"\n },\n \"query\": \"credit for missed technician visit\",\n \"max_tokens\": 300,\n \"verification\": \"V1\",\n \"conversation_id\": \"call-4471\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/history/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subject\": {\n \"type\": \"phone_e164\",\n \"value\": \"+14155550123\"\n },\n \"query\": \"credit for missed technician visit\",\n \"max_tokens\": 300,\n \"verification\": \"V1\",\n \"conversation_id\": \"call-4471\"\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "ep_01J2",
"kind": "episode",
"text": "Technician did not show up · $40 credit on the April bill · settled",
"at": "2026-03-12T14:20:00Z",
"channel": "voice",
"source_id": "src_voice",
"outcome": "resolved",
"confidence": 0.94,
"origin_event_id": "evt_01J2A"
},
{
"id": "ep_01J3",
"kind": "episode",
"text": "Customer confirmed the credit and the new visit",
"at": "2026-03-14T12:02:00Z",
"channel": "whatsapp",
"source_id": "src_whatsapp",
"outcome": "resolved",
"confidence": 0.91,
"origin_event_id": "evt_01J3C"
}
],
"recurrence": {
"category": "technician_visit",
"occurrences": 2,
"window_days": 365,
"last_at": "2026-03-12T14:20:00Z",
"last_outcome": "resolved",
"last_resolution": "$40 credit"
},
"withheld": 0,
"as_of": "2026-09-22T17:07:02Z",
"tokens_used": 61,
"degraded": null
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Autorizações
nia_sk_...
Corpo
Linguagem natural ou palavras-chave.
1 - 2000Um identificador de um sujeito num canal ou sistema: um telefone, um e-mail, um id do CRM.
Show child attributes
Show child attributes
Um identificador de um sujeito num canal ou sistema: um telefone, um e-mail, um id do CRM.
Show child attributes
Show child attributes
1 - 512Show child attributes
Show child attributes
Orçamento da resposta. Os itens são cortados por valor, nunca pela ordem de chegada. Use 300 na voz.
50 <= x <= 40001 - 512Nível de verificação da sessão. V0 autodeclarado, V1 plausível pelo canal, V2 atestado pelo canal, V3 desafiado (OTP ou login), V4 conferido com um sistema de registro ou por um atendente. no_customer vale para tarefas sem cliente presente e só é aceito de fontes de agente interno.
V0, V1, V2, V3, V4, no_customer Resposta
Os itens encontrados, cortados por valor até max_tokens.
Show child attributes
Show child attributes
text_only quando a busca por significado não estava disponível e só a busca por palavra rodou.
Quantas vezes isso aconteceu, contado sobre episódios tipados. Uma contagem, não um palpite.
Show child attributes
Show child attributes

