API Endpoint Template
A template for designing and implementing RESTful API endpoints with request/response contracts, authentication, validation, error handling, and rate limiting considerations.
Template Preview
Copy and use in your projectAPI: Implement [HTTP Method] /api/[resource]
As an API consumer, I want a well-documented endpoint for managing [resource] so that I can integrate [resource] operations into my application or automation workflow.
Description
Acceptance Criteria
Given I send a valid request with proper authentication
When the server processes the request
Then I receive a 200/201 response with the expected JSON payload and correct Content-Type headers
Given I send a request with invalid or missing required fields
When the server validates the request body using Zod
Then I receive a 400 response with a detailed validation error message indicating which fields failed
Given I send a request without authentication or with an invalid API key
When the auth middleware processes the request
Then I receive a 401 response and no data is returned or modified
Given I exceed the rate limit of 60 requests per minute
When I send an additional request
Then I receive a 429 response with a Retry-After header indicating when I can make the next request
Given the endpoint is deployed
When I check the OpenAPI specification
Then the new endpoint is documented with request/response schemas, authentication requirements, and example payloads
Import directly into Codepylot
Skip the copy-paste. Codepylot has built-in templates you can use with one click, plus AI that generates even richer stories from your ideas.
Try Codepylot Free