Worker API Endpoints
Complete reference for all Cloudflare Worker API endpoints.
Authentication
All API endpoints require authentication via Bearer token:
http
Authorization: Bearer your-token-hereCharacter Endpoints
List All Characters
http
GET /api/charactersResponse:
json
[
{
"id": "char-example-123",
"name": "Character Name",
"origin": "Feudal World",
"faction": "Inquisition",
"role": "Warrior",
"characteristics": {...},
"skills": {...},
"talents": [...],
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]Notes:
- Returns only non-deleted characters
- Automatically filters out history entries
- Results include migrated UUID identifiers
Get Character by ID
http
GET /api/characters/:idParameters:
id- Character UUID
Response:
json
{
"id": "char-example-123",
"name": "Character Name",
"characteristics": {
"ws": 35,
"bs": 30,
"str": 30,
"tgh": 35,
"ag": 30,
"int": 35,
"per": 30,
"wil": 35,
"fel": 30
},
"skills": {
"athletics": {
"advances": 2,
"specializations": {}
}
},
"talents": ["hardy", "combat_master"],
"equipment": [],
"wounds": { "current": 10, "max": 10 },
"fate": 3,
"influence": 30
}Create Character
http
POST /api/charactersRequest Body:
json
{
"name": "New Character",
"origin": "Hive World",
"faction": "Administratum",
"role": "Savant",
"characteristics": {...}
}Response:
json
{
"id": "char-new-character-1234567890-abc123",
"name": "New Character",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z",
...
}Notes:
- ID is auto-generated if not provided
- Creates history entry automatically
- Timestamps are added server-side
Update Character
http
PUT /api/characters/:idRequest Body:
json
{
"name": "Updated Name",
"skills": {
"athletics": {
"advances": 3
}
}
}Response:
json
{
"id": "char-example-123",
"updated_at": "2024-01-01T00:00:00Z",
...
}Notes:
- Creates history snapshot before update
- Preserves existing data not in request
- Updates timestamp automatically
Delete Character (Soft Delete)
http
DELETE /api/characters/:idResponse:
json
{
"success": true
}Notes:
- Marks character as deleted (
_deleted: true) - Character remains in storage but hidden from normal queries
- Can be restored via admin panel
Journal Endpoints
List Journal Entries
http
GET /api/journal?characterId=char-example-123Query Parameters:
characterId(optional) - Filter by character
Response:
json
[
{
"id": "journal-entry-123",
"character_id": "char-example-123",
"title": "Session 1",
"content": "Journal content...",
"session_date": "2024-01-01",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]Create Journal Entry
http
POST /api/journalRequest Body:
json
{
"character_id": "char-example-123",
"title": "Session Title",
"content": "What happened in the session...",
"session_date": "2024-01-01"
}Response:
json
{
"id": "journal-entry-456",
"character_id": "char-example-123",
"created_at": "2024-01-01T00:00:00Z",
...
}Admin Endpoints
Get All Characters (Including Deleted)
http
GET /api/admin/charactersResponse:
json
[
{
"id": "char-example-123",
"name": "Active Character",
"_deleted": false,
...
},
{
"id": "char-deleted-456",
"name": "Deleted Character",
"_deleted": true,
"_deletedAt": "2024-01-01T00:00:00Z",
...
}
]Get Character History
http
GET /api/admin/history/character/:idResponse:
json
[
{
"id": "char-example-123",
"name": "Character Name",
"updated_at": "2024-01-01T12:00:00Z",
...
},
{
"id": "char-example-123",
"name": "Character Name (Old)",
"updated_at": "2024-01-01T10:00:00Z",
...
}
]Notes:
- Returns all versions sorted by date (newest first)
- Each entry represents a snapshot at that time
- Can be used to restore previous versions
Permanent Delete
http
DELETE /api/admin/characters/:idResponse:
json
{
"success": true,
"deleted": {
"character": 1,
"history": 5,
"journal": 10
}
}Warning:
- Permanently removes character from KV storage
- Deletes all history entries
- Deletes all journal entries
- Cannot be undone!
Nuke All Data
http
DELETE /api/admin/nukeResponse:
json
{
"success": true,
"deleted": {
"characters": 25,
"journal": 150
}
}Warning:
- Removes ALL data for the token
- Includes all characters, history, and journals
- Cannot be undone!
Import Data
http
POST /api/admin/importRequest Body:
json
{
"characters": [
{
"id": "char-example-123",
"name": "Imported Character",
...
}
],
"journal": [
{
"id": "journal-entry-123",
"character_id": "char-example-123",
...
}
]
}Response:
json
{
"success": true,
"imported": {
"characters": 2,
"journal": 10
}
}Error Responses
401 Unauthorized
json
{
"error": "Unauthorized"
}404 Not Found
json
{
"error": "Character not found"
}400 Bad Request
json
{
"error": "Invalid data format"
}500 Internal Server Error
json
{
"error": "Error message"
}Rate Limiting
The API implements the following rate limits:
- 100 requests per minute per token
- 1000 requests per hour per token
- Burst allowance of 10 requests
Exceeded limits return 429 Too Many Requests.
CORS Configuration
The API allows requests from any origin:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, AuthorizationData Formats
Character ID Format
char-{name-slug}-{timestamp}-{random}Example: char-john-doe-1704067200000-abc123
Journal ID Format
journal-{uuid-v4}Example: journal-550e8400-e29b-41d4-a716-446655440000
Timestamps
All timestamps use ISO 8601 format:
2024-01-01T00:00:00.000Z