Scale · API · intermediate

Create REST API Endpoints for Your App

API SaaS intermediate LovableReplitCursor

How to use

  1. Copy the prompt below
  2. Paste it into Lovable, Replit, Cursor
  3. Review the output and follow up with refinements
Prompt
Build a set of REST API endpoints so external services and scripts can interact with this app's project data. Implement five endpoints: GET /api/projects (returns a JSON array of all projects belonging to the authenticated user), POST /api/projects (creates a new project from the request body, returns the created object with 201 status), GET /api/projects/:id (returns a single project or 404 if not found), PUT /api/projects/:id (updates the specified project's fields from the request body), and DELETE /api/projects/:id (deletes the project and returns 204). Authenticate all requests by reading an Authorization: Bearer [key] header and looking up the key in an api_keys table that links to a user_id. If the key is missing or invalid, return 401. If the user tries to access another user's project, return 403. Return consistent JSON error objects in the format { error: "message" } for all error responses.

Related prompts

Was this helpful?