curl https://api.u1.archetypeai.app/v0.5/files/download/file-abc123 \
-H "Authorization: Bearer $ATAI_API_KEY" \
-o downloaded_file.csv
import requests
import os
api_key = os.environ.get("ATAI_API_KEY")
file_id = "file-abc123"
response = requests.get(
f"https://api.u1.archetypeai.app/v0.5/files/download/{file_id}",
headers={"Authorization": f"Bearer {api_key}"},
stream=True,
)
response.raise_for_status()
with open("downloaded_file.csv", "wb") as fh:
for chunk in response.iter_content(chunk_size=1 << 20):
fh.write(chunk)
print(f"Downloaded {file_id}")
import fs from "node:fs";
import { Readable } from "node:stream";
const fileId = "file-abc123";
const response = await fetch(
`https://api.u1.archetypeai.app/v0.5/files/download/${fileId}`,
{
headers: {
Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
},
}
);
if (!response.ok) {
throw new Error(`Download failed: ${response.status}`);
}
const out = fs.createWriteStream("downloaded_file.csv");
Readable.fromWeb(response.body).pipe(out);
<binary file contents — Content-Type: application/octet-stream>
{
"errors": [
{
"code": "file_not_downloadable",
"message": "File exists but is not in a downloadable state (status: Uploading).",
"suggestion": "Wait for the file to reach the Registered status before downloading.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "unauthorized_request",
"message": "Unauthorized or invalid access.",
"suggestion": "Provide valid authentication credentials and ensure they have the required permissions.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "file_not_found",
"message": "No file with the given file_id was found for the organization.",
"suggestion": "Verify the file_id and that the file has not been deleted.",
"error_uid": "err-xxxxxxxx"
}
]
}
Files API
Download File
Download the raw bytes of a previously uploaded file
GET
/
files
/
download
/
{file_id}
curl https://api.u1.archetypeai.app/v0.5/files/download/file-abc123 \
-H "Authorization: Bearer $ATAI_API_KEY" \
-o downloaded_file.csv
import requests
import os
api_key = os.environ.get("ATAI_API_KEY")
file_id = "file-abc123"
response = requests.get(
f"https://api.u1.archetypeai.app/v0.5/files/download/{file_id}",
headers={"Authorization": f"Bearer {api_key}"},
stream=True,
)
response.raise_for_status()
with open("downloaded_file.csv", "wb") as fh:
for chunk in response.iter_content(chunk_size=1 << 20):
fh.write(chunk)
print(f"Downloaded {file_id}")
import fs from "node:fs";
import { Readable } from "node:stream";
const fileId = "file-abc123";
const response = await fetch(
`https://api.u1.archetypeai.app/v0.5/files/download/${fileId}`,
{
headers: {
Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
},
}
);
if (!response.ok) {
throw new Error(`Download failed: ${response.status}`);
}
const out = fs.createWriteStream("downloaded_file.csv");
Readable.fromWeb(response.body).pipe(out);
<binary file contents — Content-Type: application/octet-stream>
{
"errors": [
{
"code": "file_not_downloadable",
"message": "File exists but is not in a downloadable state (status: Uploading).",
"suggestion": "Wait for the file to reach the Registered status before downloading.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "unauthorized_request",
"message": "Unauthorized or invalid access.",
"suggestion": "Provide valid authentication credentials and ensure they have the required permissions.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "file_not_found",
"message": "No file with the given file_id was found for the organization.",
"suggestion": "Verify the file_id and that the file has not been deleted.",
"error_uid": "err-xxxxxxxx"
}
]
}
Overview
This endpoint streams the raw contents of a previously uploaded file. The response body isapplication/octet-stream — the file as it was uploaded.
The file must be in a downloadable state. Files that are still uploading, deleted, or corrupt will return 400.
Path Parameters
string
required
Identifier of the file to download
Response
The response body is the raw file bytes withContent-Type: application/octet-stream.
curl https://api.u1.archetypeai.app/v0.5/files/download/file-abc123 \
-H "Authorization: Bearer $ATAI_API_KEY" \
-o downloaded_file.csv
import requests
import os
api_key = os.environ.get("ATAI_API_KEY")
file_id = "file-abc123"
response = requests.get(
f"https://api.u1.archetypeai.app/v0.5/files/download/{file_id}",
headers={"Authorization": f"Bearer {api_key}"},
stream=True,
)
response.raise_for_status()
with open("downloaded_file.csv", "wb") as fh:
for chunk in response.iter_content(chunk_size=1 << 20):
fh.write(chunk)
print(f"Downloaded {file_id}")
import fs from "node:fs";
import { Readable } from "node:stream";
const fileId = "file-abc123";
const response = await fetch(
`https://api.u1.archetypeai.app/v0.5/files/download/${fileId}`,
{
headers: {
Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
},
}
);
if (!response.ok) {
throw new Error(`Download failed: ${response.status}`);
}
const out = fs.createWriteStream("downloaded_file.csv");
Readable.fromWeb(response.body).pipe(out);
<binary file contents — Content-Type: application/octet-stream>
{
"errors": [
{
"code": "file_not_downloadable",
"message": "File exists but is not in a downloadable state (status: Uploading).",
"suggestion": "Wait for the file to reach the Registered status before downloading.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "unauthorized_request",
"message": "Unauthorized or invalid access.",
"suggestion": "Provide valid authentication credentials and ensure they have the required permissions.",
"error_uid": "err-xxxxxxxx"
}
]
}
{
"errors": [
{
"code": "file_not_found",
"message": "No file with the given file_id was found for the organization.",
"suggestion": "Verify the file_id and that the file has not been deleted.",
"error_uid": "err-xxxxxxxx"
}
]
}
Was this page helpful?
⌘I