Upload File Queue

Upload file bytes. Send configuration in HTTP headers. Queue the file for processing and receive a webhook with the results.

Raw File Bytes

Upload the raw file bytes in the request body.

curl --request POST \
     --url 'https://api.scale.com/v1/document-ai/file/upload/queue' \
     --user '$SCALE_API_KEY:'
     --header 'Accept: application/json' \
     --header 'Content-Type: application/pdf' \
     --header 'Scale-Api-Arg: {"folder_name":"$FOLDER_NAME","file_name":"$FILE_NAME"}' \
     --data-binary "@/LOCAL/FILE/PATH.pdf"
import fetch from 'node-fetch';
import fs from 'fs';

const fileBuffer = await fs.promises.readFile('./local/file.pdf');
const response = await fetch('https://api.scale.com/v1/document-ai/file/upload/queue', {
  method: 'POST',
  headers: {
    'Authorizaton': 'Basic ' + Buffer.fromString('YOUR API KEY' + ':').toString('base64'),
    'Accept': 'application/json',
    'Content-Type': 'application/pdf',
    'Scale-Api-Arg': JSON.stringify({
      folder_name: 'YOUR FOLDER NAME',
      file_name: 'ANY FILE NAME',
    }),
  },
  body: fileBuffer,
});
if (response.ok) {
  const fileJson = await response.json();
} else {
  const errorJson = await response.json();
}
import requests
import json

with open('./local/file.pdf', 'rb') as f:
    data = f.read()
    scale_api_arg = {
        'folder_name': 'YOUR FOLDER NAME',
        'file_name': 'ANY FILE NAME'
    }
    headers = {
        'Accept': 'application/json',
        'Content-Type': 'application/pdf',
        'Scale-Api-Arg': json.dumps(scale_api_arg),
    }
    response = requests.post(url='https://api.scale.com/v1/document-ai/file/upload/queue',
                             data=data,
                             headers=headers
                             auth=('SCALE API KEY', ''))
    if response.ok:
        file_json = response.json()
    else:
        error_json = response.json()

Scale-Api-Arg

In order to pass raw file bytes in the request body, the parameters are passed in the Scale-Api-Arg header in JSON format.

Field

Data Type

Comment

folder_id

String

The folder to upload the file. One of folder_id or folder_name is required.

folder_name

String

The folder to upload the file. One of folder_id or folder_name is required.

file_name

String

The display name of the file. It will be the file name displayed in the dashboard.

metadata

Object

Metadata is optional. It can be helpful to store related information such as lookup identifiers. Scale does not modify or use the metadata. The metadata will be returned along with the file object in the future.

Response

202 Accepted: File Object

{
  "id": "string",
  "folder_reference": {
    "id": "string",
    "name": "string"
  },
  "metadata": {
    "*": "provide metadata fields to reference later here"
  },
  "documents": [
    {
      "id": "string",
      "type": "string",
      "version": 0,
      "structured_data": {
        "*": "depends on the document type and version, see the schema docs"
      }
    }
  ],
  "created_at": "2022-08-26T01:22:35.853Z"
}