# Hold the customer while this agent works the case; another holder's stricter claim wins
claimed = conversation.claim(kind="case", lease_s=600, intents=["proposal_followup"])
if not claimed.held:
print(claimed.error) # lease_held, task_locked, or Niadra did not answer// Hold the customer while this agent works the case; another holder's stricter claim wins
const claimed = await convo.claim({ kind: "case", leaseS: 600, intents: ["proposal_followup"] });
if (!claimed.held) console.log(claimed.error); // lease_held, task_locked, or Niadra did not answercurl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/coordination/claims \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"holder": "<string>",
"lease_s": 43200,
"intents": [
"<string>"
],
"level": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"observed_at": "2023-11-07T05:31:56Z",
"source": "<string>",
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task": "<string>"
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
holder: '<string>',
lease_s: 43200,
intents: ['<string>'],
level: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
observed_at: '2023-11-07T05:31:56Z',
source: '<string>',
subject: {value: '<string>', scope: '<string>'},
task: '<string>'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/coordination/claims', 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/coordination/claims",
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([
'holder' => '<string>',
'lease_s' => 43200,
'intents' => [
'<string>'
],
'level' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'observed_at' => '2023-11-07T05:31:56Z',
'source' => '<string>',
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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://{space}.{region}.api.niadra.com/v1/coordination/claims"
payload := strings.NewReader("{\n \"holder\": \"<string>\",\n \"lease_s\": 43200,\n \"intents\": [\n \"<string>\"\n ],\n \"level\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"observed_at\": \"2023-11-07T05:31:56Z\",\n \"source\": \"<string>\",\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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/coordination/claims")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"holder\": \"<string>\",\n \"lease_s\": 43200,\n \"intents\": [\n \"<string>\"\n ],\n \"level\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"observed_at\": \"2023-11-07T05:31:56Z\",\n \"source\": \"<string>\",\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/coordination/claims")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"holder\": \"<string>\",\n \"lease_s\": 43200,\n \"intents\": [\n \"<string>\"\n ],\n \"level\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"observed_at\": \"2023-11-07T05:31:56Z\",\n \"source\": \"<string>\",\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"claim_id": "<string>",
"epoch": 123,
"holder": "<string>",
"kind": "owner",
"level": "<string>",
"valid_until": "2023-11-07T05:31:56Z"
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Reivindicar um cliente ou uma tarefa
Uma posse (owner, case) sobre o cliente ou uma trava de tarefa sobre um objeto, por um prazo; recusada com 409 enquanto outro detentor tem uma reivindicação igual ou mais restritiva. Uma observação do seu worker nunca é recusada.
# Hold the customer while this agent works the case; another holder's stricter claim wins
claimed = conversation.claim(kind="case", lease_s=600, intents=["proposal_followup"])
if not claimed.held:
print(claimed.error) # lease_held, task_locked, or Niadra did not answer// Hold the customer while this agent works the case; another holder's stricter claim wins
const claimed = await convo.claim({ kind: "case", leaseS: 600, intents: ["proposal_followup"] });
if (!claimed.held) console.log(claimed.error); // lease_held, task_locked, or Niadra did not answercurl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/coordination/claims \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"holder": "<string>",
"lease_s": 43200,
"intents": [
"<string>"
],
"level": "<string>",
"object": {
"id": "<string>",
"namespace": "<string>",
"type": "<string>"
},
"observed_at": "2023-11-07T05:31:56Z",
"source": "<string>",
"subject": {
"value": "<string>",
"scope": "<string>"
},
"task": "<string>"
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
holder: '<string>',
lease_s: 43200,
intents: ['<string>'],
level: '<string>',
object: {id: '<string>', namespace: '<string>', type: '<string>'},
observed_at: '2023-11-07T05:31:56Z',
source: '<string>',
subject: {value: '<string>', scope: '<string>'},
task: '<string>'
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/coordination/claims', 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/coordination/claims",
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([
'holder' => '<string>',
'lease_s' => 43200,
'intents' => [
'<string>'
],
'level' => '<string>',
'object' => [
'id' => '<string>',
'namespace' => '<string>',
'type' => '<string>'
],
'observed_at' => '2023-11-07T05:31:56Z',
'source' => '<string>',
'subject' => [
'value' => '<string>',
'scope' => '<string>'
],
'task' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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://{space}.{region}.api.niadra.com/v1/coordination/claims"
payload := strings.NewReader("{\n \"holder\": \"<string>\",\n \"lease_s\": 43200,\n \"intents\": [\n \"<string>\"\n ],\n \"level\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"observed_at\": \"2023-11-07T05:31:56Z\",\n \"source\": \"<string>\",\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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/coordination/claims")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"holder\": \"<string>\",\n \"lease_s\": 43200,\n \"intents\": [\n \"<string>\"\n ],\n \"level\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"observed_at\": \"2023-11-07T05:31:56Z\",\n \"source\": \"<string>\",\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/coordination/claims")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"holder\": \"<string>\",\n \"lease_s\": 43200,\n \"intents\": [\n \"<string>\"\n ],\n \"level\": \"<string>\",\n \"object\": {\n \"id\": \"<string>\",\n \"namespace\": \"<string>\",\n \"type\": \"<string>\"\n },\n \"observed_at\": \"2023-11-07T05:31:56Z\",\n \"source\": \"<string>\",\n \"subject\": {\n \"value\": \"<string>\",\n \"scope\": \"<string>\"\n },\n \"task\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"claim_id": "<string>",
"epoch": 123,
"holder": "<string>",
"kind": "owner",
"level": "<string>",
"valid_until": "2023-11-07T05:31:56Z"
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Autorizações
nia_sk_...
Cabeçalhos
Obrigatório. Guardado por 24 horas com o hash do corpo: a mesma chave com o mesmo corpo devolve a primeira resposta, e a mesma chave com outro corpo devolve 409 conflict.
1 - 256Corpo
Uma reivindicação declarada, detida por holder. level é por padrão o nível menos restritivo do espaço; uma declaração é recusada (409 lease_held) enquanto a reivindicação de outro detentor é ao menos tão restritiva, e o mesmo detentor renova a própria. lease_s é limitado pelo maior prazo declarado do espaço. Uma trava de tarefa nomeia um objeto e a task dele, e é recusada (409 task_locked) enquanto outro detentor tem essa tarefa.
1 - 256owner, case, task_lock 1 <= x <= 8640020^[a-z][a-z0-9_]{0,39}$^[a-z][a-z0-9_]{0,39}$Um objeto de negócio num sistema de registro.
Show child attributes
Show child attributes
Quando a fonte viu; uma observação mais antiga que a última da fonte é ignorada.
Uma observação desta fonte de posse, lida e enviada pelo worker da empresa: nunca recusada, substitui o que a fonte disse antes, limitada pela validade da fonte.
^[a-z][a-z0-9_]{0,39}$Um identificador de um sujeito num canal ou sistema: um telefone, um e-mail, um id do CRM.
Show child attributes
Show child attributes
^[a-z][a-z0-9_]{0,39}$Resposta
A reivindicação, com a época que uma liberação precisa nomear.

