POST
/
api
/
v1
/
documents
/
answer
curl --request POST \
  --url https://api.fieldwise.ai/api/v1/documents/answer \
  --header 'Content-Type: application/json' \
  --data '{
  "format": "MARKDOWN",
  "metadata_filter": {
    "$and": [
      {
        "category": "finance"
      },
      {
        "priority": {
          "$gt": 2
        }
      },
      {
        "tags": {
          "$contains": [
            "important"
          ]
        }
      }
    ]
  },
  "question": "What is the main topic of the document?"
}'
{
  "success": true,
  "data": {
    "answer": "<string>",
    "sources": [
      {
        "document_id": 123,
        "page_number": 123,
        "paragraph_id": 123,
        "paragraph_index": 123,
        "highlight_sentences": [
          {}
        ],
        "relevance": "<string>",
        "document_metadata": {}
      }
    ],
    "format": "<string>",
    "optimized_question": "<string>",
    "optimized_metadata": {}
  },
  "error": {
    "error_code": "RESOURCE_NOT_FOUND",
    "message": "Resource not found"
  },
  "meta": {
    "timestamp": "2023-11-07T05:31:56Z",
    "version": "1.0"
  }
}

Headers

X-API-Key
string | null

Body

application/json

Request model for asking questions about documents.

question
string
required
optimize_metadata
boolean
default:false

If True, optimize the metadata filter based on the question

optimize_question
boolean
default:false

If True, optimize the question by removing parts covered by metadata filter

metadata_filter
object | null

Optional metadata filters using MongoDB-like query syntax

format
enum<string> | null
default:MARKDOWN

Format of the answer (MARKDOWN or PLAIN_TEXT)

Available options:
MARKDOWN,
PLAIN_TEXT

Response

200
application/json
Successful Response
data
object
required

Response data

success
boolean
default:true
error
object | null

Schema for API error responses.

Example:
{
  "error_code": "RESOURCE_NOT_FOUND",
  "message": "Resource not found"
}
meta
object

Metadata for API responses