Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ub.bitbros.in/llms.txt

Use this file to discover all available pages before exploring further.

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.

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

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

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

success
boolean
true when the document was moved to trash.
data
object
Object containing the id of the deleted document.
message
string
Human-readable confirmation message.

Code examples

const docId = '64fd1234abcd5678ef901234';

const res = await fetch(
  `https://api.ub.bitbros.in/api/data/posts/${docId}`,
  {
    method: 'DELETE',
    headers: {
      'x-api-key': 'sk_live_YOUR_SECRET_KEY'
    }
  }
);

const { success, data, message } = await res.json();

Success response

{
  "success": true,
  "data": {
    "id": "64fd1234abcd5678ef901234"
  },
  "message": "Document moved to trash"
}

Errors

StatusCause
401 UnauthorizedMissing/invalid API key, or missing Bearer token on an RLS-enabled collection
403 Forbiddenpk_live without RLS, or the authenticated user doesn’t own the document
404 Not FoundNo document with that ID exists in the collection