curl --request POST \
--url https://api.vectorshift.ai/v1/object-model/records/{type_id}/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"aggregates": [
{
"field": "size",
"op": "sum"
}
],
"filter": {
"conditions": [
{
"field": "stage",
"op": "eq",
"value": "diligence"
},
{
"field": "size",
"op": "gt",
"value": 5000000
}
],
"op": "all"
},
"limit": 20,
"select": "records",
"sorts": [
{
"descending": true,
"field": "size"
}
]
}
'import requests
url = "https://api.vectorshift.ai/v1/object-model/records/{type_id}/query"
payload = {
"aggregates": [
{
"field": "size",
"op": "sum"
}
],
"filter": {
"conditions": [
{
"field": "stage",
"op": "eq",
"value": "diligence"
},
{
"field": "size",
"op": "gt",
"value": 5000000
}
],
"op": "all"
},
"limit": 20,
"select": "records",
"sorts": [
{
"descending": True,
"field": "size"
}
]
}
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({
aggregates: [{field: 'size', op: 'sum'}],
filter: {
conditions: [
{field: 'stage', op: 'eq', value: 'diligence'},
{field: 'size', op: 'gt', value: 5000000}
],
op: 'all'
},
limit: 20,
select: 'records',
sorts: [{descending: true, field: 'size'}]
})
};
fetch('https://api.vectorshift.ai/v1/object-model/records/{type_id}/query', 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.vectorshift.ai/v1/object-model/records/{type_id}/query",
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([
'aggregates' => [
[
'field' => 'size',
'op' => 'sum'
]
],
'filter' => [
'conditions' => [
[
'field' => 'stage',
'op' => 'eq',
'value' => 'diligence'
],
[
'field' => 'size',
'op' => 'gt',
'value' => 5000000
]
],
'op' => 'all'
],
'limit' => 20,
'select' => 'records',
'sorts' => [
[
'descending' => true,
'field' => 'size'
]
]
]),
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.vectorshift.ai/v1/object-model/records/{type_id}/query"
payload := strings.NewReader("{\n \"aggregates\": [\n {\n \"field\": \"size\",\n \"op\": \"sum\"\n }\n ],\n \"filter\": {\n \"conditions\": [\n {\n \"field\": \"stage\",\n \"op\": \"eq\",\n \"value\": \"diligence\"\n },\n {\n \"field\": \"size\",\n \"op\": \"gt\",\n \"value\": 5000000\n }\n ],\n \"op\": \"all\"\n },\n \"limit\": 20,\n \"select\": \"records\",\n \"sorts\": [\n {\n \"descending\": true,\n \"field\": \"size\"\n }\n ]\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.vectorshift.ai/v1/object-model/records/{type_id}/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"aggregates\": [\n {\n \"field\": \"size\",\n \"op\": \"sum\"\n }\n ],\n \"filter\": {\n \"conditions\": [\n {\n \"field\": \"stage\",\n \"op\": \"eq\",\n \"value\": \"diligence\"\n },\n {\n \"field\": \"size\",\n \"op\": \"gt\",\n \"value\": 5000000\n }\n ],\n \"op\": \"all\"\n },\n \"limit\": 20,\n \"select\": \"records\",\n \"sorts\": [\n {\n \"descending\": true,\n \"field\": \"size\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vectorshift.ai/v1/object-model/records/{type_id}/query")
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 \"aggregates\": [\n {\n \"field\": \"size\",\n \"op\": \"sum\"\n }\n ],\n \"filter\": {\n \"conditions\": [\n {\n \"field\": \"stage\",\n \"op\": \"eq\",\n \"value\": \"diligence\"\n },\n {\n \"field\": \"size\",\n \"op\": \"gt\",\n \"value\": 5000000\n }\n ],\n \"op\": \"all\"\n },\n \"limit\": 20,\n \"select\": \"records\",\n \"sorts\": [\n {\n \"descending\": true,\n \"field\": \"size\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"deleted_id": "<string>",
"disposition": "<string>",
"next_cursor": "<string>",
"records": [
{
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"id": "<string>",
"label": "<string>",
"links": {},
"locked": true,
"revision": "<string>",
"type_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"values": {}
}
],
"summary": {},
"total_count": "<string>",
"written_id": "<string>"
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}Query records
The typed record query: a filter, sorts, aggregates and a group over every match, text search, and an ids-only mode. The path names the type; a body naming another is refused. Without sorts, aggregates or group it pages by record id: a write between pages never moves another record across a boundary, and total_count is on the first page. A sorted or summarizing query pages by offset and is live: a write between pages can.
curl --request POST \
--url https://api.vectorshift.ai/v1/object-model/records/{type_id}/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"aggregates": [
{
"field": "size",
"op": "sum"
}
],
"filter": {
"conditions": [
{
"field": "stage",
"op": "eq",
"value": "diligence"
},
{
"field": "size",
"op": "gt",
"value": 5000000
}
],
"op": "all"
},
"limit": 20,
"select": "records",
"sorts": [
{
"descending": true,
"field": "size"
}
]
}
'import requests
url = "https://api.vectorshift.ai/v1/object-model/records/{type_id}/query"
payload = {
"aggregates": [
{
"field": "size",
"op": "sum"
}
],
"filter": {
"conditions": [
{
"field": "stage",
"op": "eq",
"value": "diligence"
},
{
"field": "size",
"op": "gt",
"value": 5000000
}
],
"op": "all"
},
"limit": 20,
"select": "records",
"sorts": [
{
"descending": True,
"field": "size"
}
]
}
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({
aggregates: [{field: 'size', op: 'sum'}],
filter: {
conditions: [
{field: 'stage', op: 'eq', value: 'diligence'},
{field: 'size', op: 'gt', value: 5000000}
],
op: 'all'
},
limit: 20,
select: 'records',
sorts: [{descending: true, field: 'size'}]
})
};
fetch('https://api.vectorshift.ai/v1/object-model/records/{type_id}/query', 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.vectorshift.ai/v1/object-model/records/{type_id}/query",
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([
'aggregates' => [
[
'field' => 'size',
'op' => 'sum'
]
],
'filter' => [
'conditions' => [
[
'field' => 'stage',
'op' => 'eq',
'value' => 'diligence'
],
[
'field' => 'size',
'op' => 'gt',
'value' => 5000000
]
],
'op' => 'all'
],
'limit' => 20,
'select' => 'records',
'sorts' => [
[
'descending' => true,
'field' => 'size'
]
]
]),
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.vectorshift.ai/v1/object-model/records/{type_id}/query"
payload := strings.NewReader("{\n \"aggregates\": [\n {\n \"field\": \"size\",\n \"op\": \"sum\"\n }\n ],\n \"filter\": {\n \"conditions\": [\n {\n \"field\": \"stage\",\n \"op\": \"eq\",\n \"value\": \"diligence\"\n },\n {\n \"field\": \"size\",\n \"op\": \"gt\",\n \"value\": 5000000\n }\n ],\n \"op\": \"all\"\n },\n \"limit\": 20,\n \"select\": \"records\",\n \"sorts\": [\n {\n \"descending\": true,\n \"field\": \"size\"\n }\n ]\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.vectorshift.ai/v1/object-model/records/{type_id}/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"aggregates\": [\n {\n \"field\": \"size\",\n \"op\": \"sum\"\n }\n ],\n \"filter\": {\n \"conditions\": [\n {\n \"field\": \"stage\",\n \"op\": \"eq\",\n \"value\": \"diligence\"\n },\n {\n \"field\": \"size\",\n \"op\": \"gt\",\n \"value\": 5000000\n }\n ],\n \"op\": \"all\"\n },\n \"limit\": 20,\n \"select\": \"records\",\n \"sorts\": [\n {\n \"descending\": true,\n \"field\": \"size\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vectorshift.ai/v1/object-model/records/{type_id}/query")
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 \"aggregates\": [\n {\n \"field\": \"size\",\n \"op\": \"sum\"\n }\n ],\n \"filter\": {\n \"conditions\": [\n {\n \"field\": \"stage\",\n \"op\": \"eq\",\n \"value\": \"diligence\"\n },\n {\n \"field\": \"size\",\n \"op\": \"gt\",\n \"value\": 5000000\n }\n ],\n \"op\": \"all\"\n },\n \"limit\": 20,\n \"select\": \"records\",\n \"sorts\": [\n {\n \"descending\": true,\n \"field\": \"size\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"deleted_id": "<string>",
"disposition": "<string>",
"next_cursor": "<string>",
"records": [
{
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"id": "<string>",
"label": "<string>",
"links": {},
"locked": true,
"revision": "<string>",
"type_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"values": {}
}
],
"summary": {},
"total_count": "<string>",
"written_id": "<string>"
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}{
"code": "<string>",
"error": "<string>",
"status": "failed",
"details": {},
"path": "<string>",
"request_id": "<string>",
"result": {}
}Authorizations
An API key issued with object_model scopes: Authorization: Bearer sk_…. The scopes: object_model:records:read, object_model:records:write, object_model:facts:read, object_model:facts:write, object_model:model:read, object_model:model:configure, object_model:actions:run, object_model:changes:read. An operation's security lists the scopes it needs; several entries mean any one of them will do. A person field (ref(user), ref_list(user)) holds a user id: look people up by email or id with GET /v1/users, outside this API, with a key that also has users:read.
Body
A query names at most 64 distinct fields in all, across filter, sorts, aggregates (field and fallback_field), group and search.fields; a field named twice counts once. Past that it is refused (422 too_many_fields, path the first field past the bound).
Response
Answered.
With aggregates or group: {"aggregates": [{"field", "op", "value", "error"}], "groups": [{"value", "count", "aggregates": […]}], "groups_truncated"}. aggregates are in the order asked, over every match, not only this page. A count is 0 when nothing matches; a sum, average, min or max is null when no match has a value. groups has one entry per value of the group field, in ascending order (records with no value form a group whose value is null), at most 200, with groups_truncated set past that. Sent again on every page.
