Back to guide/General Productivity

REST API Endpoint

Defines every route, validation rule, and response format so Bolt builds a complete CRUD API. The 'do not modify' boundary prevents unintended side effects.

bolt-ai-promptsresource_namerequired_fields
Edit View
Prompt
Add a RESTful API endpoint for {{resource_name}}.\n\nRoutes:\n- GET /api/{{resource_name}} — list all with pagination (page, limit query params)\n- GET /api/{{resource_name}}/:id — get single by ID\n- POST /api/{{resource_name}} — create new (validate required fields: {{required_fields}})\n- PUT /api/{{resource_name}}/:id — update existing\n- DELETE /api/{{resource_name}}/:id — soft delete (set deleted_at timestamp)\n\nInclude:\n- Input validation with descriptive error messages\n- Try/catch with proper HTTP status codes (400, 404, 500)\n- Response format: { success: boolean, data: T, error?: string }\n\nDo not modify any existing routes or the frontend.

Variables to customize

{{resource_name}}{{required_fields}}

Why this prompt works

Defines every route, validation rule, and response format so Bolt builds a complete CRUD API. The 'do not modify' boundary prevents unintended side effects.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.