Skip to content

Commit e65845c

Browse files
authored
Merge pull request #6273 from keboola/devin/1760340271-workspace-table-export
DMD-441 add workspace table export endpoint
2 parents 9441283 + b95204b commit e65845c

2 files changed

Lines changed: 120 additions & 0 deletions

File tree

apiary.apib

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5465,6 +5465,98 @@ when any of the row values were changed during an incremental import.
54655465
"outBytes": 0,
54665466
"outBytesUncompressed": 0
54675467
}
5468+
5469+
## Export Table from Workspace [/v2/storage/workspaces/{workspace_id}/table-export]
5470+
5471+
### Export Table from Workspace [POST /v2/storage/workspaces/{workspace_id}/table-export]
5472+
5473+
Export a table from a workspace to file storage. This endpoint creates an asynchronous job that exports the specified table
5474+
from the workspace schema to file storage. The exported file can then be downloaded using the file ID returned in the job results.
5475+
5476+
**Note:** Currently only supported for Snowflake workspaces.
5477+
5478+
+ Parameters
5479+
+ workspace_id (required, number) - The workspace ID
5480+
5481+
+ Attributes
5482+
+ tableName (required, string) - Name of the table to export from the workspace
5483+
+ fileName (optional, string) - Custom filename for the exported file. If not provided, a default filename will be generated.
5484+
+ fileType (optional, enum[string]) - File type of the exported file
5485+
+ Members
5486+
+ csv - Export as CSV format
5487+
+ parquet - Export as Parquet format (requires project feature support)
5488+
+ Default: csv
5489+
5490+
+ Request (application/json)
5491+
+ Headers
5492+
5493+
X-StorageApi-Token: your_token
5494+
5495+
+ Body
5496+
5497+
{
5498+
"tableName": "my_table",
5499+
"fileName": "custom_export",
5500+
"fileType": "csv"
5501+
}
5502+
5503+
+ Response 202 (application/json)
5504+
+ Body
5505+
5506+
{
5507+
"id": 12345678,
5508+
"status": "waiting",
5509+
"url": "https://connection.keboola.com/v2/storage/jobs/12345678",
5510+
"tableId": null,
5511+
"operationName": "workspaceTableExport",
5512+
"operationParams": {
5513+
"workspaceId": 504345774,
5514+
"tableName": "my_table",
5515+
"fileName": "custom_export.csv",
5516+
"format": "csv"
5517+
},
5518+
"createdTime": "2025-10-12T21:43:00+0000",
5519+
"startTime": null,
5520+
"endTime": null,
5521+
"runId": null,
5522+
"results": null,
5523+
"creatorToken": {
5524+
"id": "27978",
5525+
"description": "user@example.com"
5526+
},
5527+
"metrics": {
5528+
"inCompressed": false,
5529+
"inBytes": 0,
5530+
"inBytesUncompressed": 0,
5531+
"outCompressed": false,
5532+
"outBytes": 0,
5533+
"outBytesUncompressed": 0
5534+
}
5535+
}
5536+
5537+
+ Response 404 (application/json)
5538+
5539+
Workspace not found
5540+
5541+
+ Body
5542+
5543+
{
5544+
"error": "Workspace \"999999\" not found",
5545+
"code": 404
5546+
}
5547+
5548+
+ Response 400 (application/json)
5549+
5550+
Table not found in workspace or workspace is not a table workspace
5551+
5552+
+ Body
5553+
5554+
{
5555+
"error": "Table \"non_existent_table\" not found in workspace \"504345774\"",
5556+
"code": 400
5557+
}
5558+
5559+
54685560
}
54695561
54705562

src/Keboola/StorageApi/Client.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,34 @@ public function exportTableAsync($tableId, $options = [])
17271727
);
17281728
}
17291729

1730+
/**
1731+
* Export a table from workspace to file storage
1732+
*
1733+
* @param string|null $fileType Optional format (csv or parquet), defaults to csv
1734+
* @return array{
1735+
* file: array{
1736+
* id: int
1737+
* }
1738+
* }
1739+
*/
1740+
public function exportWorkspaceTable(
1741+
int $workspaceId,
1742+
string $tableName,
1743+
string $fileName,
1744+
?string $fileType = null,
1745+
): array {
1746+
$params = [
1747+
'tableName' => $tableName,
1748+
'fileName' => $fileName,
1749+
];
1750+
1751+
if ($fileType !== null) {
1752+
$params['fileType'] = $fileType;
1753+
}
1754+
1755+
return $this->apiPostJson("workspaces/{$workspaceId}/table-export", $params);
1756+
}
1757+
17301758
private function prepareExportOptions(array $options)
17311759
{
17321760
$allowedOptions = [

0 commit comments

Comments
 (0)