Skip to main content

DELETE /api/data/:collectionName/:id

Moves the document with the given ID to the trash by setting isDeleted: true and recording the deletedAt timestamp. The document remains recoverable for a 30-day grace period, after which it is permanently deleted by a background cleanup worker. See the Database Guide for more details. Pass permanent=true to skip the trash and remove the document immediately. Permanent deletion cannot be undone.

Required header

x-api-key: sk_live_… by default. pk_live_… is accepted only when the collection has RLS enabled and the request includes Authorization: Bearer <accessToken>.

Path parameters

string
required
The name of the collection containing the document.
string
required
The MongoDB ObjectId string of the document to delete.

Query parameters

boolean
default:"false"
When true, deletes the document immediately instead of moving it to the trash. The document cannot be recovered, and its size is subtracted from your databaseUsed quota right away. When omitted or false, the document is soft deleted and quota is only reclaimed after the 30-day cleanup.

RLS ownership check

When using pk_live with RLS enabled, urBackend compares the existing document’s owner field against the authenticated user’s ID. You can only delete your own documents; attempting to delete another user’s document returns 403.

Response fields

boolean
true when the document was moved to trash.
object
Object containing the id of the deleted document.
string
Human-readable confirmation message. "Document moved to trash" for soft deletes, "Document permanently deleted" when permanent=true.

Code examples

Success response

With permanent=true, the message is "Document permanently deleted" instead.

Errors