curl --request POST \
--url https://api.example.com/v0/facets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"corpus_ids": [
"<string>"
],
"fields": [
{
"field": "<string>",
"limit": 20
}
],
"filter": {
"source_namespaces": [
"<string>"
],
"metadata": [
{
"field": "<string>",
"any_of": [
"<string>"
],
"gte": "2023-11-07T05:31:56Z",
"lte": "2023-11-07T05:31:56Z"
}
]
},
"accepted_after": "2023-11-07T05:31:56Z",
"accepted_before": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.example.com/v0/facets"
payload = {
"corpus_ids": ["<string>"],
"fields": [
{
"field": "<string>",
"limit": 20
}
],
"filter": {
"source_namespaces": ["<string>"],
"metadata": [
{
"field": "<string>",
"any_of": ["<string>"],
"gte": "2023-11-07T05:31:56Z",
"lte": "2023-11-07T05:31:56Z"
}
]
},
"accepted_after": "2023-11-07T05:31:56Z",
"accepted_before": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
corpus_ids: ['<string>'],
fields: [{field: '<string>', limit: 20}],
filter: {
source_namespaces: ['<string>'],
metadata: [
{
field: '<string>',
any_of: ['<string>'],
gte: '2023-11-07T05:31:56Z',
lte: '2023-11-07T05:31:56Z'
}
]
},
accepted_after: '2023-11-07T05:31:56Z',
accepted_before: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.example.com/v0/facets', 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.example.com/v0/facets",
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([
'corpus_ids' => [
'<string>'
],
'fields' => [
[
'field' => '<string>',
'limit' => 20
]
],
'filter' => [
'source_namespaces' => [
'<string>'
],
'metadata' => [
[
'field' => '<string>',
'any_of' => [
'<string>'
],
'gte' => '2023-11-07T05:31:56Z',
'lte' => '2023-11-07T05:31:56Z'
]
]
],
'accepted_after' => '2023-11-07T05:31:56Z',
'accepted_before' => '2023-11-07T05:31:56Z'
]),
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://api.example.com/v0/facets"
payload := strings.NewReader("{\n \"corpus_ids\": [\n \"<string>\"\n ],\n \"fields\": [\n {\n \"field\": \"<string>\",\n \"limit\": 20\n }\n ],\n \"filter\": {\n \"source_namespaces\": [\n \"<string>\"\n ],\n \"metadata\": [\n {\n \"field\": \"<string>\",\n \"any_of\": [\n \"<string>\"\n ],\n \"gte\": \"2023-11-07T05:31:56Z\",\n \"lte\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"accepted_after\": \"2023-11-07T05:31:56Z\",\n \"accepted_before\": \"2023-11-07T05:31:56Z\"\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://api.example.com/v0/facets")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"corpus_ids\": [\n \"<string>\"\n ],\n \"fields\": [\n {\n \"field\": \"<string>\",\n \"limit\": 20\n }\n ],\n \"filter\": {\n \"source_namespaces\": [\n \"<string>\"\n ],\n \"metadata\": [\n {\n \"field\": \"<string>\",\n \"any_of\": [\n \"<string>\"\n ],\n \"gte\": \"2023-11-07T05:31:56Z\",\n \"lte\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"accepted_after\": \"2023-11-07T05:31:56Z\",\n \"accepted_before\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v0/facets")
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 \"corpus_ids\": [\n \"<string>\"\n ],\n \"fields\": [\n {\n \"field\": \"<string>\",\n \"limit\": 20\n }\n ],\n \"filter\": {\n \"source_namespaces\": [\n \"<string>\"\n ],\n \"metadata\": [\n {\n \"field\": \"<string>\",\n \"any_of\": [\n \"<string>\"\n ],\n \"gte\": \"2023-11-07T05:31:56Z\",\n \"lte\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"accepted_after\": \"2023-11-07T05:31:56Z\",\n \"accepted_before\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"field": "<string>",
"buckets": [
{
"value": "<string>",
"count": 2
}
]
}
],
"excluded_corpora": [
{
"corpus_id": "<string>",
"fields": [
"<string>"
]
}
]
}{
"code": "<string>",
"message": "<string>",
"retryable": true,
"request_id": "<string>",
"trace_id": "<string>",
"span_id": "<string>",
"field": "<string>",
"resync_url": "<string>"
}Count facets
Exact document counts for projected metadata fields across authorized Corpora. Uses content:read and validates every requested Corpus before resolving mappings, including Corpora excluded for missing facet or predicate fields. Exclusions use the same excluded_corpora shape and rules as search and metadata-filtered listing. All fields are aggregated in one read snapshot from current baseline-ready, non-quarantined Versions; withdrawn Records and Tombstones are excluded immediately. Each distinct array value counts a document once. Missing field values contribute no bucket. Common metadata.* fields and custom fields declared with the filter role are supported. Incompatible types across Corpora return 422 invalid_query. Existing projections without metadata require rebuilding (422 metadata_filter_unavailable). Each field returns at most its limit, selected by descending count then JSON value text in byte order for ties. UTC date buckets are then returned chronologically; empty date buckets are omitted. Histograms require day, month or year on datetime fields; interval on another type is invalid_query. Counts are independent of search and listing reads and can change with ingestion. No text query or ranking is applied. Each API process admits at most 8 active facet requests; excess work returns retryable 503 content_unavailable with Retry-After: 1. Requests have a 25-second execution deadline.
curl --request POST \
--url https://api.example.com/v0/facets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"corpus_ids": [
"<string>"
],
"fields": [
{
"field": "<string>",
"limit": 20
}
],
"filter": {
"source_namespaces": [
"<string>"
],
"metadata": [
{
"field": "<string>",
"any_of": [
"<string>"
],
"gte": "2023-11-07T05:31:56Z",
"lte": "2023-11-07T05:31:56Z"
}
]
},
"accepted_after": "2023-11-07T05:31:56Z",
"accepted_before": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.example.com/v0/facets"
payload = {
"corpus_ids": ["<string>"],
"fields": [
{
"field": "<string>",
"limit": 20
}
],
"filter": {
"source_namespaces": ["<string>"],
"metadata": [
{
"field": "<string>",
"any_of": ["<string>"],
"gte": "2023-11-07T05:31:56Z",
"lte": "2023-11-07T05:31:56Z"
}
]
},
"accepted_after": "2023-11-07T05:31:56Z",
"accepted_before": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
corpus_ids: ['<string>'],
fields: [{field: '<string>', limit: 20}],
filter: {
source_namespaces: ['<string>'],
metadata: [
{
field: '<string>',
any_of: ['<string>'],
gte: '2023-11-07T05:31:56Z',
lte: '2023-11-07T05:31:56Z'
}
]
},
accepted_after: '2023-11-07T05:31:56Z',
accepted_before: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.example.com/v0/facets', 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.example.com/v0/facets",
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([
'corpus_ids' => [
'<string>'
],
'fields' => [
[
'field' => '<string>',
'limit' => 20
]
],
'filter' => [
'source_namespaces' => [
'<string>'
],
'metadata' => [
[
'field' => '<string>',
'any_of' => [
'<string>'
],
'gte' => '2023-11-07T05:31:56Z',
'lte' => '2023-11-07T05:31:56Z'
]
]
],
'accepted_after' => '2023-11-07T05:31:56Z',
'accepted_before' => '2023-11-07T05:31:56Z'
]),
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://api.example.com/v0/facets"
payload := strings.NewReader("{\n \"corpus_ids\": [\n \"<string>\"\n ],\n \"fields\": [\n {\n \"field\": \"<string>\",\n \"limit\": 20\n }\n ],\n \"filter\": {\n \"source_namespaces\": [\n \"<string>\"\n ],\n \"metadata\": [\n {\n \"field\": \"<string>\",\n \"any_of\": [\n \"<string>\"\n ],\n \"gte\": \"2023-11-07T05:31:56Z\",\n \"lte\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"accepted_after\": \"2023-11-07T05:31:56Z\",\n \"accepted_before\": \"2023-11-07T05:31:56Z\"\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://api.example.com/v0/facets")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"corpus_ids\": [\n \"<string>\"\n ],\n \"fields\": [\n {\n \"field\": \"<string>\",\n \"limit\": 20\n }\n ],\n \"filter\": {\n \"source_namespaces\": [\n \"<string>\"\n ],\n \"metadata\": [\n {\n \"field\": \"<string>\",\n \"any_of\": [\n \"<string>\"\n ],\n \"gte\": \"2023-11-07T05:31:56Z\",\n \"lte\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"accepted_after\": \"2023-11-07T05:31:56Z\",\n \"accepted_before\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v0/facets")
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 \"corpus_ids\": [\n \"<string>\"\n ],\n \"fields\": [\n {\n \"field\": \"<string>\",\n \"limit\": 20\n }\n ],\n \"filter\": {\n \"source_namespaces\": [\n \"<string>\"\n ],\n \"metadata\": [\n {\n \"field\": \"<string>\",\n \"any_of\": [\n \"<string>\"\n ],\n \"gte\": \"2023-11-07T05:31:56Z\",\n \"lte\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"accepted_after\": \"2023-11-07T05:31:56Z\",\n \"accepted_before\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"field": "<string>",
"buckets": [
{
"value": "<string>",
"count": 2
}
]
}
],
"excluded_corpora": [
{
"corpus_id": "<string>",
"fields": [
"<string>"
]
}
]
}{
"code": "<string>",
"message": "<string>",
"retryable": true,
"request_id": "<string>",
"trace_id": "<string>",
"span_id": "<string>",
"field": "<string>",
"resync_url": "<string>"
}Authorizations
API key, not necessarily a JWT. Server derives Organization, permitted actions and Corpus scope; every resource access is authorized.
Body
1 - 16 elements1Distinct logical metadata field names, in response order.
1 - 16 elementsShow child attributes
Show child attributes
Candidate filter applied before ranking. Every present condition must hold. A requested Corpus served by a Projection Generation built before source filtering existed returns 422 source_filter_unavailable; rebuild that Corpus once (rebuildCorpusProjection) to enable it. Unfiltered search is unaffected.
Show child attributes
Show child attributes
Inclusive current-Version acceptance-time lower bound, as in listing.
Exclusive current-Version acceptance-time upper bound, as in listing.