---
title: "Permanently delete all or filtered objects"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Permanently delete all or filtered objects

Path: CloudRaker Workspace API › Data Objects

`POST /spaces/{spaceId}/objects/{definitionId}/delete-matching`

Permanently deletes the objects of a definition in a space. The objects cannot be restored. The definition stays. Authorization: requires `space:contribute` on `:spaceId`. Lacking it gives **403** (no `space:read` gives 404). Body: `{ view? }`. With `view`, only the objects that match the filters of that saved view are deleted. One request deletes at most 2000 objects. Returns `{ deleted, more }`. When `more` is true, send the same request again.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`deleteMatchingObjects.path.spaceId`; string, required)
- `definitionId` (`deleteMatchingObjects.path.definitionId`; string, required)

## Request body

_Required._

- `view` (`deleteMatchingObjects.view`; string, optional) — A saved view id. Only the objects that match its filters are deleted. Without it, all the objects are deleted.
  - minLength 1

## Example request

```json
{
  "view": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/delete-matching' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "view": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/delete-matching';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({view: 'string'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/delete-matching"

payload = { "view": "string" }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The deleted count.

#### Example

```json
{
  "deleted": 0,
  "more": true
}
```

- `deleted` (`deleteMatchingObjects.response.200.deleted`; number, required) — How many objects the request deleted.
- `more` (`deleteMatchingObjects.response.200.more`; boolean, required) — True when matching objects can stay. Send the same request again.

### 403

Missing `space:contribute`.

### 404

Missing `space:read`, or an unknown `view` id.

### 422

A view filter names an unknown or archived field.


Source: https://docs.cloudraker.com/workspace/api/data-objects/delete-matching-objects/index.md
