API Reference
Manage documents using the CloudKey REST API. Upload, view, download, and delete files securely across MinIO and AWS S3.
http://localhost:3001
Authentication & Rate Limits
All document API endpoints require a single request header for authentication. Pass the secret key that was generated when your organization was provisioned.
Rate Limiting: Requests are limited to 100 requests per 15 minutes per IP address.
Required Header
Include this header on every request to the Documents API.
| Header | Type | Description |
|---|---|---|
| x-secret-key | string | Your organization's secret access key REQUIRED |
Providers
CloudKey supports two storage backends. Set the x-provider header on every request to select the one relevant to your organization.
| Value | Endpoint Used | Notes |
|---|---|---|
| minio | MINIO_ENDPOINT (.env) | Uses path-style routing. Default: http://localhost:9000 |
| aws-s3 | Standard AWS S3 | Uses AWS region from AWS_REGION env variable |
Folder Structure
CloudKey automatically enforces a consistent folder layout for all uploads. If your key does not already start with your orgname, it is rewritten automatically.
key = report.pdf with x-orgname: acme-corp will automatically store the file at acme-corp/documents/2026-08/report.pdf.
Upload Document
Upload a file to your organization's storage bucket. The request must be sent as multipart/form-data. The folder path is enforced automatically based on your org name and the current date.
Request Body — multipart/form-data
| Field | Type | Description |
|---|---|---|
| folder_name | string | Target subfolder (e.g., invoices, reports) REQUIRED |
| file | file | Binary file content to upload REQUIRED |
Code Example
200 — Success Response
View / Download Document
Returns a temporary presigned URL for the specified document. This URL allows any HTTP client or browser to securely access the file for up to 1 hour without additional credentials.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| key | string | Full path to the file (e.g. acme-corp/documents/2026-08/reports/report.pdf) REQUIRED |
Code Example
200 — Success Response
Delete Document
Permanently removes a document from the storage bucket. This operation is irreversible. Ensure you have the correct key before proceeding.
Request Body — application/json
| Field | Type | Description |
|---|---|---|
| key | string | Full path to the file to delete REQUIRED |
Code Example
200 — Success Response
Error Codes
All error responses follow a consistent JSON format with a success: false flag and a descriptive message.
| HTTP Code | Meaning | Common Cause |
|---|---|---|
| 400 | Bad Request | Missing required field (folder_name, key, or file) |
| 401 | Unauthorized | Missing x-secret-key header |
| 403 | Forbidden | Invalid secret key |
| 429 | Too Many Requests | Rate limit exceeded (100 reqs / 15 mins) |
| 500 | Internal Server Error | Storage service unreachable or misconfigured .env |
Error Response Shape