File storages
These endpoints are specific to file storage connections.
Retrieve file
Returns schema and first rows of a file.
Request
-
:id
int RequiredThe ID of the connection from which to read the users. It must be a source file storage.
-
path
string RequiredThe file path relative to the root of the file storage. For details on the required format, refer to the file storage connector documentation.
The path must not be empty and cannot exceed 1,024 characters in length.
Note that the path must be URL-encoded. For example, if the path is
docs/users/subscribers.csv, you need to pass it asdocs%2Fusers%2Fsubscribers.csv. -
format
string RequiredThe file format. Note that it corresponds to the code of the file connector used to read the file.
Possible values:"csv","excel","parquet"or"json". -
sheet
string Conditionally RequiredThe sheet name. It can only be used with the "excel" format, where it is required.
When provided, it must have a length between 1 and 31 characters, not start or end with a single quote
', and cannot contain any of the following characters:*,/,:,?,[,\, and]. -
compression
stringThe method used to compress the file, if applicable.
Note: An Excel file is inherently compressed, so no compression method needs to be specified unless the file has been further compressed.
Possible values:"","Zip","Gzip"or"Snappy". -
formatSettings
nullable jsonThe settings for the file format. Refer to the documentation for the connector related to the file format to understand the available settings and their corresponding values.
If the file format does not require any settings, the
formatSettingsparameter must be either omitted or set tonull. -
limit
intThe maximum number of rows to return along with the schema. The maximum is 100; the default is 0, meaning no rows are returned.
Response
-
schema
nullable schemaThe file's schema. It will be null if there are no supported columns.
-
rows
array of object with json valuesThe file's rows.
-
issues
nullable array of stringThe issues encountered while reading the file, such as unsupported columns, which did not prevent processing. If it is not null, it contains at least one issue.
curl -G https://example.com/v1/connections/1371036433/files \ -H "Authorization: Bearer api_xxxxxxx" \ -d "path=users.xlsx" \ -d "format=excel" \ -d "sheet=Sheet1" \ -d "formatSettings=%7b%22HasColumnNames%22%3atrue%7d" \ -d "limit=50" {
"schema": {
"kind": "object",
"properties": [
{
"name": "FirstName",
"type": {
"kind": "string"
}
},
{
"name": "LastName",
"type": {
"kind": "string"
}
}
]
},
"rows": [
{
"FirstName": "John",
"LastName": "Mitchell"
},
{
"FirstName": "Emily",
"LastName": "Carter"
},
{
"FirstName": "Michael",
"LastName": "Reynolds"
}
],
"issues": [
"Column \"Score\" cannot be imported because its type \"INT128\" is not supported"
]
}Read sheets
Returns the list of sheets in a file, applicable to file formats that support sheets.
Request
-
:id
int RequiredThe ID of the connection from which to read the users. It must be a source file storage.
-
path
string RequiredThe file path relative to the root of the file storage. For details on the required format, refer to the file storage connector documentation.
The path must not be empty and cannot exceed 1,024 characters in length.
Note that the path must be URL-encoded. For example, if the path is
docs/users/subscribers.csv, you need to pass it asdocs%2Fusers%2Fsubscribers.csv. -
format
string RequiredThe file format. Note that it corresponds to the code of the file connector used to read the file.
Possible values:"csv","excel","parquet"or"json". -
compression
stringThe method used to compress the file, if applicable.
Note: An Excel file is inherently compressed, so no compression method needs to be specified unless the file has been further compressed.
Possible values:"","Zip","Gzip"or"Snappy". -
formatSettings
nullable jsonThe settings for the file format. Refer to the documentation for the connector related to the file format to understand the available settings and their corresponding values.
If the file format does not require any settings, the
formatSettingsparameter must be either omitted or set tonull.
Response
-
sheets
array of stringThe sheets of the file. They have a length between 1 and 31 characters, not start or end with a single quote
', and cannot contain any of the following characters:*,/,:,?,[,\, and].
curl -G https://example.com/v1/connections/1371036433/files/sheets \ -H "Authorization: Bearer api_xxxxxxx" \ -d "path=users.xlsx" \ -d "format=excel" \ -d "formatSettings=%7b%22HasColumnNames%22%3atrue%7d" {
"sheets": [
"Sheet1",
"Sheet2"
]
}Get absolute path
Returns the file path relative to the root of the file storage.
While this absolute path isn't used directly by other API endpoints, it can help confirm that the relative path points to the correct file.
Request
-
:id
int RequiredThe ID of the file storage connection for which the path should be retrieved.
-
path
string RequiredThe file path relative to the root of the file storage. For details on the required format, refer to the file storage connector documentation.
The path must not be empty and cannot exceed 1,024 characters in length.
Note that the path must be URL-encoded. For example, if the path is
docs/users/subscribers.csv, you need to pass it asdocs%2Fusers%2Fsubscribers.csv.
Response
-
path
stringThe absolute path of the file.
curl -G https://example.com/v1/connections/1371036433/files/absolute \ -H "Authorization: Bearer api_xxxxxxx" \ -d "path=users.xlsx" {
"path": "/data/users.csv"
}