API Reference
ByteBox APIs are Next.js route handlers under src/app/api/*.
Cards Collection
Section titled “Cards Collection” GET
/api/cards - Returns
{ boardData, cards, tags }. - Ensures default categories exist when DB is empty.
POST
/api/cards - Creates a card with optional tags.
- Accepts
tagNames: string[](preferred) and legacytagscompatibility input.
PATCH
/api/cards - Bulk reorder/move endpoint.
- Request shape:
{ "updates": [ { "id": "card_1", "categoryId": "cat_2", "order": 3 } ]} DELETE
/api/cards - Destructive maintenance endpoint.
- Deletes all cards, tags, and categories.
Single Card
Section titled “Single Card” GET
/api/cards/[id] - Fetches one card by ID.
- Returns
404if not found.
PUT
/api/cards/[id] - Full update path.
- Returns updated card.
PATCH
/api/cards/[id] - Supports star toggle action:
{ "action": "toggleStar" }
- Supports partial updates:
title,description,content,language,starred,categoryId,tagNames
DELETE
/api/cards/[id] - Deletes one card by ID.
- Returns
404if not found.
Categories
Section titled “Categories” GET
/api/categories - Returns all categories.
POST
/api/categories - Requires
name. - Optional
description. - Defaults
colorto#ec4899.
PATCH
/api/categories/[id] - Supports
nameandcolor. - Validates target category exists.
DELETE
/api/categories/[id] - Deletes a category by ID.
- Existing cards cascade via relation.
GET
/api/tags - Returns tags sorted by name.
- Includes
_count.cardsfor each tag.
POST
/api/tags - Requires non-empty
namewith max length 32. - Restricts
colorto allowed palette values.
DELETE
/api/tags/[id] - Deletes one tag by ID.
Settings
Section titled “Settings” GET
/api/settings - Returns singleton user settings payload.
PATCH
/api/settings - Partial update for appearance/settings state.
PUT
/api/settings - Replace-style update path (same update helper currently).
Data Portability
Section titled “Data Portability” GET
/api/export - Exports metadata + categories/tags/cards payload.
- Does not currently include rich fields like
imageData,fileData,starred.
POST
/api/import - Validates payload shape and app identity (
ByteBox). - Upserts categories, tags, and cards in a transaction.
Health and Response Patterns
Section titled “Health and Response Patterns”- Health check endpoint:
GET /api/cards - Success responses are entity payloads or
{ success: true } - Error payload shape:
{ error: "..." }with HTTP status - Dynamic route params are awaited in handlers:
{ params }: { params: Promise<{ id: string }> }