REST API
Manage custom sheet templates from any HTTP client, script, or IDE. No AI assistant required — just standard REST calls with your API key. API access requires a paid plan (Table, $5/month). Anything that runs the AI also uses AI credits.
Authentication
All API requests require an API key sent as a Bearer token. Generate a key from Developer Tools in your avatar menu.
Authorization: Bearer ph_...
All responses are JSON. Errors return { "error": "..." } with an appropriate HTTP status code.
Endpoints
GET /api/custom-sheet-templates
List all custom sheet templates owned by the authenticated user.
curl https://polyhedral.co/api/custom-sheet-templates \ -H "Authorization: Bearer ph_..."
Returns an array of template objects.
POST /api/custom-sheet-templates
Create a new template. Required fields: name, code, buildType.
curl -X POST https://polyhedral.co/api/custom-sheet-templates \
-H "Authorization: Bearer ph_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Sci-Fi Character",
"code": "<Section title=\"Stats\"><Field name=\"hp\" type=\"number\" /></Section>",
"buildType": "in-app",
"description": "A sci-fi RPG character sheet",
"fieldSchema": [
{ "name": "hp", "type": "number", "label": "Hit Points", "default": 10 }
]
}'Request Body
name(string, required) — display namecode(string, required) — JSX source codebuildType(string, required) —"in-app"or"external"description(string, optional)source(string, optional) — attribution or originfieldSchema(array, optional) — typed field definitionsnameField(string | null, optional) — field used as character namethumbnailUrl(string, optional)
Returns the created template object.
GET /api/custom-sheet-templates/{id}
Fetch a single template by ID.
curl https://polyhedral.co/api/custom-sheet-templates/TEMPLATE_ID \ -H "Authorization: Bearer ph_..."
PATCH /api/custom-sheet-templates/{id}
Update one or more fields on an existing template. Only include the fields you want to change.
curl -X PATCH https://polyhedral.co/api/custom-sheet-templates/TEMPLATE_ID \
-H "Authorization: Bearer ph_..." \
-H "Content-Type: application/json" \
-d '{ "code": "<Section title=\"Stats\">...</Section>" }'DELETE /api/custom-sheet-templates/{id}
Delete a template and its thumbnail.
curl -X DELETE https://polyhedral.co/api/custom-sheet-templates/TEMPLATE_ID \ -H "Authorization: Bearer ph_..."
Returns { "success": true }.
POST /api/custom-sheet-templates/validate
Compile in-app sheet code exactly as the sheet itself compiles it, without creating or updating a template. Useful for checking code before pushing it.
curl -X POST https://polyhedral.co/api/custom-sheet-templates/validate \
-H "Authorization: Bearer ph_..." \
-H "Content-Type: application/json" \
-d '{ "code": "<Section title=\"Stats\"><Field name=\"hp\" type=\"number\" /></Section>" }'Returns { "valid": true } when the code compiles, or { "valid": false, "error": "...", "line": 1, "column": 5 } when it doesn't. The error is the compiler's message with a code frame. line counts from 1 and column from 0; both are left out when the compiler gives no position.
Example Workflows
Create a Template from a File
# Validate first
curl -X POST https://polyhedral.co/api/custom-sheet-templates/validate \
-H "Authorization: Bearer ph_..." \
-H "Content-Type: application/json" \
-d "$(jq -n --arg code "$(cat my-sheet.jsx)" '{ code: $code }')"
# Create
curl -X POST https://polyhedral.co/api/custom-sheet-templates \
-H "Authorization: Bearer ph_..." \
-H "Content-Type: application/json" \
-d "$(jq -n \
--arg name "My Custom Sheet" \
--arg code "$(cat my-sheet.jsx)" \
'{ name: $name, code: $code, buildType: "in-app" }'
)"Update Code from a Script
TEMPLATE_ID="your-template-id"
curl -X PATCH "https://polyhedral.co/api/custom-sheet-templates/$TEMPLATE_ID" \
-H "Authorization: Bearer ph_..." \
-H "Content-Type: application/json" \
-d "$(jq -n --arg code "$(cat my-sheet.jsx)" '{ code: $code }')"Preview a Template
After creating or updating a template, open it in the browser to preview:
https://polyhedral.co/home/sheets/preview/TEMPLATE_ID
Error Codes
- 400 — Missing required fields
- 401 — Missing or invalid API key
- 403 — A paid plan is required
- 429 — Builder API rate limit exceeded
- 404 — Template not found
- 500 — Server error