Test soft delete: 404, 410 Gone and records that should stay hidden
Soft delete sets a deletedAt column instead of removing the row. It makes undo and audits easy, and it adds a rule every query has to follow: "and not deleted". Each query that forgets it is a bug, and the API surface is where you find them.
404 or 410?
Both are fine for a deleted record:
404 Not Foundsays nothing about whether it ever existed. Good when existence itself is private.410 Gonesays it existed and was removed on purpose. Useful for public resources and caches.
Pick one and test it, so it doesn't change between releases:
// "Read customer (after delete)"
pm.test('deleted customer is gone', () => pm.response.to.have.status(410));The folder
📂 Customer soft delete
POST Create customer
GET Count customers (before)
DELETE Delete customer
GET Read customer (after delete)
GET List customers (after delete)
GET Search customers (after delete)
GET Count customers (after delete)
POST Create customer with the same emailCreate customer stores the id and email:
const c = pm.response.json();
pm.environment.set('customerId', c.id);
pm.environment.set('customerEmail', c.email);with a body that uses {{$randomEmail}}, so every run starts clean.
Count customers (before) stores the total:
pm.environment.set('countBefore', String(pm.response.json().total));Lists, searches and counts
// "List customers (after delete)"
pm.test('deleted customer is not listed', () => {
const ids = pm.response.json().data.map((c) => c.id);
pm.expect(ids).to.not.include(pm.environment.get('customerId'));
});// "Search customers (after delete)", GET {{baseUrl}}/customers?q={{customerEmail}}
pm.test('deleted customer is not found by search', () => {
pm.expect(pm.response.json().data).to.have.lengthOf(0);
});// "Count customers (after delete)"
pm.test('count went down by one', () => {
pm.expect(pm.response.json().total).to.equal(Number(pm.environment.get('countBefore')) - 1);
});The count check assumes nobody else creates customers in the same workspace during the run. On a shared staging environment, filter the count by a tag only your test data has.
Search is the one that fails most often: search indexes are updated by a separate job, and the delete handler doesn't always tell it.
Unique values
A soft-deleted customer still holds its email in the table. Creating a new customer with the same email shows how the unique index was built:
// "Create customer with the same email"
pm.test('email can be reused after delete', () => pm.response.to.have.status(201));If your product says the opposite (an email can never be reused), assert 409 instead. What matters is that the answer is decided, not an accidental 500 from a unique constraint violation.
Related endpoints
Deleted records leak sideways. Check the endpoints that join to the deleted one:
GET /orders?customerId={{customerId}}: are the orders hidden, kept, or reassigned?- An export or report endpoint: is the customer in the CSV?
GET /customers/{{customerId}}/addresses: does it404like the parent?
Restore
If there's an undelete:
POST {{baseUrl}}/customers/{{customerId}}/restoreThen read it and check it's back with its fields, and listed and searchable again. A restore that brings the row back but not the search entry is the mirror image of the delete bug.
Hard delete and retention
If deleted records are purged after a retention period, you can't wait 30 days in a test. Ask for an admin endpoint or a test-only setting that runs the purge now, and test that the purge removes related data too.