DELETE method
The HTTP DELETE method removes content. With a selector range unit it removes one element and all its descendants; without a selector it removes the whole document.
When to reach for it
Use DELETE to remove a fragment from a document, or the whole document. The server returns 204 No Content — for a selector-scoped delete, with a Content-Range header identifying the removed element. A selector-scoped delete sends no ETag, because the element no longer exists and the response never carries the whole document's ETag.
All DELETE requests are subject to authorization.
Examples
Remove an element
Remove the last paragraph from a document:
DELETE /delete-remove-test.html
Range: selector=p:last-child
HTTP/1.1 204
Verify the removal
Reading the document back confirms the element is gone:
GET /delete-verify-test.html
HTTP/1.1 200
<!DOCTYPE html>
<html><body>
<h1>Title</h1>
<p>Keep this paragraph.</p>
</body></html>
Delete a whole document
A DELETE with no selector removes the entire document:
DELETE /delete-whole-doc-test.html
HTTP 204
An element deny does not stop a whole-document DELETE. The page-wide rules alone decide it.
A later GET for that path returns 404 Not Found.
Concurrency
A whole-document DELETE can be made conditional with If-Match, exactly as
for PUT: send the ETag you
last read, and the delete only succeeds if the document is still at that
version when the delete commits. If another client changed the document in
the meantime, the DELETE is rejected with 412 Precondition Failed (with
the current ETag in the response) instead of removing a version you never
saw. The single-tag, list, and * forms of If-Match all work as they do
for PUT.
A change that lands in the instant between that check and the commit
conflicts with the delete instead. The delete then answers 409 Conflict with
a WriteContention document and removes nothing. If the change was to the
document itself, sending the same If-Match again gets the 412. If it was a
page that refers to the document, the document did not change and sending it
again succeeds.
A selector-scoped If-Match can also fail for a second reason. If the version
you quoted is still current but the ETag does not name the element as it is
stored, the 412 body carries a problem item of type
https://pagelove.org/Problem/RepresentationMismatch. Re-reading will not
help. See PUT for the full
explanation, including which pages can and cannot be written back through.
Error cases
| Condition | Status |
|---|---|
| Document does not exist | 404 Not Found |
| Selector matches no element | 416 Range Not Satisfiable |
| Authorization denied | 403 Forbidden |
A Range header with more than one selector= |
400 Bad Request |
| Schema validation fails | 422 Unprocessable Entity |
If-Match ETag no longer current (document changed concurrently) |
412 Precondition Failed |
| A concurrent write conflicts with the delete as it commits, for example a referring page saved meanwhile | 409 Conflict with a WriteContention document; send it again |
| A delete of one page keeps the database's transaction open for more than 5 seconds while it checks restrict or cascade rules | 504 Gateway Timeout |
| The checks of a restrict or cascade rule go over the limit for searching the site | 503 Service Unavailable with a BudgetLimit document |
| Host has transition rules and the page changed while the write was being checked | 409 Conflict |
The two checks that can time out or go over the limit are described in Property.
On a host with transition rules, every DELETE the rules check is pinned to the version of the page the server read, whether or not it touches a watched item. If the page changed in between, you get 409 Conflict with a WriteContention error and nothing is deleted. This includes a DELETE of a page that does not exist: if another client creates the page in between, the DELETE is refused and the new page stays. Before trying again, re-read and review the current target and decide whether that content should still be deleted. A new attempt is checked against the current page; that check does not establish consent to delete a page another client created or changed. A stored file that is not a page holds nothing for the rules, so deleting one is never refused by them. A DELETE of a directory is not checked or pinned. See TransitionConstraint for the writes the rules do not check.
For an ordinary DELETE, retain the intended resource/selector and original validator while resolving a refusal or uncertain outcome. To protect reviewed content, use a supported concrete strong If-Match for that target (see Concurrency); If-Match: * checks existence, not the reviewed version. If the reply is lost, treat the outcome as Unknown and inspect current state through a permitted read before deciding on another request. Current absence does not identify which request removed the content. Avoid automatic repeats, and reconcile independently persisted trigger effects separately.
Absence and denial are distinct. A selector that matches no element gets
416, and one you are not permitted to write gets401/403— the two are never confused. Where the edge cannot see your target it re-checks against the live document before answering, so a416means the element really was absent at that moment. Two cases still refuse rather than reporting416: a target that exists but is covered by a rule denying it, which is a genuine authorization answer rather than an absence; and a target you would not be permitted to read, since "there is nothing there" is itself information about the page. If you can write to part of a page you cannot read, writes refuse identically whether the target exists or not.
See also
- Modeling data — schema validators that check content values on write
- Shape Constraints — validate document structure on write