API Reference
Complete reference for the SparkDB Buckets API. All endpoints, request formats, response types, and error codes.
Base URLs
Authentication
| API | Method |
|---|---|
| Client API | Session cookie / JWT (from dashboard login) |
| Developer API | x-api-key: spk_your_api_key or Authorization: Bearer spk_your_api_key |
Endpoints
Create Bucket
curl
Request Body
| Field | Type | Default | Description |
|---|---|---|---|
name | string | required | Bucket name, 3–40 chars, ^[a-z0-9][a-z0-9_-]{1,38}[a-z0-9]$ |
visibility | string | "private" | "public" or "private" |
public | boolean | false | Alternative to visibility |
Response 201
List Buckets
curl
Response 200
Get Bucket
curl
Response 200
Response 404
Delete Bucket
curl
Response 200
Update Visibility
curl
Request Body
| Field | Type | Description |
|---|---|---|
visibility | string | "public" or "private" |
Response 200
List Files
curl
Response 200
Upload File
curl
Response 201
Response 409
Upload File (Raw Body)
curl
Content-Type header sets the file’s MIME type. Use this for programmatic uploads where multipart form data is not convenient.
Download File
curl
Content-Type and Content-Length headers.
Get File Metadata
curl
Content-Type, Content-Length, ETag, and Last-Modified. No response body.
Delete File
curl
Response 200
Client API Endpoints
The client API (session-based) mirrors the developer API but under/api/buckets:
| Method | Path | Description |
|---|---|---|
GET | /api/buckets | List buckets |
POST | /api/buckets | Create bucket |
GET | /api/buckets/:id | Get bucket |
DELETE | /api/buckets/:id | Delete bucket |
POST / PATCH | /api/buckets/:id/visibility | Update visibility |
GET | /api/buckets/:id/files | List files |
GET | /api/buckets/:id/objects | List files (alias) |
POST | /api/buckets/:id/files | Upload file (multipart) |
POST | /api/buckets/:id/upload | Upload file (alias) |
PUT | /api/buckets/:id/files/:filename | Upload file (raw body) |
HEAD | /api/buckets/:id/files/:filename | Get file metadata |
GET | /api/buckets/:id/files/:filename | Download file |
DELETE | /api/buckets/:id/files/:filename | Delete file |
Developer API Endpoints
The developer API also supports these additional aliases under/api/v1/buckets:
| Method | Path | Description |
|---|---|---|
GET | /api/v1/buckets/list | List buckets (alias) |
POST | /api/v1/buckets/create | Create bucket (alias) |
DELETE | /api/v1/buckets/:id/delete | Delete bucket (alias) |
DELETE | /api/v1/buckets/:id/files/:filename/delete | Delete file (alias) |
Object Reference
StorageBucket
| Field | Type | Description |
|---|---|---|
id | number | Unique bucket identifier |
name | string | Human-readable bucket name |
public | boolean | Whether files are publicly accessible |
object_count | number | Number of files in the bucket |
total_bytes | number | Total storage used by the bucket |
created_at | string | ISO 8601 timestamp |
BucketObject
| Field | Type | Description |
|---|---|---|
id | string | Object identifier ({bucketId}/{filename}) |
bucket_id | number | Parent bucket ID |
storage_name | string | S3 key name |
filename | string | Original filename |
size | number | File size in bytes |
content_type | string | MIME type |
url | string | Download URL |
created_at | string | ISO 8601 timestamp |
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
BucketNotFoundError | 404 | Bucket doesn’t exist or was soft-deleted |
StorageLimitExceededError | 409 | Upload exceeds plan storage limit. Error message includes plan limit. |
| Validation error | 400 | Invalid bucket name, missing fields |
| Unauthorized | 401 | Missing or invalid API key |
