# 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"
}Claim a customer or a task
An ownership claim (owner, case) on the customer or a task lock on an object, for a lease; refused with 409 while another holder has a claim at least as restrictive. An observation from your worker is never refused.
# 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"
}Authorizations
nia_sk_...
Headers
Required. Kept 24 hours with the hash of the body: a retry with the same key returns the first answer, and the same key with a different body returns 409 conflict.
1 - 256Body
A declared claim, held by holder. level defaults to the space's least restrictive level; a
declaration is refused (409 lease_held) while another holder's claim is at least as restrictive, and the
same holder renews its own. lease_s is capped by the space's longest declared lease. A task lock names
an object and its task, and is refused (409 task_locked) while another holder has that task.
1 - 256owner, case, task_lock 1 <= x <= 8640020^[a-z][a-z0-9_]{0,39}$^[a-z][a-z0-9_]{0,39}$A business object in a system of record, e.g. invoice / erp / 0823.
Show child attributes
Show child attributes
When the source saw it; an observation older than the source's last is ignored.
An observation of this ownership source, read and sent by the company's worker: never refused, replacing what the source said before, and capped by the source's validity.
^[a-z][a-z0-9_]{0,39}$An identifier of a subject in some channel or system: a phone, an e-mail, a CRM id.
Show child attributes
Show child attributes
^[a-z][a-z0-9_]{0,39}$Response
The claim, with the epoch a release must name.

