curl --request POST \
--url https://api.fieldwise.ai/api/v1/documents/answer \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"format": "MARKDOWN",
"metadata_filter": {
"$and": [
{
"category": "finance"
},
{
"priority": {
"$gt": 2
}
},
{
"tags": {
"$contains": [
"important"
]
}
}
]
},
"question": "What is the main topic of the document?"
}
'import requests
url = "https://api.fieldwise.ai/api/v1/documents/answer"
payload = {
"format": "MARKDOWN",
"metadata_filter": { "$and": [{ "category": "finance" }, { "priority": { "$gt": 2 } }, { "tags": { "$contains": ["important"] } }] },
"question": "What is the main topic of the document?"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
format: 'MARKDOWN',
metadata_filter: {
$and: [
{category: 'finance'},
{priority: {$gt: 2}},
{tags: {$contains: ['important']}}
]
},
question: 'What is the main topic of the document?'
})
};
fetch('https://api.fieldwise.ai/api/v1/documents/answer', 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.fieldwise.ai/api/v1/documents/answer",
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([
'format' => 'MARKDOWN',
'metadata_filter' => [
'$and' => [
[
'category' => 'finance'
],
[
'priority' => [
'$gt' => 2
]
],
[
'tags' => [
'$contains' => [
'important'
]
]
]
]
],
'question' => 'What is the main topic of the document?'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-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://api.fieldwise.ai/api/v1/documents/answer"
payload := strings.NewReader("{\n \"format\": \"MARKDOWN\",\n \"metadata_filter\": {\n \"$and\": [\n {\n \"category\": \"finance\"\n },\n {\n \"priority\": {\n \"$gt\": 2\n }\n },\n {\n \"tags\": {\n \"$contains\": [\n \"important\"\n ]\n }\n }\n ]\n },\n \"question\": \"What is the main topic of the document?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.fieldwise.ai/api/v1/documents/answer")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"format\": \"MARKDOWN\",\n \"metadata_filter\": {\n \"$and\": [\n {\n \"category\": \"finance\"\n },\n {\n \"priority\": {\n \"$gt\": 2\n }\n },\n {\n \"tags\": {\n \"$contains\": [\n \"important\"\n ]\n }\n }\n ]\n },\n \"question\": \"What is the main topic of the document?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fieldwise.ai/api/v1/documents/answer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"format\": \"MARKDOWN\",\n \"metadata_filter\": {\n \"$and\": [\n {\n \"category\": \"finance\"\n },\n {\n \"priority\": {\n \"$gt\": 2\n }\n },\n {\n \"tags\": {\n \"$contains\": [\n \"important\"\n ]\n }\n }\n ]\n },\n \"question\": \"What is the main topic of the document?\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"answer": "<string>",
"format": "<string>",
"sources": [
{
"document_id": 123,
"page_number": 123,
"relevance": "<string>",
"document_metadata": {}
}
],
"optimized_question": "<string>",
"optimized_metadata": {}
},
"success": true,
"error": {
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"version": "1.0"
}
}{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}Get Document Answer
Answer a question based on the documents matching the provided metadata filter.
The metadata_filter parameter supports MongoDB-like query syntax with operators:
- Comparison:
$eq, $ne, $gt, $lt, $gte, $lte, $in, $nin - Array:
$contains, $containsAny, $notContains, $size - Logical:
$and, $or, $not - Type:
$type - Regex:
$regex, $iregex
Example Metadata Filter
json { "$and": [ { "category": "finance" }, { "tags": { "$contains": ["important"] } }, { "$or": [ { "priority": { "$gt": 2 } }, { "status": "active" } ] } ] }
curl --request POST \
--url https://api.fieldwise.ai/api/v1/documents/answer \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"format": "MARKDOWN",
"metadata_filter": {
"$and": [
{
"category": "finance"
},
{
"priority": {
"$gt": 2
}
},
{
"tags": {
"$contains": [
"important"
]
}
}
]
},
"question": "What is the main topic of the document?"
}
'import requests
url = "https://api.fieldwise.ai/api/v1/documents/answer"
payload = {
"format": "MARKDOWN",
"metadata_filter": { "$and": [{ "category": "finance" }, { "priority": { "$gt": 2 } }, { "tags": { "$contains": ["important"] } }] },
"question": "What is the main topic of the document?"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
format: 'MARKDOWN',
metadata_filter: {
$and: [
{category: 'finance'},
{priority: {$gt: 2}},
{tags: {$contains: ['important']}}
]
},
question: 'What is the main topic of the document?'
})
};
fetch('https://api.fieldwise.ai/api/v1/documents/answer', 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.fieldwise.ai/api/v1/documents/answer",
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([
'format' => 'MARKDOWN',
'metadata_filter' => [
'$and' => [
[
'category' => 'finance'
],
[
'priority' => [
'$gt' => 2
]
],
[
'tags' => [
'$contains' => [
'important'
]
]
]
]
],
'question' => 'What is the main topic of the document?'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-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://api.fieldwise.ai/api/v1/documents/answer"
payload := strings.NewReader("{\n \"format\": \"MARKDOWN\",\n \"metadata_filter\": {\n \"$and\": [\n {\n \"category\": \"finance\"\n },\n {\n \"priority\": {\n \"$gt\": 2\n }\n },\n {\n \"tags\": {\n \"$contains\": [\n \"important\"\n ]\n }\n }\n ]\n },\n \"question\": \"What is the main topic of the document?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.fieldwise.ai/api/v1/documents/answer")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"format\": \"MARKDOWN\",\n \"metadata_filter\": {\n \"$and\": [\n {\n \"category\": \"finance\"\n },\n {\n \"priority\": {\n \"$gt\": 2\n }\n },\n {\n \"tags\": {\n \"$contains\": [\n \"important\"\n ]\n }\n }\n ]\n },\n \"question\": \"What is the main topic of the document?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fieldwise.ai/api/v1/documents/answer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"format\": \"MARKDOWN\",\n \"metadata_filter\": {\n \"$and\": [\n {\n \"category\": \"finance\"\n },\n {\n \"priority\": {\n \"$gt\": 2\n }\n },\n {\n \"tags\": {\n \"$contains\": [\n \"important\"\n ]\n }\n }\n ]\n },\n \"question\": \"What is the main topic of the document?\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"answer": "<string>",
"format": "<string>",
"sources": [
{
"document_id": 123,
"page_number": 123,
"relevance": "<string>",
"document_metadata": {}
}
],
"optimized_question": "<string>",
"optimized_metadata": {}
},
"success": true,
"error": {
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"version": "1.0"
}
}{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}Authorizations
Headers
Body
Request model for asking questions about documents.
If True, optimize the metadata filter based on the question
If True, optimize the question by removing parts covered by metadata filter
Optional metadata filters using MongoDB-like query syntax
Filter by created_at database field. Supports operators: $eq, $ne, $gt, $lt, $gte, $lte, $in, $nin. Use ISO date format (e.g., '2024-01-01T00:00:00')
Filter by updated_at database field. Supports operators: $eq, $ne, $gt, $lt, $gte, $lte, $in, $nin. Use ISO date format (e.g., '2024-01-01T00:00:00')
Format of the answer (MARKDOWN or PLAIN_TEXT)
MARKDOWN, PLAIN_TEXT Response
Successful Response
Response data
Show child attributes
Show child attributes
Schema for API error responses.
Show child attributes
Show child attributes
{
"error_code": "RESOURCE_NOT_FOUND",
"message": "Resource not found"
}
Metadata for API responses
Show child attributes
Show child attributes