# Encode the file first
base64 -i /path/to/local/file.csv -o /tmp/file.b64
curl -X POST https://api.u1.archetypeai.app/v0.5/files/base64 \
-H "Authorization: Bearer $ATAI_API_KEY" \
-F "file=@/tmp/file.b64;filename=file.csv"
import base64
import io
import requests
import os
api_key = os.environ.get("ATAI_API_KEY")
with open("/path/to/local/file.csv", "rb") as fh:
encoded = base64.b64encode(fh.read())
response = requests.post(
"https://api.u1.archetypeai.app/v0.5/files/base64",
headers={"Authorization": f"Bearer {api_key}"},
files={"file": ("file.csv", io.BytesIO(encoded), "text/csv")},
)
result = response.json()
if result.get("is_valid"):
print(f"Uploaded: {result['file_id']}")
else:
print(f"Errors: {result.get('errors')}")
import fs from "node:fs";
const encoded = fs.readFileSync("/path/to/local/file.csv").toString("base64");
const form = new FormData();
form.append("file", new Blob([encoded]), "file.csv");
const response = await fetch(
"https://api.u1.archetypeai.app/v0.5/files/base64",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
},
body: form,
}
);
const result = await response.json();
if (result.is_valid) {
console.log(`Uploaded: ${result.file_id}`);
} else {
console.error("Errors:", result.errors);
}
{
"is_valid": true,
"file_id": "file-abc123",
"file_uid": "8f2c1e5a-7b3d-4d9e-9c1a-2f5b7d8e4a6c"
}
{
"errors": [
{
"code": "invalid_base64",
"message": "File contents are not valid base64.",
"suggestion": "Ensure the form field contains correctly base64-encoded data.",
"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_already_exists",
"message": "A file with this name already exists for the organization.",
"suggestion": "Delete the existing file first or upload with a different filename.",
"error_uid": "err-xxxxxxxx"
}
]
}
Files API
Upload Base64 File
Upload a file with base64-encoded contents via streaming multipart/form-data
POST
/
files
/
base64
# Encode the file first
base64 -i /path/to/local/file.csv -o /tmp/file.b64
curl -X POST https://api.u1.archetypeai.app/v0.5/files/base64 \
-H "Authorization: Bearer $ATAI_API_KEY" \
-F "file=@/tmp/file.b64;filename=file.csv"
import base64
import io
import requests
import os
api_key = os.environ.get("ATAI_API_KEY")
with open("/path/to/local/file.csv", "rb") as fh:
encoded = base64.b64encode(fh.read())
response = requests.post(
"https://api.u1.archetypeai.app/v0.5/files/base64",
headers={"Authorization": f"Bearer {api_key}"},
files={"file": ("file.csv", io.BytesIO(encoded), "text/csv")},
)
result = response.json()
if result.get("is_valid"):
print(f"Uploaded: {result['file_id']}")
else:
print(f"Errors: {result.get('errors')}")
import fs from "node:fs";
const encoded = fs.readFileSync("/path/to/local/file.csv").toString("base64");
const form = new FormData();
form.append("file", new Blob([encoded]), "file.csv");
const response = await fetch(
"https://api.u1.archetypeai.app/v0.5/files/base64",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
},
body: form,
}
);
const result = await response.json();
if (result.is_valid) {
console.log(`Uploaded: ${result.file_id}`);
} else {
console.error("Errors:", result.errors);
}
{
"is_valid": true,
"file_id": "file-abc123",
"file_uid": "8f2c1e5a-7b3d-4d9e-9c1a-2f5b7d8e4a6c"
}
{
"errors": [
{
"code": "invalid_base64",
"message": "File contents are not valid base64.",
"suggestion": "Ensure the form field contains correctly base64-encoded data.",
"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_already_exists",
"message": "A file with this name already exists for the organization.",
"suggestion": "Delete the existing file first or upload with a different filename.",
"error_uid": "err-xxxxxxxx"
}
]
}
Requires version 1.1.5 or later of the Archetype platform.
File Upload Note: The interactive playground doesn’t support file uploads due to browser limitations. Use the cURL examples below to test file uploads.
Overview
Upload a file whose contents have been Base64-encoded. The request body ismultipart/form-data; the server decodes the Base64 payload as it streams.
Use this endpoint when the source environment cannot transmit raw binary contents (for example, embedding a small file in a JSON-bearing channel that has been wrapped in a multipart form).
For files larger than the simple-upload cap, or any case that needs resumable uploads, use the direct-to-cloud multipart flow (up to 250 GB) instead.
Request
The request must be sent asmultipart/form-data with a form field containing the base64-encoded file contents. The server decodes the contents on the fly.
Supported File Types
The server’sContent-Type validator accepts:
- Images:
image/jpeg,image/png - Video:
video/mp4 - Text & data:
text/plain,text/csv,application/json
application/x-ndjson) is not accepted by this endpoint — use the multipart flow for JSONL.
Maximum size: 512 MB (after Base64 encoding). The Developer Console UI caps its uploads through this endpoint at 255 MB.
Response
boolean
Whether the upload was successful. Check this field to detect errors.
string
Filename of the uploaded file. Use this to download, delete, or fetch metadata for the file.
string
Internal unique identifier for the uploaded file.
# Encode the file first
base64 -i /path/to/local/file.csv -o /tmp/file.b64
curl -X POST https://api.u1.archetypeai.app/v0.5/files/base64 \
-H "Authorization: Bearer $ATAI_API_KEY" \
-F "file=@/tmp/file.b64;filename=file.csv"
import base64
import io
import requests
import os
api_key = os.environ.get("ATAI_API_KEY")
with open("/path/to/local/file.csv", "rb") as fh:
encoded = base64.b64encode(fh.read())
response = requests.post(
"https://api.u1.archetypeai.app/v0.5/files/base64",
headers={"Authorization": f"Bearer {api_key}"},
files={"file": ("file.csv", io.BytesIO(encoded), "text/csv")},
)
result = response.json()
if result.get("is_valid"):
print(f"Uploaded: {result['file_id']}")
else:
print(f"Errors: {result.get('errors')}")
import fs from "node:fs";
const encoded = fs.readFileSync("/path/to/local/file.csv").toString("base64");
const form = new FormData();
form.append("file", new Blob([encoded]), "file.csv");
const response = await fetch(
"https://api.u1.archetypeai.app/v0.5/files/base64",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ATAI_API_KEY}`,
},
body: form,
}
);
const result = await response.json();
if (result.is_valid) {
console.log(`Uploaded: ${result.file_id}`);
} else {
console.error("Errors:", result.errors);
}
{
"is_valid": true,
"file_id": "file-abc123",
"file_uid": "8f2c1e5a-7b3d-4d9e-9c1a-2f5b7d8e4a6c"
}
{
"errors": [
{
"code": "invalid_base64",
"message": "File contents are not valid base64.",
"suggestion": "Ensure the form field contains correctly base64-encoded data.",
"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_already_exists",
"message": "A file with this name already exists for the organization.",
"suggestion": "Delete the existing file first or upload with a different filename.",
"error_uid": "err-xxxxxxxx"
}
]
}
Was this page helpful?