> This documentation belongs to Invofox, an AI-powered document processing
> platform. The API extracts structured data (fields) from unstructured
> documents (invoices, contracts, forms, bank statements, and more).
> Key concepts: Account, Environment, Document Type, Field, File, Import,
> and Document. When answering, prefer the exact terminology defined in the
> Glossary and cite the relevant API Reference endpoint when applicable.

# Get document field provenance

GET https://api.invofox.com/documents/{id}/provenance

For every extracted field of the document's type, the OCR words that hold its value. See [Field provenance](/documentation/field-provenance) to match the words with `GET /documents/{id}/ocr` and to correct them with `PUT /documents/{id}`.

Reference: https://developers.invofox.com/api-reference/main-reference/documents/get-document-field-provenance

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `id` (string, required) — id of the document to get

## Response

### 200

Provenance of every field, by field path

- `result` (map from string to FieldProvenance, optional) — Field path (`supplier.name`, `lines.0.quantity`: dot-separated, list items as plain numbers, no `data.` prefix nor `.value` suffix) → its provenance. Only the fields of the document's type, and a field may be absent: treat it as an empty `geometry`. An address located as a whole is given on its `raw` field.

## Errors

### 400 Bad Request Error

Provided id is not correctly formatted

- `code` (string, optional)

### 403 Forbidden Error

User is not authorized to carry out this action

- `code` (string, optional)

### 404 Not Found Error

Element was not found

- `code` (string, optional)
- `additionalInfo` (DocumentsIdProvenanceGetResponsesContentApplicationJsonSchemaAdditionalInfo, optional)

### 429 Too Many Requests Error

Too many requests were sent to the server in a short period of time. The response contains headers conforming to the [ratelimit standardization draft adopted by the IETF](https://github.com/ietf-wg-httpapi/ratelimit-headers/blob/main/draft-ietf-httpapi-ratelimit-headers.md/) * RateLimit-Limit - Limit of requests per window * RateLimit-Remaining - Remaining requests for current window * RateLimit-Reset - Seconds until window resets * Retry-After - Seconds caller should wait before retrying

- `code` (string, optional)

### 500 Internal Server Error

Unkown server error

- `code` (string, optional)

## Types

### FieldProvenance

A field's provenance: the OCR words that hold its value.

- `geometry` (list of FieldProvenanceGeometryItems, required) — OCR words that hold the value, in reading order, all indexes 0-based. Empty when the value has no located words (not found, computed, or changed without new words).

### DocumentsIdProvenanceGetResponsesContentApplicationJsonSchemaAdditionalInfo

### FieldProvenanceGeometryItems

- `page` (integer, required) — `index` of the OCR page (not `data.page`, which counts from 1).
- `region` (integer, required) — Position in the OCR page's `regions`.
- `line` (integer, required) — Position in the region's `lines`.
- `word` (integer, required) — Position in the line's `words`.

## Examples

**Response**

```json
{
  "result": {
    "lines.0.quantity": {
      "geometry": [
        {
          "page": 1,
          "region": 4,
          "line": 2,
          "word": 0
        }
      ]
    },
    "supplier.email": {
      "geometry": []
    },
    "supplier.name": {
      "geometry": [
        {
          "page": 0,
          "region": 17,
          "line": 3,
          "word": 10
        },
        {
          "page": 0,
          "region": 17,
          "line": 3,
          "word": 11
        }
      ]
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.invofox.com/documents/id/provenance"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.invofox.com/documents/id/provenance';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.invofox.com/documents/id/provenance"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.invofox.com/documents/id/provenance")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.invofox.com/documents/id/provenance")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.invofox.com/documents/id/provenance', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.invofox.com/documents/id/provenance");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.invofox.com/documents/id/provenance")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```