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 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

Example request

Direct file upload

As an alternative to providing a public file URL, you can upload the file contents directly. Instead of import.public_file_url, use the following body parameter.

Request body

Send the file with the multipart/form-data content type.

Example request

cURL

Rate limits

The REST File API supports a limit of 30 requests per minute. This allotment replenishes at a rate of 2 requests per second. Past the limit, the API returns a 429 Too Many Requests error. All REST API responses include the x-csvbox-file-api-call-limit header, which shows how many requests the client has made and the total number allowed per minute. A 429 response also includes a retry-after header with the number of seconds to wait before retrying your query.

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.

402 Import Limit Reached

The monthly import limit for the account plan is reached. Upgrade the plan to increase the import limit.

403 Forbidden

The server is refusing to respond. This is typically caused by the File API being disabled.

404 Not Found

The referenced sheet was not found.

422 Unprocessable File

The request body contains file errors. Typical causes are an incorrect file path, invalid file permissions, an incorrect file format, a corrupt file, or a file size that’s too large.

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: 0
  • Description: Specify whether the file contains a header row. Acceptable values are 0 (no header) and 1 (has a header row).

auto_map

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