collections
Add Files To Collection
Link existing uploaded files to a collection.
POST
/
api
/
v1
/
collections
/
{collection_id}
/
files
Add Files To Collection
import requests
url = "https://www.datalab.to/api/v1/collections/{collection_id}/files"
payload = { "uploaded_file_ids": [123] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://www.datalab.to/api/v1/collections/{collection_id}/files \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"uploaded_file_ids": [
123
]
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({uploaded_file_ids: [123]})
};
fetch('https://www.datalab.to/api/v1/collections/{collection_id}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.datalab.to/api/v1/collections/{collection_id}/files"
payload := strings.NewReader("{\n \"uploaded_file_ids\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": 123,
"name": "<string>",
"description": "<string>",
"archived": true,
"created": "2023-11-07T05:31:56Z",
"updated": "2023-11-07T05:31:56Z",
"file_count": 0,
"files": [
{
"uploaded_file_id": 123,
"original_filename": "<string>",
"file_size": 123,
"content_type": "<string>",
"sort_order": 123,
"source_type": "upload",
"external_key": "<string>",
"external_etag": "<string>",
"external_last_modified": "2023-11-07T05:31:56Z",
"external_deleted_at": "2023-11-07T05:31:56Z",
"last_eval_score": 123,
"last_score_breakdown": [
123
]
}
],
"s3_source": {
"id": 123,
"bucket": "<string>",
"prefix": "<string>",
"region": "<string>",
"aws_access_key_id": "<string>",
"aws_secret_access_key_redacted": "<string>",
"sync_status": "<string>",
"last_sync_started_at": "2023-11-07T05:31:56Z",
"last_sync_completed_at": "2023-11-07T05:31:56Z",
"last_sync_file_count": 123,
"last_sync_error": "<string>",
"output_bucket": "<string>",
"output_prefix": "<string>",
"output_region": "<string>",
"output_aws_access_key_id": "<string>",
"output_aws_secret_access_key_redacted": "<string>",
"writeback_status": "<string>",
"last_writeback_run_id": 123,
"last_writeback_started_at": "2023-11-07T05:31:56Z",
"last_writeback_completed_at": "2023-11-07T05:31:56Z",
"last_writeback_file_count": 123,
"last_writeback_total_file_count": 123,
"last_writeback_failed_file_count": 123,
"last_writeback_error": "<string>",
"last_writeback_error_code": "<string>",
"last_writeback_manifest_uri": "<string>"
},
"s3_status": {
"collection_id": 123,
"sync_status": "<string>",
"writeback_status": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Path Parameters
Body
application/json
Required array length:
1 - 100 elementsResponse
Successful Response
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
Previous
Remove File From CollectionUnlink a file from a collection (does NOT delete the uploaded file).
Next
⌘I
Add Files To Collection
import requests
url = "https://www.datalab.to/api/v1/collections/{collection_id}/files"
payload = { "uploaded_file_ids": [123] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://www.datalab.to/api/v1/collections/{collection_id}/files \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"uploaded_file_ids": [
123
]
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({uploaded_file_ids: [123]})
};
fetch('https://www.datalab.to/api/v1/collections/{collection_id}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.datalab.to/api/v1/collections/{collection_id}/files"
payload := strings.NewReader("{\n \"uploaded_file_ids\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": 123,
"name": "<string>",
"description": "<string>",
"archived": true,
"created": "2023-11-07T05:31:56Z",
"updated": "2023-11-07T05:31:56Z",
"file_count": 0,
"files": [
{
"uploaded_file_id": 123,
"original_filename": "<string>",
"file_size": 123,
"content_type": "<string>",
"sort_order": 123,
"source_type": "upload",
"external_key": "<string>",
"external_etag": "<string>",
"external_last_modified": "2023-11-07T05:31:56Z",
"external_deleted_at": "2023-11-07T05:31:56Z",
"last_eval_score": 123,
"last_score_breakdown": [
123
]
}
],
"s3_source": {
"id": 123,
"bucket": "<string>",
"prefix": "<string>",
"region": "<string>",
"aws_access_key_id": "<string>",
"aws_secret_access_key_redacted": "<string>",
"sync_status": "<string>",
"last_sync_started_at": "2023-11-07T05:31:56Z",
"last_sync_completed_at": "2023-11-07T05:31:56Z",
"last_sync_file_count": 123,
"last_sync_error": "<string>",
"output_bucket": "<string>",
"output_prefix": "<string>",
"output_region": "<string>",
"output_aws_access_key_id": "<string>",
"output_aws_secret_access_key_redacted": "<string>",
"writeback_status": "<string>",
"last_writeback_run_id": 123,
"last_writeback_started_at": "2023-11-07T05:31:56Z",
"last_writeback_completed_at": "2023-11-07T05:31:56Z",
"last_writeback_file_count": 123,
"last_writeback_total_file_count": 123,
"last_writeback_failed_file_count": 123,
"last_writeback_error": "<string>",
"last_writeback_error_code": "<string>",
"last_writeback_manifest_uri": "<string>"
},
"s3_status": {
"collection_id": 123,
"sync_status": "<string>",
"writeback_status": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}