Upload Raw Data File
Upload a physical file to an existing raw data record.
Endpoint
POST https://api.platform.knowledgator.com/data/{id}/files/upload/
Headers
| Name | Type | Description |
|---|---|---|
KnowledgatorAPI-Key | String | Your API key |
Content-Type | String | multipart/form-data |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Unique data identifier |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The file to upload |
Response
{
"id": "data-123",
"name": "Single Data Item",
"type": "ner",
"format": "jsonl",
"status": "processing",
"created_at": "2024-01-15T10:30:00Z"
}
Error Codes
| Status Code | Description |
|---|---|
| 200 | OK – Upload successful. |
| 400 | Bad Request – Invalid or missing file. |
| 401 | Unauthorized – Invalid API key. |
| 404 | Not Found – Invalid data ID. |
| 500 | Internal Server Error – Server-side issue. |
Example Usage
SDK Usage
💡 Dedicated SDK Guides: See Python SDK | TypeScript SDK
TypeScript/JavaScript
import { createClient } from '@knowledgator/typescript-sdk';
import { readFile } from 'fs/promises';
const kg = createClient('YOUR_API_KEY');
const fileContent = await readFile('./my-data.jsonl');
await kg.datasets.uploadData('data-123', {
file: new File([fileContent], 'my-data.jsonl')
});
Python
from knowledgator import Knowledgator
kg = Knowledgator(api_key="YOUR_API_KEY")
with open("my-data.jsonl", "rb") as f:
kg.datasets.upload_data('data-123', file=f)
Python Requests
import requests
data_id = "data-123"
url = f"https://api.platform.knowledgator.com/data/{data_id}/files/upload/"
headers = {
"KnowledgatorAPI-Key": "YOUR_API_KEY"
}
files = {
"file": open("my-data.jsonl", "rb")
}
response = requests.post(url, headers=headers, files=files)
print(response.json())
cURL
curl -X POST https://api.platform.knowledgator.com/data/data-123/files/upload/ \
-H "KnowledgatorAPI-Key: YOUR_API_KEY" \
-F "file=@my-data.jsonl"
Additional Information
- Processing: Uploaded files will trigger data processing. Monitor the record's
statusto know when it's ready. - Use Cases:
- Adding content to placeholder records
- Updating existing data
- Batching uploads via scripts