REST File API
Automate CSV submissions via REST File API
The File API lets you accept spreadsheet files programmatically. It is an alternative to the users uploading the files manually, via the Csvbox importer. Files submitted via the REST File API will then be pushed to the data destination as set up in the Csvbox dashboard.

Simple File API Request

1
curl --location --request POST 'https://api.csvbox.io/1.1/file' \
2
--header 'x-csvbox-api-key: CSBxRLHgIZv3bqMlrJiVKXhKwtcHSv' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"import": {
6
"public_file_url": "https: //some-domain.com/file/3434as.csv",
7
"sheet_license_key": "jhkjsahjkhkjhkjhkjasdasd",
8
"user": {
9
"user_id": "1a2b3c4d5e6f",
10
},
11
"options": {
12
"has_header": 1
13
}
14
}'
Copied!
After the data is pushed to the destination, the import complete webhook can be triggered as configured in the sheet settings.
The spreadsheet data submitted via File API will not be validated based on the rules configured in the sheet settings. The importer will attempt to push the data directly to the destination in the raw form.
The columns in the file should be arranged in the same order as configured in the sheet template.

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 a x-csvbox-api-key header on all API queries.

Endpoint

post
https://api.csvbox.io/1.1
/file
Submits a spreadsheet file

Example Request

cURL
jQuery
PHP
NodeJS
1
curl --location --request POST 'https://api.csvbox.io/1.1/file' \
2
--header 'x-csvbox-api-key: CSBxRLHgIZv3bqMlrJiVKXhKwtcHSv' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"import": {
6
"public_file_url": "https: //some-domain.com/admin/download-csv/UXOR2MphpEu2sSAIISpY7AKmOIzAKygLNy8eviEr",
7
"sheet_license_key": "jhkjsahjkhkjhkjhkjasdasd",
8
"user": {
9
"user_id": "1a2b3c4d5e6f",
10
"team_id": "sales2",
11
"permissionLevel": "admin"
12
},
13
"options": {
14
"max_rows": 150,
15
"has_header": 1
16
},
17
"dynamic_columns": [
18
{
19
"column_name": "qualification",
20
"display_label": "HighestQualification",
21
"info_hint": "Whatisyourhighesteducationaldegree",
22
"matching_keywords": "degree, education",
23
"type": "text",
24
"validators": {
25
"min_length": 2,
26
"max_length": 50
27
},
28
"required": true
29
},
30
{
31
"column_name": "experience",
32
"display_label": "WorkExperience",
33
"info_hint": "Yearsofworkexperience",
34
"matching_keywords": "",
35
"type": "number",
36
"validators": {
37
"min_value": 0,
38
"max_value": 100
39
},
40
"required": false
41
}
42
]
43
}'
Copied!
1
var settings = {
2
"url": "https://api.csvbox.io/1.1/file",
3
"method": "POST",
4
"timeout": 0,
5
"headers": {
6
"x-csvbox-api-key": "CSBxRLHgIZv3bqMlrJiVKXhKwtcHSv",
7
"Content-Type": "application/json"
8
},
9
"data": "{\r\n \"import\": {\r\n \"public_file_url\": \"https: //some-domain.com/admin/download-csv/UXOR2MphpEu2sSAIISpY7AKmOIzAKygLNy8eviEr\",\r\n \"sheet_license_key\": \"jhkjsahjkhkjhkjhkjasdasd\",\r\n \"user\": {\r\n \"user_id\": \"1a2b3c4d5e6f\",\r\n \"team_id\": \"sales2\",\r\n \"permissionLevel\": \"admin\"\r\n },\r\n \"options\": {\r\n \"max_rows\": 150,\r\n \"has_header\": \"1\"\r\n },\r\n \"dynamic_columns\": [\r\n {\r\n \"column_name\": \"qualification\",\r\n \"display_label\": \"HighestQualification\",\r\n \"info_hint\": \"Whatisyourhighesteducationaldegree\",\r\n \"matching_keywords\": \"degree, education\",\r\n \"type\": \"text\",\r\n \"validators\": {\r\n \"min_length\": 2,\r\n \"max_length\": 50\r\n },\r\n \"required\": true\r\n },\r\n {\r\n \"column_name\": \"experience\",\r\n \"display_label\": \"WorkExperience\",\r\n \"info_hint\": \"Yearsofworkexperience\",\r\n \"matching_keywords\": \"\",\r\n \"type\": \"number\",\r\n \"validators\": {\r\n \"min_value\": 0,\r\n \"max_value\": 100\r\n },\r\n \"required\": false\r\n }\r\n ]\r\n }",
10
};
11
12
$.ajax(settings).done(function (response) {
13
console.log(response);
14
});
Copied!
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://api.csvbox.io/1.1/file',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"import": {
16
"public_file_url": "https: //some-domain.com/admin/download-csv/UXOR2MphpEu2sSAIISpY7AKmOIzAKygLNy8eviEr",
17
"sheet_license_key": "jhkjsahjkhkjhkjhkjasdasd",
18
"user": {
19
"user_id": "1a2b3c4d5e6f",
20
"team_id": "sales2",
21
"permissionLevel": "admin"
22
},
23
"options": {
24
"max_rows": 150,
25
"has_header": 1
26
},
27
"dynamic_columns": [
28
{
29
"column_name": "qualification",
30
"display_label": "HighestQualification",
31
"info_hint": "Whatisyourhighesteducationaldegree",
32
"matching_keywords": "degree, education",
33
"type": "text",
34
"validators": {
35
"min_length": 2,
36
"max_length": 50
37
},
38
"required": true
39
},
40
{
41
"column_name": "experience",
42
"display_label": "WorkExperience",
43
"info_hint": "Yearsofworkexperience",
44
"matching_keywords": "",
45
"type": "number",
46
"validators": {
47
"min_value": 0,
48
"max_value": 100
49
},
50
"required": false
51
}
52
]
53
}',
54
CURLOPT_HTTPHEADER => array(
55
'x-csvbox-api-key: CSBxRLHgIZv3bqMlrJiVKXhKwtcHSv',
56
'Content-Type: application/json'
57
),
58
));
59
60
$response = curl_exec($curl);
61
62
curl_close($curl);
63
echo $response;
64
Copied!
1
var axios = require('axios');
2
var data = '{\r\n "import": {\r\n "public_file_url": "https: //some-domain.com/admin/download-csv/UXOR2MphpEu2sSAIISpY7AKmOIzAKygLNy8eviEr",\r\n "sheet_license_key": "jhkjsahjkhkjhkjhkjasdasd",\r\n "user": {\r\n "user_id": "1a2b3c4d5e6f",\r\n "team_id": "sales2",\r\n "permissionLevel": "admin"\r\n },\r\n "options": {\r\n "max_rows": 150,\r\n "has_header": "1"\r\n },\r\n "dynamic_columns": [\r\n {\r\n "column_name": "qualification",\r\n "display_label": "HighestQualification",\r\n "info_hint": "Whatisyourhighesteducationaldegree",\r\n "matching_keywords": "degree, education",\r\n "type": "text",\r\n "validators": {\r\n "min_length": 2,\r\n "max_length": 50\r\n },\r\n "required": true\r\n },\r\n {\r\n "column_name": "experience",\r\n "display_label": "WorkExperience",\r\n "info_hint": "Yearsofworkexperience",\r\n "matching_keywords": "",\r\n "type": "number",\r\n "validators": {\r\n "min_value": 0,\r\n "max_value": 100\r\n },\r\n "required": false\r\n }\r\n ]\r\n }';
3
4
var config = {
5
method: 'post',
6
url: 'https://api.csvbox.io/1.1/file',
7
headers: {
8
'x-csvbox-api-key': 'CSBxRLHgIZv3bqMlrJiVKXhKwtcHSv',
9
'Content-Type': 'application/json'
10
},
11
data : data
12
};
13
14
axios(config)
15
.then(function (response) {
16
console.log(JSON.stringify(response.data));
17
})
18
.catch(function (error) {
19
console.log(error);
20
});
21
Copied!

