Skip to main content
The File API lets you accept spreadsheet files programmatically, as an alternative to users uploading files manually through the CSVbox importer. Files submitted through the REST File API are pushed to the data destination set up in the CSVbox dashboard.

Simple File API request

After the data is pushed to the destination, the import complete webhook can be triggered as configured in the sheet settings.
Spreadsheet data submitted through the File API is not validated against the rules configured in the sheet settings. The importer attempts to push the data directly to the destination in raw form.

Authentication

All REST File API queries require a valid API key. You can find the API key on the Accounts page in the CSVbox dashboard. Include your API key as an x-csvbox-api-key header on all API queries.

Endpoint

Submits a spreadsheet file.

Headers

Request body

The public_file_url must respond to a HEAD request within 5 seconds, or the API returns 422 with The file URL could not be accessed. If the URL path has no file extension, the file type is resolved from the Content-Type the URL returns.
The columns in the file must be in the same order as configured in the sheet template, and the column names must match exactly. To have the importer auto-map the columns, set options.auto_map to true.

Response

200 OK: File submitted.
200 OK
  • env_name is the environment.env_name you sent, or default when none was sent.
  • pdf_meta contains the document metadata fields extracted from a PDF, DOCX, or image file. It is an empty object for spreadsheet files.
Some fields appear only in specific cases:

Document and image files

Besides CSV, XLS, and XLSX, the File API accepts PDF, DOC/DOCX, and image (JPG, JPEG, PNG) files when the sheet has AI Document Import enabled for that file type.
  • Only the first table found in the file is imported, since no user is present to choose a table.
  • Each page processed consumes AI document pages from your account.
  • If no table is found, the API returns 422 with No table data found in the file.

Example request

Direct file upload

As an alternative to providing a public file URL, you can upload the file contents directly. Send the request as multipart/form-data with two parts instead of a JSON body.

Request body

Send the file with the multipart/form-data content type. If the file part is missing, the API returns 422.

Example request

cURL

Rate limits

The REST File API allows 30 requests per minute for each combination of client IP address and API key. The count resets at the end of each one-minute window. Past the limit, the API returns a 429 Too Many Requests error. Responses include these headers: A 429 response also includes:

Status and error codes

All API queries return HTTP status codes that tell you more about the response.

401 Unauthorized

The client doesn’t have the correct authentication credentials.
If the API key is valid but doesn’t belong to the account that owns the sheet, the response is:

402 Import Limit Reached

The monthly import limit for the account plan is reached. Upgrade the plan to increase the import limit.
For PDF, DOCX, and image files, 402 is also returned when the account has run out of AI document pages:

404 Not Found

The referenced sheet was not found.

415 Unsupported Media Type

The Content-Type header doesn’t match the request.
For a direct file upload, the message is Content-Type must be multipart/form-data.

422 Unprocessable File

The request body or the file can’t be processed.
Other 422 messages include: When a field in the import object fails validation, the response also includes validation_errors, keyed by field:

429 Too Many Requests

The client has exceeded the rate limit.

5xx errors

An internal error occurred in CSVbox. Report such errors to our team.

Options

The following additional configuration options are available with the File API.

max_rows

  • Type: Integer
  • Default: Null
  • Description: The maximum number of rows to import.

has_header

  • Type: Boolean
  • Default: 1
  • Description: Specify whether the file contains a header row. Acceptable values are 0 (no header) and 1 (has a header row). The first row is treated as a header unless you send 0.

auto_map

  • Type: Boolean
  • Default: false
  • Description: Enable automatic column mapping in cases where an exact match is not found.

target_file_name

  • Type: String
  • Default: Null
  • Description: The name of the file (or Google Sheets tab) written to a file-based destination such as Amazon S3, Google Cloud Storage, Azure Blob Storage, FTP, GitHub, or Google Sheets. If not set, a name based on the import ID is used.