Evaluate a query against the authenticated user's credentials
curl --request POST \
--url https://api.sandbox.humanity.org/v2/queries/evaluate \
--header 'Content-Type: application/json' \
--data '
{
"query": {
"check": {
"claim": "<string>",
"operator": "==",
"value": "<unknown>"
}
}
}
'import requests
url = "https://api.sandbox.humanity.org/v2/queries/evaluate"
payload = { "query": { "check": {
"claim": "<string>",
"operator": "==",
"value": "<unknown>"
} } }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({query: {check: {claim: '<string>', operator: '==', value: '<unknown>'}}})
};
fetch('https://api.sandbox.humanity.org/v2/queries/evaluate', 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://api.sandbox.humanity.org/v2/queries/evaluate",
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([
'query' => [
'check' => [
'claim' => '<string>',
'operator' => '==',
'value' => '<unknown>'
]
]
]),
CURLOPT_HTTPHEADER => [
"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://api.sandbox.humanity.org/v2/queries/evaluate"
payload := strings.NewReader("{\n \"query\": {\n \"check\": {\n \"claim\": \"<string>\",\n \"operator\": \"==\",\n \"value\": \"<unknown>\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.sandbox.humanity.org/v2/queries/evaluate")
.header("Content-Type", "application/json")
.body("{\n \"query\": {\n \"check\": {\n \"claim\": \"<string>\",\n \"operator\": \"==\",\n \"value\": \"<unknown>\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.humanity.org/v2/queries/evaluate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": {\n \"check\": {\n \"claim\": \"<string>\",\n \"operator\": \"==\",\n \"value\": \"<unknown>\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"type": "predicate",
"passed": true,
"evaluatedAt": "<string>",
"evidence": {
"claimsUsed": [
{
"path": "<string>",
"value": "<unknown>",
"credentialId": "<string>",
"source": "<string>"
}
],
"checkResults": [
{
"claim": "<string>",
"operator": "<string>",
"expectedValue": "<unknown>",
"actualValue": "<unknown>",
"passed": true
}
]
},
"expiresAt": "<string>"
}Query Engine
Query Engine · Evaluate
Evaluate a query against the authenticated user’s credentials. This endpoint allows declarative queries to check user claims.
POST
/
queries
/
evaluate
Evaluate a query against the authenticated user's credentials
curl --request POST \
--url https://api.sandbox.humanity.org/v2/queries/evaluate \
--header 'Content-Type: application/json' \
--data '
{
"query": {
"check": {
"claim": "<string>",
"operator": "==",
"value": "<unknown>"
}
}
}
'import requests
url = "https://api.sandbox.humanity.org/v2/queries/evaluate"
payload = { "query": { "check": {
"claim": "<string>",
"operator": "==",
"value": "<unknown>"
} } }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({query: {check: {claim: '<string>', operator: '==', value: '<unknown>'}}})
};
fetch('https://api.sandbox.humanity.org/v2/queries/evaluate', 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://api.sandbox.humanity.org/v2/queries/evaluate",
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([
'query' => [
'check' => [
'claim' => '<string>',
'operator' => '==',
'value' => '<unknown>'
]
]
]),
CURLOPT_HTTPHEADER => [
"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://api.sandbox.humanity.org/v2/queries/evaluate"
payload := strings.NewReader("{\n \"query\": {\n \"check\": {\n \"claim\": \"<string>\",\n \"operator\": \"==\",\n \"value\": \"<unknown>\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.sandbox.humanity.org/v2/queries/evaluate")
.header("Content-Type", "application/json")
.body("{\n \"query\": {\n \"check\": {\n \"claim\": \"<string>\",\n \"operator\": \"==\",\n \"value\": \"<unknown>\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.humanity.org/v2/queries/evaluate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": {\n \"check\": {\n \"claim\": \"<string>\",\n \"operator\": \"==\",\n \"value\": \"<unknown>\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"type": "predicate",
"passed": true,
"evaluatedAt": "<string>",
"evidence": {
"claimsUsed": [
{
"path": "<string>",
"value": "<unknown>",
"credentialId": "<string>",
"source": "<string>"
}
],
"checkResults": [
{
"claim": "<string>",
"operator": "<string>",
"expectedValue": "<unknown>",
"actualValue": "<unknown>",
"passed": true
}
]
},
"expiresAt": "<string>"
}SDK equivalent
// Predicate query (boolean check)
const result = await sdk.evaluateQuery({
accessToken: token.accessToken,
query: {
check: { claim: 'identity.age', operator: '>=', value: 18 }
}
});
// Projection query (data extraction)
const data = await sdk.evaluateQuery({
accessToken: token.accessToken,
query: {
projections: [{ claim: 'identity.email', lens: 'pluck' }]
}
});
Query Types
Predicate Queries (Boolean Checks)
Returntrue or false based on credential values.
{
"query": {
"check": {
"claim": "identity.age",
"operator": ">=",
"value": 18
}
}
}
| Operator | Description | Example |
|---|---|---|
== | Equals | { "claim": "kyc.passed", "operator": "==", "value": true } |
!= | Not equals | { "claim": "identity.country", "operator": "!=", "value": "US" } |
> | Greater than | { "claim": "financial.net_worth", "operator": ">", "value": 100000 } |
>= | Greater than or equal | { "claim": "identity.age", "operator": ">=", "value": 21 } |
< | Less than | { "claim": "identity.age", "operator": "<", "value": 65 } |
<= | Less than or equal | { "claim": "financial.loan_balance", "operator": "<=", "value": 50000 } |
in | Value in array | { "claim": "identity.country", "operator": "in", "value": ["US", "CA", "UK"] } |
notIn | Value not in array | { "claim": "identity.country", "operator": "notIn", "value": ["RU", "CN"] } |
contains | Array contains value | { "claim": "identity.social_accounts", "operator": "contains", "value": "github" } |
isDefined | Claim exists | { "claim": "kyc.document_number", "operator": "isDefined" } |
startsWith | String prefix | { "claim": "identity.email", "operator": "startsWith", "value": "admin@" } |
matchRegex | Regex match | { "claim": "identity.phone", "operator": "matchRegex", "value": "^\\+1" } |
Compound Policies
Combine multiple checks with logical operators:{
"query": {
"policy": {
"allOf": [
{ "check": { "claim": "identity.age", "operator": ">=", "value": 21 } },
{ "check": { "claim": "identity.country", "operator": "==", "value": "US" } }
]
}
}
}
| Operator | Description |
|---|---|
allOf | AND - all conditions must pass |
anyOf | OR - at least one condition must pass |
not | NOT - negate the result |
{
"query": {
"policy": {
"allOf": [
{ "check": { "claim": "kyc.passed", "operator": "==", "value": true } },
{
"policy": {
"anyOf": [
{ "check": { "claim": "financial.net_worth", "operator": ">=", "value": 1000000 } },
{ "check": { "claim": "financial.income", "operator": ">=", "value": 200000 } }
]
}
}
]
}
}
}
Projection Queries (Data Extraction)
Extract values from credentials:{
"query": {
"projections": [
{ "claim": "identity.email", "lens": "pluck" },
{ "claim": "identity.country", "lens": "pluck" }
]
}
}
| Lens | Description |
|---|---|
pluck | Extract single value at path |
pick | Extract subset of object fields |
at | Array index access |
Response Types
Predicate Response
{
"type": "predicate",
"passed": true,
"evaluatedAt": "2026-01-16T12:00:00.000Z",
"evidence": {
"claimsUsed": [
{ "path": "identity.age", "value": 25, "credentialId": "cred_123" }
],
"checkResults": [
{
"claim": "identity.age",
"operator": ">=",
"expectedValue": 18,
"actualValue": 25,
"passed": true
}
]
},
"expiresAt": "2026-02-16T12:00:00.000Z"
}
Projection Response
{
"type": "projection",
"data": {
"identity.email": "user@example.com",
"identity.country": "US"
},
"evaluatedAt": "2026-01-16T12:00:00.000Z",
"claimsUsed": [
{ "path": "identity.email", "value": "user@example.com" },
{ "path": "identity.country", "value": "US" }
],
"expiresAt": "2026-02-16T12:00:00.000Z"
}
Claim Paths
Claims are accessed using dot-notation paths based on credential categories:| Category | Example Claims |
|---|---|
identity | identity.age, identity.email, identity.country_of_residence |
kyc | kyc.passed, kyc.document_country, kyc.last_updated_at |
financial | financial.net_worth, financial.bank_balance, financial.loan_balance |
Scope Requirements
Query evaluation respects OAuth scopes. You can only query claims covered by the granted scopes. For example:identity:read- Access to basic identity claimsidentity:date_of_birth- Access to age-related claimsfinancial:net_worth- Access to net worth data
Body
application/json
The query to evaluate
Request body for query evaluation.
The query to evaluate. Can be a simple check or compound policy.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Response
200 - application/json
Query evaluation result
- Option 1
- Option 2
Response from predicate query evaluation.