Rate limits

The REST Admin 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 will return 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 will also include a retry-after header with the number of seconds to wait until retrying your query.

Status and error codes

All API queries return HTTP status codes that can tell you more about the response.
401 Unauthorized
The client doesn’t have the correct authentication credentials.
1
HTTP/1.1 401 Unauthorized
2
{
3
"errors": "[API] Invalid API key or access token."
4
}
Copied!
402 Import Limit Reached
The monthly import limit based on the account plan is reached. You can upgrade the plan to increase the import limit.
1
HTTP/1.1 402 Import Limit Reached
2
{
3
"errors": "The account has exceeded the import limit."
4
}
Copied!
403 Forbidden
The server is refusing to respond. This is typically caused if File API is disabled.
1
HTTP/1.1 403 Access Denied
2
{
3
"errors": "User does not have access."
4
}
Copied!
404 Not Found
The referenced sheet was not found.
1
HTTP/1.1 404 Not Found
2
{
3
"errors": "Sheet not found."
4
}
Copied!
422 Unprocessable File
The request body contains file errors. This is typically caused by incorrect file path, invalid file permissions, incorrect file format, corrupt file, file size too large, etc.
1
HTTP/1.1 422 Unprocessable File
2
{
3
"errors": "Invalid file format."
4
}
Copied!
429 Too Many Requests
The client has exceeded the rate limit.
1
HTTP/1.1 429 Too Many Requests
2
{
3
"errors": "API Rate limit reached. Reduce request rates to resume uninterrupted service."
4
}
Copied!
5xx Errors
An internal error occurred in Csvbox. Report to our team for such errors.
1
HTTP/1.1 500 Internal Server Error
2
{
3
"errors": "An unexpected error occurred."
4
}
Copied!

Options

Here is the list of additional configuration options 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)
1 (has a header row)