Files

Learn about how Scan Documents handles file objects

Overview

The File object represents a file that has been uploaded to the Scan Documents API. This could be an image (like a PNG, JPEG, or WebP) or a document (currently, only PDF is supported).

Scan Documents API allows you to operate on these files, through Task Operations. Depending on the type of file, you can perform various operations such as converting, extracting text, or analyzing the content.

Example File Object

Here's what a typical File object representing a PNG image might look like:

{
  "id": "file_euyrvozb9302uwhq",
  "name": "Example image",
  "type": "image/png",
  "properties": {
    "size": 1024,
    "width": 800,
    "height": 600
  },
  "task_id": null,
  "created_at": "2021-05-01T12:00:00Z"
}

Now, let's break down the properties of this File object.

Properties

Every File object, regardless of its type, will have the following basic information:

id
string

A unique identifier for the file (e.g., file_euyrvozb9302uwhq). You'll use this ID to refer to the file in other API operations.

name
string

The name you gave the file when you uploaded it (e.g., Example image).

type
string

The MIME type of the file (e.g., image/png, application/pdf). This tells you what kind of file it is.

properties
object

An object containing additional properties specific to the file type. This will include details like size, dimensions, or page count.

task_id
string

If this file was generated as the result of an API operation (like converting an image), this field will contain the ID of that task. Otherwise, it will be null.

created_at
string

The date and time when the file was uploaded or created, in ISO format (e.g., 2021-05-01T12:00:00Z).

The properties object will vary depending on the type of file. Below are the details for each supported file type.

Image Files

If the file is an image, the type will be one of image/png, image/jpeg, or image/webp.

The properties object for an image will contain:

size
number

The file size in bytes (e.g., 1024).

width
number

The width of the image in pixels (e.g., 800).

height
number

The height of the image in pixels (e.g., 600).

Example

Here's what a typical File object representing a PNG image might look like:

{
  "id": "file_euyrvozb9302uwhq",
  "name": "Example image",
  "type": "image/png",
  "properties": {
    "size": 1024,
    "width": 800,
    "height": 600
  },
  "task_id": null,
  "created_at": "2021-05-01T12:00:00Z"
}

Document Files

If the file is a PDF document, the type will be application/pdf

The properties object for a document will contain:

size
number

The file size in bytes (e.g., 20480).

page_count
number

The number of pages in the document (e.g., 10).

Example

Here's what a typical File object representing a PDF document might look like:

{
  "id": "file_euyrvozb9302uwhq",
  "name": "Example document",
  "type": "application/pdf",
  "properties": {
    "size": 20480,
    "page_count": 10
  },
  "task_id": null,
  "created_at": "2021-05-01T12:00:00Z"
}

File Operations

Now that you understand the File object, you can use it in various API operations. Check out the Task Operations section for more details on how to use files in your API requests.

On this page