Prompt Library ⚙️ Technical Design a REST API from Requirements
GPT-4o ⚙️ Technical Advanced

Design a REST API from Requirements

Design a complete, production-grade REST API from business requirements — including endpoints, schemas, authentication, and error responses.

👁 5 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Design a REST API from Requirements

You are a senior API architect designing a production-grade REST API for [PRODUCT_NAME].

## Requirements

Product domain: [PRODUCT_DOMAIN]
Primary consumers: [API_CONSUMERS] (web app, mobile, third-party)
Scale requirements: [EXPECTED_REQUESTS_PER_DAY]
Authentication method: [AUTH_METHOD]

Core use cases to support:
1. [USE_CASE_1]
2. [USE_CASE_2]
3. [USE_CASE_3]

## API Design

**Base URL structure:**
`/api/v1/[RESOURCE]`

For each core resource, define:

**Endpoints:**
- Method + path + purpose
- Required vs. optional query parameters
- Request body schema (JSON)
- Success response schema
- Error response codes and meanings

**Resource: [RESOURCE_1]**
[Define all CRUD + business logic endpoints]

**Resource: [RESOURCE_2]**
[Same structure]

## Authentication and Authorization

Design the auth flow for [AUTH_METHOD]:
- Token format and lifetime
- Which endpoints require auth
- Role-based access control if needed for [PRODUCT_DOMAIN]

## Error Handling Standard

Define the standard error response format and the full set of error codes for [PRODUCT_NAME]'s API.

## Versioning Strategy

Define how [PRODUCT_NAME] will handle API versioning and breaking changes.

## OpenAPI Spec Stub

Write a minimal OpenAPI 3.0 spec stub for the most important endpoint.

📝 Fill in the blanks

Replace these placeholders with your own content:

[PRODUCT_NAME]
[PRODUCT_DOMAIN]
[API_CONSUMERS]
[EXPECTED_REQUESTS_PER_DAY]
[AUTH_METHOD]
[USE_CASE_1]
[USE_CASE_2]
[USE_CASE_3]
[RESOURCE]
[RESOURCE_1]
[Define all CRUD + business logic endpoints]
[RESOURCE_2]
[Same structure]

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.