Submit previously uploaded documents for scanning and extraction
curl --request POST \
--url https://api.sandbox.goteal.co/doc-scan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"files": [
{
"path": "client/acct123/users/user456/p45.pdf",
"external_document_id": "ext-p45-2024-05"
}
]
}
'import requests
url = "https://api.sandbox.goteal.co/doc-scan"
payload = { "files": [
{
"path": "client/acct123/users/user456/p45.pdf",
"external_document_id": "ext-p45-2024-05"
}
] }
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({
files: [
{
path: 'client/acct123/users/user456/p45.pdf',
external_document_id: 'ext-p45-2024-05'
}
]
})
};
fetch('https://api.sandbox.goteal.co/doc-scan', 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.sandbox.goteal.co/doc-scan",
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([
'files' => [
[
'path' => 'client/acct123/users/user456/p45.pdf',
'external_document_id' => 'ext-p45-2024-05'
]
]
]),
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.sandbox.goteal.co/doc-scan"
payload := strings.NewReader("{\n \"files\": [\n {\n \"path\": \"client/acct123/users/user456/p45.pdf\",\n \"external_document_id\": \"ext-p45-2024-05\"\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.sandbox.goteal.co/doc-scan")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"files\": [\n {\n \"path\": \"client/acct123/users/user456/p45.pdf\",\n \"external_document_id\": \"ext-p45-2024-05\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.goteal.co/doc-scan")
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 \"files\": [\n {\n \"path\": \"client/acct123/users/user456/p45.pdf\",\n \"external_document_id\": \"ext-p45-2024-05\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"documents": [
{
"id": "95a0e70b-fe02-4f47-aef9-2efff279df71",
"type": "p45",
"created_at": "2019-05-17T00:00:00.000Z",
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"extract": {
"employer_name": "Acme Corporation",
"paye_reference": "123/AB456",
"employee_name": "John Smith",
"national_insurance_number": "QQ123456C",
"leave_date": "2024-05-31",
"tax_code": "1257L",
"tax_year": "2024",
"gross_pay": "1500.00",
"income_tax": "250.00"
},
"probability": 0.95,
"document_external_id": "<string>",
"document_filename": "<string>",
"provenance": {
"source": "DOC_SCAN",
"trust_score": "High"
}
}
],
"errors": [
{
"error": "P45 could not be extracted",
"file_name": "p45.pdf"
}
]
}{
"documents": [
{
"id": "95a0e70b-fe02-4f47-aef9-2efff279df71",
"type": "p45",
"created_at": "2019-05-17T00:00:00.000Z",
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"extract": {
"employer_name": "Acme Corporation",
"paye_reference": "123/AB456",
"employee_name": "John Smith",
"national_insurance_number": "QQ123456C",
"leave_date": "2024-05-31",
"tax_code": "1257L",
"tax_year": "2024",
"gross_pay": "1500.00",
"income_tax": "250.00"
},
"probability": 0.95,
"document_external_id": "<string>",
"document_filename": "<string>",
"provenance": {
"source": "DOC_SCAN",
"trust_score": "High"
}
}
],
"errors": [
{
"error": "P45 could not be extracted",
"file_name": "p45.pdf"
}
]
}{
"errors": [
"The request is missing the required field `name`"
]
}{
"errors": [
"Not Authorization: Bearer <token> provided or wrong value"
]
}{
"errors": [
"The request is missing the required field `name`"
]
}Doc Scan
Upload documents for doc scan
Uploading documents for doc scan is a three-step flow:
- Request upload slots with
PUT /doc-scan/presign, providing each PDF file name (and optional external identifier). The response includespresigned_urlandpathvalues for every requested file. - Upload the PDF content to every
presigned_urlusing an HTTPPUTrequest withContent-Type: application/octet-stream. - Call this endpoint with the
path(and optionalexternal_document_id) of every uploaded file so Teal can extract the document data.
type (p45, p60 or universal_credit) is required and tells
Teal which document type to extract.
Each path must start with {client_name}/{user_id}/. A maximum of
12 files can be submitted at once and each file must be 10 MB or
smaller. The uploaded files are deleted from storage after
processing. The relevant scan flag (p45_scan_enabled,
p60_scan_enabled or universal_credit_scan_enabled) must be
enabled for the user and for the requested type.
POST
/
doc-scan
Submit previously uploaded documents for scanning and extraction
curl --request POST \
--url https://api.sandbox.goteal.co/doc-scan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"files": [
{
"path": "client/acct123/users/user456/p45.pdf",
"external_document_id": "ext-p45-2024-05"
}
]
}
'import requests
url = "https://api.sandbox.goteal.co/doc-scan"
payload = { "files": [
{
"path": "client/acct123/users/user456/p45.pdf",
"external_document_id": "ext-p45-2024-05"
}
] }
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({
files: [
{
path: 'client/acct123/users/user456/p45.pdf',
external_document_id: 'ext-p45-2024-05'
}
]
})
};
fetch('https://api.sandbox.goteal.co/doc-scan', 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.sandbox.goteal.co/doc-scan",
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([
'files' => [
[
'path' => 'client/acct123/users/user456/p45.pdf',
'external_document_id' => 'ext-p45-2024-05'
]
]
]),
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.sandbox.goteal.co/doc-scan"
payload := strings.NewReader("{\n \"files\": [\n {\n \"path\": \"client/acct123/users/user456/p45.pdf\",\n \"external_document_id\": \"ext-p45-2024-05\"\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.sandbox.goteal.co/doc-scan")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"files\": [\n {\n \"path\": \"client/acct123/users/user456/p45.pdf\",\n \"external_document_id\": \"ext-p45-2024-05\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.goteal.co/doc-scan")
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 \"files\": [\n {\n \"path\": \"client/acct123/users/user456/p45.pdf\",\n \"external_document_id\": \"ext-p45-2024-05\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"documents": [
{
"id": "95a0e70b-fe02-4f47-aef9-2efff279df71",
"type": "p45",
"created_at": "2019-05-17T00:00:00.000Z",
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"extract": {
"employer_name": "Acme Corporation",
"paye_reference": "123/AB456",
"employee_name": "John Smith",
"national_insurance_number": "QQ123456C",
"leave_date": "2024-05-31",
"tax_code": "1257L",
"tax_year": "2024",
"gross_pay": "1500.00",
"income_tax": "250.00"
},
"probability": 0.95,
"document_external_id": "<string>",
"document_filename": "<string>",
"provenance": {
"source": "DOC_SCAN",
"trust_score": "High"
}
}
],
"errors": [
{
"error": "P45 could not be extracted",
"file_name": "p45.pdf"
}
]
}{
"documents": [
{
"id": "95a0e70b-fe02-4f47-aef9-2efff279df71",
"type": "p45",
"created_at": "2019-05-17T00:00:00.000Z",
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"extract": {
"employer_name": "Acme Corporation",
"paye_reference": "123/AB456",
"employee_name": "John Smith",
"national_insurance_number": "QQ123456C",
"leave_date": "2024-05-31",
"tax_code": "1257L",
"tax_year": "2024",
"gross_pay": "1500.00",
"income_tax": "250.00"
},
"probability": 0.95,
"document_external_id": "<string>",
"document_filename": "<string>",
"provenance": {
"source": "DOC_SCAN",
"trust_score": "High"
}
}
],
"errors": [
{
"error": "P45 could not be extracted",
"file_name": "p45.pdf"
}
]
}{
"errors": [
"The request is missing the required field `name`"
]
}{
"errors": [
"Not Authorization: Bearer <token> provided or wrong value"
]
}{
"errors": [
"The request is missing the required field `name`"
]
}Authorizations
Headers
Body
application/json