---
name: api-route-validator
description: "Gives a route a pre-release contract check: a checklist covering path shape, auth, parameters, status codes, and rate limits, plus the test cases that prove each one, in a table a tester can run from. Use when an API route needs a contract check and test cases before release, covering parameters, auth, status codes, and rate limiting. Do not use for diagnosing a route that is already failing, or generating load tests and performance benchmarks. Related topics: coding, api."
---

# API Route Validator

Gives a route a pre-release contract check: a checklist covering path shape, auth, parameters, status codes, and rate limits, plus the test cases that prove each one, in a table a tester can run from.

## When to use

Use this skill when an API route needs a contract check and test cases before release, covering parameters, auth, status codes, and rate limiting. Do not use it for diagnosing a route that is already failing, or generating load tests and performance benchmarks.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Write checklist items in request-processing order (path and method, auth, parameters, status codes, rate limit), each phrased as a yes or no question.
3. Derive one test case per required parameter, per auth failure mode, per expected status code, and one for the rate limit, so every checklist item has a proving case.
4. Fill each case with an ID, the exact input (method, path, headers, body), and the expected status and body shape, so a tester can run it without interpretation.
5. Check that no two cases expect different results for the same input and that the happy path appears first.

## Inputs

- **Route path** (free text, e.g. "/users/{id}")
- **HTTP method** (choose one: GET, POST, PUT, DELETE, PATCH)
- **Required parameters** (longer free text)
- **Authentication required** (choose one: Yes, No)
- **Expected response codes** (longer free text)
- **Rate limit (requests per minute)** (number from 1 to 1000)

## Output

Two sections and nothing else: Validation Checklist as a bullet list of yes or no questions, then Sample Test Cases as a table with columns Test ID, Description, Input, Expected Output, happy path first.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### API Route Validator

Check one API route against its contract and produce the test cases that prove it.

- Route path: {{Route path}}
- HTTP method: {{HTTP method}}
- Required parameters: {{Required parameters}}
- Authentication required: {{Authentication required}}
- Expected response codes: {{Expected response codes}}
- Rate limit (requests per minute): {{Rate limit (requests per minute)}}

Build the checklist in the order a request is processed: path and method match the convention (plural nouns, no verbs, consistent casing), auth is enforced and a missing or invalid credential returns 401 before any validation, each required parameter is present with the right type and location and a missing one returns 400 with a message naming it, every listed status code is reachable and the conditions do not overlap, and the rate limit returns 429 with a Retry-After header once exceeded. Phrase each item as a yes or no question. Then write the test cases: at least one happy path, one per required parameter missing or malformed, one per auth failure mode, one per expected error code, and one that crosses the rate limit. Give each case an ID, the exact input (method, path, headers, body), and the expected status and body shape. Keep the output to the checklist and the table with no commentary around them.

## Pitfalls

- Testing only the happy path and one generic 400; a missing-parameter case per parameter is what catches the field a refactor dropped.
- Expecting 401 and 403 interchangeably; 401 is a missing or bad credential, 403 is a valid one without permission, and the route must pick one per condition.
- Writing a rate-limit case without stating the window, so the tester cannot tell whether 61 requests in a minute should fail.
