THE REPLACEQA BLOG

API testing beyond status codes: verify data, state and permissions

Build API tests that check the returned data, persistent effects, failure behavior and access rules rather than stopping at HTTP 200.

After checking an API's status code, verify the returned data, the state change it promises, the permissions it enforces and the side effects it must avoid. A successful HTTP response can still identify the wrong record, leak another workspace's data or acknowledge a write that was never saved.

A Reddit question from someone starting API testing asks what to do beyond status codes and basic validation. Start with one operation and its business contract rather than collecting a large number of unrelated requests.

Write the operation as a state transition

For a fictional document service, a requirement might be: “A workspace editor can create a private draft, read it back and see it only within the intended workspace.” That sentence contains more testable behavior than “POST returns 201.”

LayerCheckExample defect
TransportExpected status and content typeHTML error page returned as success
StructureRequired fields and typesIdentifier changed from string to object
MeaningCorrect title, owner and workspaceResponse describes a different record
PersistenceIndependent read returns the created stateResponse generated before a failed save
PermissionsIntended roles and ownership enforcedViewer can create or read private drafts
Side effectsOnly intended records or messages createdOne request creates duplicate drafts

OpenAPI describes interfaces, including request and response structures. Schema validation is useful, but it cannot establish that a structurally valid document belongs to the correct customer. Use the schema version your tooling supports and keep semantic assertions alongside it.

Assert against controlled input

In Postman, a post-response script can check a successful create response. This illustrative snippet assumes an endpoint returning id, title and workspaceId, with an environment variable identifying an owned test workspace:

pm.test('created draft matches the requested workspace', () => {
  pm.response.to.have.status(201);
  const draft = pm.response.json();
  pm.expect(draft.id).to.be.a('string').and.not.empty;
  pm.expect(draft.title).to.eql('Release notes draft');
  pm.expect(draft.workspaceId).to.eql(pm.environment.get('testWorkspaceId'));
  pm.collectionVariables.set('createdDraftId', draft.id);
});

Configure the request body to contain that title and workspace. The Postman script documentation describes post-response tests and assertions. This example is an application-specific pattern, not a tested integration with your API. Sources were checked on November 18, 2026.

Fail setup early when the workspace variable or credentials are missing. Avoid allowing a previous run's createdDraftId to drive a later request after creation fails. Clear run-owned variables before setup and make the execution order explicit.

Read back through an independent path

Use a follow-up GET for the returned ID and assert the same agreed properties. If a create operation is asynchronous, follow its documented job or readiness mechanism rather than assuming a fixed delay.

For important writes, decide which read path establishes persistence. A cache that echoes the request may not be enough. A controlled database inspection can help diagnose a failure, but hardcoding every database detail into the public API suite makes harmless implementation changes expensive. Choose the boundary according to what the test is meant to protect.

Delete only the record this test created. A broad cleanup request can remove another test's data and cause failures that look unrelated.

Exercise rejection without accepting silent mutation

For invalid input, assert the agreed error response and confirm the prohibited state change did not occur. A 400 response followed by a newly created record is still a defect.

Include missing required input, wrong types, boundary values, unknown identifiers and unsupported operations where they matter to the contract. Test authorization with deliberately different identities rather than using an admin token everywhere.

Do not assume that every failure must use the same status. An API may intentionally return 404 instead of disclosing that a forbidden object exists. What matters is the documented contract, absence of leaked content and absence of unauthorized effects.

Add pagination and retry cases deliberately

For list endpoints, seed enough records to cross a page boundary. Verify identifiers across pages, not just the length of each page. Define ordering and what happens when data changes while the client paginates. A simple fixed dataset and a concurrent-update scenario answer different questions.

For retry behavior, determine whether the operation supports an idempotency key and its documented scope. Repeating a GET and repeating a payment-creation request are not interchangeable experiments. Test duplicate submission only in an environment with controlled downstream effects.

Keep timing assertions separate from load capacity. One response below a threshold does not show how the service behaves under sustained concurrency.

Report which layer failed

Name tests after requirements: “viewer cannot create a draft” is more informative than “POST test 7.” Retain sanitized request shape, identity role, response, record IDs and the affected build. Do not attach credentials or unrelated private payloads.

The testing strategy guide helps divide responsibilities across unit, API and user-facing checks. The uptime comparison explains why a healthy response alone cannot prove the full customer task. API tests add depth at their own boundary; they do not need to become browser tests to be useful.

Keep checking your important customer journeys.

Explore ReplaceQA ↗