Idempotency
// Definition
A property of an operation where calling it once and calling it many times produce the same effect. Critical for safe retries — GET, PUT, and DELETE are idempotent in HTTP semantics; POST is not. Tests should verify duplicate requests don't double-charge, double-create, or double-send.
// Code Example
it('PUT is idempotent — same payload twice yields one resource', () => {
const body = { id: 'abc', name: 'Cypress' };
cy.request('PUT', '/api/tools/abc', body).its('status').should('eq', 200);
cy.request('PUT', '/api/tools/abc', body).its('status').should('eq', 200);
cy.request('/api/tools').then((res) => {
expect(res.body.filter((t: { id: string }) => t.id === 'abc')).to.have.length(1);
});
});// Related terms
REST
Representational State Transfer — an architectural style for HTTP APIs where resources are addressed by URLs and manipulated via standard HTTP verbs (GET, POST, PUT, DELETE). The dominant API style for over a decade.
Endpoint
A specific URL exposed by an API that accepts requests and returns responses. Defined by its path, HTTP method, and contract.
Status Code
A three-digit HTTP response code indicating outcome — 2xx success, 3xx redirect, 4xx client error, 5xx server error. The first signal an API test asserts on.
Learn more · API Testing Masterclass
Chapter 4 · Lesson 4: Rate Limiting and Retry Strategies