Prompt Library › ⚙️ Technical › Generate REST API Endpoints with AI
GPT-4o ⚙️ Technical Intermediate

Generate REST API Endpoints with AI

Describe your [RESOURCE] and get fully implemented REST endpoints in [FRAMEWORK] — with validation, error handling, and OpenAPI spec.

👁 6 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Generate REST API Endpoints with AI

You are a backend developer. Generate a complete REST API for the [RESOURCE] resource in [FRAMEWORK] using [LANGUAGE].

## Resource Definition

**Resource name:** [RESOURCE]
**Fields:** [FIELD_DEFINITIONS]
**Relationships:** [RELATIONSHIP_DESCRIPTION]
**Business rules:** [BUSINESS_RULES]

## Endpoints to Generate

- `GET /[RESOURCE_PLURAL]` — list with pagination ([PAGE_SIZE] per page) and filter by [FILTER_FIELDS]
- `GET /[RESOURCE_PLURAL]/:id` — fetch single record
- `POST /[RESOURCE_PLURAL]` — create with validation for [REQUIRED_FIELDS]
- `PUT /[RESOURCE_PLURAL]/:id` — full update
- `PATCH /[RESOURCE_PLURAL]/:id` — partial update of [PATCHABLE_FIELDS]
- `DELETE /[RESOURCE_PLURAL]/:id` — [SOFT_OR_HARD] delete

## Cross-Cutting Concerns

- Auth: require [AUTH_METHOD] on all routes except [PUBLIC_ROUTES]
- Validation: use [VALIDATION_LIBRARY] with clear error messages
- Rate limiting: [RATE_LIMIT] requests per [WINDOW] per user

## Output

Complete controller code plus an OpenAPI 3.0 spec block for each endpoint.

📝 Fill in the blanks

Replace these placeholders with your own content:

[RESOURCE]
[FRAMEWORK]
[LANGUAGE]
[FIELD_DEFINITIONS]
[RELATIONSHIP_DESCRIPTION]
[BUSINESS_RULES]
[RESOURCE_PLURAL]
[PAGE_SIZE]
[FILTER_FIELDS]
[REQUIRED_FIELDS]
[PATCHABLE_FIELDS]
[SOFT_OR_HARD]
[AUTH_METHOD]
[PUBLIC_ROUTES]
[VALIDATION_LIBRARY]
[RATE_LIMIT]
[WINDOW]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.