-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Complete API documentation for KV Manager endpoints.
-
Production: Your Worker URL (e.g.,
https://kv-manager.yourteam.workers.dev) -
Development:
http://localhost:8787
All production API requests require a valid Cloudflare Access JWT token.
Header:
cf-access-jwt-assertion: YOUR_JWT_TOKEN
Note: Authentication is bypassed for localhost requests in development.
{
"success": true,
"data": { ... }
}{
"success": false,
"error": "Error message"
}GET /api/namespacesResponse:
{
"success": true,
"data": [
{
"id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
"title": "my-namespace",
"supports_url_encoding": true
}
]
}POST /api/namespacesBody:
{
"title": "my-new-namespace"
}Response:
{
"success": true,
"data": {
"id": "...",
"title": "my-new-namespace"
}
}DELETE /api/namespaces/:idResponse:
{
"success": true
}PATCH /api/namespaces/:id/renameBody:
{
"title": "new-namespace-name"
}Response:
{
"success": true
}GET /api/namespaces/:id/infoResponse:
{
"success": true,
"data": {
"id": "...",
"title": "my-namespace",
"keyCount": 1234,
"firstAccessed": "2025-11-01T12:00:00.000Z",
"lastAccessed": "2025-11-21T15:30:00.000Z"
}
}GET /api/keys/:namespaceId/list?limit=100&cursor=optionalQuery Parameters:
-
limit(optional) - Number of keys to return (default: 100, max: 1000) -
cursor(optional) - Pagination cursor from previous response
Response:
{
"success": true,
"data": {
"keys": [
{
"name": "user:123",
"expiration": 1735689600,
"metadata": {
"type": "user"
}
}
],
"cursor": "next_page_cursor",
"list_complete": false
}
}GET /api/keys/:namespaceId/:keyNameResponse:
{
"success": true,
"data": {
"value": "John Doe",
"metadata": {
"type": "user"
}
}
}PUT /api/keys/:namespaceId/:keyNameBody:
{
"value": "New value",
"ttl": 3600,
"metadata": {
"type": "example"
}
}Fields:
-
value(required) - Key value (string) -
ttl(optional) - Time-to-live in seconds (minimum 60) -
expiration(optional) - Unix timestamp for absolute expiration -
metadata(optional) - KV Native Metadata (max 1024 bytes)
Response:
{
"success": true
}DELETE /api/keys/:namespaceId/:keyNameResponse:
{
"success": true
}POST /api/keys/:namespaceId/bulk-deleteBody:
{
"keys": ["key1", "key2", "key3"]
}Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued",
"ws_url": "wss://..."
}
}Note: Use polling endpoint /api/jobs/:jobId to track progress.
POST /api/keys/:namespaceId/bulk-copyBody:
{
"keys": ["key1", "key2"],
"targetNamespaceId": "target_namespace_id"
}Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued"
}
}POST /api/keys/:namespaceId/bulk-ttlBody:
{
"keys": ["key1", "key2"],
"ttl": 3600
}Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued"
}
}GET /api/metadata/:namespaceId/:keyNameResponse:
{
"success": true,
"data": {
"custom_metadata": {
"email": "user@example.com",
"extended_info": "..."
},
"tags": ["production", "active"]
}
}PUT /api/metadata/:namespaceId/:keyNameBody:
{
"custom_metadata": {
"email": "user@example.com"
},
"tags": ["production", "active", "premium"]
}Response:
{
"success": true
}POST /api/metadata/:namespaceId/bulk-tagBody:
{
"keys": ["key1", "key2"],
"tags": ["production", "v2"],
"operation": "add"
}Operations:
-
add- Add tags to existing tags -
remove- Remove specified tags -
replace- Replace all tags
Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued"
}
}GET /api/search?query=user&namespaceId=...&tags=production,cacheQuery Parameters:
-
query(optional) - Key name pattern (partial match) -
namespaceId(optional) - Filter to specific namespace -
tags(optional) - Comma-separated tags (all must match)
Response:
{
"success": true,
"data": [
{
"namespace_id": "...",
"key_name": "user:123",
"custom_metadata": {...},
"tags": ["production", "active"]
}
]
}Note: Only searches keys with metadata in D1. External keys must be indexed first.
GET /api/export/:namespaceId?format=jsonQuery Parameters:
-
format(optional) -jsonorndjson(default:json)
Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued",
"ws_url": "wss://..."
}
}POST /api/import/:namespaceId?collision=overwriteQuery Parameters:
-
collision(optional) -skip,overwrite, orfail(default:skip)
Body: JSON or NDJSON array of key objects
Example:
[
{
"name": "key1",
"value": "value1",
"ttl": 3600,
"metadata": {"type": "example"},
"custom_metadata": {"extended": "data"},
"tags": ["production"]
}
]Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued"
}
}GET /api/jobs/:jobIdResponse:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "running",
"operation_type": "export",
"total_keys": 1000,
"processed_keys": 500,
"error_count": 0,
"current_key": "user:500",
"percentage": 50,
"started_at": "2025-11-21T12:00:00.000Z",
"completed_at": null
}
}Status Values:
-
queued- Job is queued -
running- Job is in progress -
completed- Job finished successfully -
failed- Job failed with errors
GET /api/jobs/:jobId/downloadResponse: File download (JSON or NDJSON)
GET /api/r2-backup/:namespaceId/listResponse:
{
"success": true,
"data": [
{
"path": "backups/namespace123/1700000000000.json",
"timestamp": 1700000000000,
"size": 1048576,
"uploaded": "2025-11-15T10:00:00.000Z"
}
]
}POST /api/r2-backup/:namespaceId?format=jsonQuery Parameters:
-
format(optional) -jsonorndjson(default:json)
Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued"
}
}POST /api/r2-restore/:namespaceIdBody:
{
"backupPath": "backups/namespace123/1700000000000.json"
}Response:
{
"success": true,
"data": {
"job_id": "job_abc123",
"status": "queued"
}
}Note: Restore always overwrites existing keys.
GET /api/jobs?limit=50&offset=0&status=completed&operation_type=exportQuery Parameters:
-
limit(optional) - Results per page (default: 50) -
offset(optional) - Pagination offset (default: 0) -
status(optional) - Filter by status -
operation_type(optional) - Filter by operation type -
namespace_id(optional) - Filter by namespace -
start_date(optional) - Filter by start date (ISO timestamp) -
end_date(optional) - Filter by end date (ISO timestamp) -
job_id(optional) - Search by job ID (partial match) -
min_errors(optional) - Filter jobs with error_count >= threshold -
sort_by(optional) - Column to sort by (default:started_at) -
sort_order(optional) -ascordesc(default:desc)
Response:
{
"success": true,
"data": {
"jobs": [...],
"total": 100,
"limit": 50,
"offset": 0
}
}GET /api/jobs/:jobId/eventsResponse:
{
"success": true,
"data": [
{
"event_type": "started",
"timestamp": "2025-11-21T12:00:00.000Z",
"metadata": {}
},
{
"event_type": "progress_25",
"timestamp": "2025-11-21T12:05:00.000Z",
"metadata": {
"processed": 250,
"total": 1000
}
}
]
}Event Types:
-
started- Job started -
progress_25- 25% complete -
progress_50- 50% complete -
progress_75- 75% complete -
completed- Job completed -
failed- Job failed
GET /api/audit/:namespaceId?limit=100&offset=0&operation=createQuery Parameters:
-
limit(optional) - Results per page (default: 100) -
offset(optional) - Pagination offset (default: 0) -
operation(optional) - Filter by operation type
Response:
{
"success": true,
"data": {
"logs": [
{
"id": 123,
"namespace_id": "...",
"key_name": "user:123",
"operation": "create",
"user_email": "user@example.com",
"timestamp": "2025-11-21T12:00:00.000Z",
"details": "Created key with TTL"
}
],
"total": 1000
}
}GET /api/audit/user/:userEmail?limit=100&offset=0Response: Same format as namespace audit log
POST /api/admin/sync-keys/:namespaceIdIndexes all keys in a namespace for search. Useful for keys created outside the UI.
Response:
{
"success": true,
"data": {
"total_keys": 1000,
"synced": 1000
}
}POST /api/backup/:namespaceId/:keyName/undoCreates a backup of the current key value before modification.
Response:
{
"success": true
}GET /api/backup/:namespaceId/:keyName/checkResponse:
{
"success": true,
"data": {
"exists": true,
"timestamp": "2025-11-21T12:00:00.000Z"
}
}- Bulk Operations: Processed in batches of 10,000 keys
- List Keys: Max 1000 keys per request
- API Requests: Subject to Cloudflare Workers rate limits
| Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Missing or invalid JWT |
| 403 | Forbidden - Access denied |
| 404 | Not Found - Resource doesn't exist |
| 500 | Internal Server Error - Worker error |
Currently not supported. Use job polling for progress updates.
- User Guide - Learn the UI
- Bulk Operations - Advanced bulk processing
- Troubleshooting - Common API issues
Getting Started
User Documentation
- User Guide
- Namespace Management
- Key Operations
- Metadata and Tags
- Search and Discovery
- Bulk Operations
- Import and Export
- R2 Backup and Restore
- Job History
- Audit Logging
Technical
Guides
Links