Testing a REST API endpoint means sending a real request to it and checking that the response is what the contract says it should be. You confirm four things: the status code, the response body and its data types, the headers (especially content type and caching), and the behaviour under bad input. This guide covers the manual and automated ways to do it with free tools, so you can start with a single endpoint and scale to a repeatable test suite.
What You'll Need
- The endpoint URL and HTTP method (GET, POST, PUT, PATCH, DELETE).
- The API's documentation, OpenAPI/Swagger file or Postman collection if one exists.
- Valid credentials: an API key, bearer token, basic auth or session cookie. Know where the token goes (header, query string or body).
- A tool: a REST client such as Postman, Insomnia or the VS Code REST Client extension, or the command-line tool curl.
- Example payloads for requests that accept a body, plus a JSON viewer or formatter.
- For automated testing: a language runtime such as Node.js or Python and a test library (Jest, Pytest, SuperTest, RestAssured and similar) if you plan to run tests on every build.
Step-by-Step
- Read the contract first. Find the method, path, required headers, path and query parameters, request body schema, and the documented success and error responses. If there is an OpenAPI spec, import it into your client so the fields are pre-filled. Testing an endpoint without knowing its intended behaviour only proves it responds, not that it is correct.
- Pick one happy path. Choose the simplest valid request: one resource by a known ID for a GET, or a minimal valid body for a POST. Record the exact request so you can repeat it.
- Send the request and capture the baseline. Check the status code first (200 or 201 for a created resource, 204 for a delete with no body), then the body, then the headers. Save the response as your baseline. Note the time and date because live data changes.
- Validate the body properly. Check that field names and nesting match the documentation, that numbers are numbers and not strings, that dates are in the expected format, and that nullable fields behave as documented. Empty arrays and
nullare different results and both need checking. Limit how much you verify against live data that other people or jobs can change. - Test the authentication layer. Repeat the same request with no token, an expired token, a token for a lower-privilege user, and a malformed token. Expect 401 for missing or invalid credentials and 403 for valid credentials without permission. A 200 where you expected 403 is a serious finding, not a quirk.
- Test input validation. Send a missing required field, a wrong type, an out-of-range value, an overlong string, an unexpected extra field, and malformed JSON. Expect 400 or 422 with an error message that identifies the problem without exposing stack traces or internal paths. Check that the server rejects rather than silently coercing bad input.
- Test boundaries and not-found cases. Request an ID that does not exist (expect 404), a deleted resource, an empty result set (usually 200 with an empty array, not 404), the first and last items of any paginated list, and the limits of page size and offsets. Try negative and very large values for numeric parameters.
- Test methods and error paths. Confirm unsupported methods return 405, that PUT replaces the whole resource while PATCH updates fields, and that deletes are idempotent or clearly documented otherwise. Check what happens on a second delete.
- Check idempotency and side effects. On requests that create records, resend the same request and confirm it does not duplicate data, or that the documented idempotency key prevents it. For state-changing calls, verify the database or a follow-up GET reflects the change exactly once.
- Check headers and performance basics. Verify
Content-Typematches what is actually returned, look for pagination and rate-limit headers, and note response times for a typical request. If the API supports CORS for browser clients, confirm the expected origins are allowed and preflight requests succeed. - Test concurrency and load at a small scale. Send several identical update requests at once and see whether the result is consistent. Only run load tests against environments you own or have permission to test, and start small so you do not affect other users.
- Turn the manual checks into automated tests. In your client, add assertions on status code, response schema and key field values, then save the request in a collection and run the collection. In code, write one test per behaviour: success, unauthorised, invalid input, not found. Use a fresh test fixture or seeded data rather than production records.
- Run against multiple environments. Point the same collection or test suite at development, staging and production using environment variables for base URL and credentials. Never store real production secrets in a shared collection; use environment variables and secret storage.
- Add contract checks and CI. If an OpenAPI spec exists, validate responses against it so schema drift is caught. Run the suite on every pull request or deployment, and treat authentication and validation failures as blocking.
Common Mistakes
- Testing only the happy path. Most real bugs sit in error handling, permissions, and empty or missing data.
- Asserting on exact values from live data, so tests break whenever someone edits a record. Assert on structure and stable fixtures instead.
- Hardcoding tokens and base URLs in requests, so the suite breaks on rotation or environment changes.
- Ignoring status codes and only eyeballing the body. A 200 with an error message inside is still a design problem worth flagging.
- Sending a body with GET or failing to set
Content-Type: application/json, then blaming the API when validation fails. - Running destructive tests (delete, bulk update) against production data.
- Skipping negative auth tests, which leaves broken access control undiscovered.
- Assuming a 500 means the API is down when it often means malformed input or a missing optional fixture.
Tips
- Keep one collection of reusable requests with a shared environment for base URL and token.
- Use variables for IDs captured from a create request, so the read and delete tests use the resource they just made.
- Store the request body and expected response in files for anything large or frequently reused.
- Test error messages for usefulness: a good API tells you which field failed and why.
- Check the API's own documentation for sandbox or demo environments so your tests do not touch real data.
- Record the API version you tested; behaviour can change between versions.
Troubleshooting
If the request fails before it reaches the API, check the URL for typos, a missing scheme, an extra slash or the wrong port, and confirm your network or proxy allows the call. A 401 usually means a missing, expired or malformed token, so regenerate it and confirm the header format. A 403 means the credentials work but the role lacks permission, which needs a policy check rather than a new token. A 404 can be a bad path or a resource that does not exist; compare the route with the documentation character by character. A 400 or 422 means the server rejected your input, so read the error body and fix the field it names. A 415 points at the content type, so set the JSON header. A 429 means you hit a rate limit, so slow the test down and check the rate-limit headers. A 500 suggests a server-side bug or bad data in your request; retry once with the simplest valid payload to see whether it is input-related. If responses differ between tools, compare headers, redirects and any hidden defaults such as automatic cookie handling. If a test passes locally but fails in CI, check the environment variables, base URL and whether the fixtures were seeded.
Frequently Asked Questions
What is the difference between API testing and endpoint testing?
Endpoint testing checks one request and response pair, while API testing covers the whole service: multiple endpoints, workflows, authentication, performance and integrations. Endpoint tests are the building blocks.
Do I need to write code to test an endpoint?
No. A REST client such as Postman, Insomnia or curl plus the API documentation is enough for manual checks. Code becomes useful once you want the same checks to run automatically on every change.
Which status codes should I always test?
At minimum: success (200/201/204), unauthorised (401), forbidden (403), not found (404), method not allowed (405), validation failure (400/422), rate limit (429) and server error (500) if you can trigger it safely.
How do I test endpoints that need a login token?
Get a token from the auth endpoint, store it as an environment variable, and reference it in the Authorization header. Test with no token, an expired token and a lower-privilege token as separate cases.
Is it safe to test against production?
Only read-only requests, and only with permission. Create, update and delete calls belong in a staging or test environment seeded with disposable data.
What should I check in the response body?
Field names, data types, nesting, required and nullable values, date formats, pagination metadata, and that error responses explain the problem without leaking internal details such as stack traces or server paths.