Skip to main content

DELETE /api/data/:collectionName/:id

Permanently removes the document with the given ID from the collection. This operation 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

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. Users can only delete their own documents — attempting to delete another user’s document returns 403.

Response Fields

success
boolean
true when the document was deleted.
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, message } = await res.json();

Success Response

{
  "success": true,
  "data": {},
  "message": "Document deleted successfully"
}

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