Campaigns API
Campaigns API
Section titled “Campaigns API”Campaign management endpoints for organizing your tabletop RPG content.
Endpoints
Section titled “Endpoints”GET /api/campaigns
Section titled “GET /api/campaigns”Get all campaigns for the authenticated user.
Response:
[ { "id": 1, "slug": "lost-mine-of-phandelver", "name": "Lost Mine of Phandelver", "description": null, "createdAt": "2024-01-15T10:30:00Z", "updatedAt": "2024-01-20T14:15:00Z", "userId": "user_123" }]
POST /api/campaigns
Section titled “POST /api/campaigns”Create a new campaign.
Request Body:
{ "newCampaign": { "name": "Dragon Heist Campaign" }}
Response:
{ "id": 2, "slug": "dragon-heist-campaign", "name": "Dragon Heist Campaign", "description": null, "createdAt": "2024-01-21T09:00:00Z", "updatedAt": "2024-01-21T09:00:00Z", "userId": "user_123"}
GET /api/campaigns/[campaignSlug]
Section titled “GET /api/campaigns/[campaignSlug]”Get a specific campaign by slug.
Parameters:
campaignSlug
(string) - URL-safe campaign identifier
Response:
{ "id": 1, "slug": "lost-mine-of-phandelver", "name": "Lost Mine of Phandelver", "description": [ { "type": "paragraph", "children": [{ "text": "A classic D&D starter adventure..." }] } ], "createdAt": "2024-01-15T10:30:00Z", "updatedAt": "2024-01-20T14:15:00Z", "userId": "user_123"}
PUT /api/campaigns/[campaignSlug]
Section titled “PUT /api/campaigns/[campaignSlug]”Update an existing campaign.
Request Body:
{ "updatedCampaign": { "slug": "lost-mine-of-phandelver", "name": "Lost Mine of Phandelver - Updated", "description": "Updated description" }}
DELETE /api/campaigns/[campaignSlug]
Section titled “DELETE /api/campaigns/[campaignSlug]”Delete a campaign and all associated data.
Response:
{ "success": true}
- Campaign slugs are automatically generated from names
- Deleting a campaign cascades to all associated arcs, things, and relationships
- Campaign ownership is enforced - users can only access their own campaigns