# Delete Record

`DELETE /data/{collection}/{id}` · Core · Data, Queries & Vectors

Permanently deletes the record identified by `id` from the named collection, returning `{id}` on success.

Passing `?requireApproval=true` routes the delete through the Maker-Checker evaluation engine: if no auto-approve policy matches, the deletion is queued as a pending change and the response returns HTTP 202 with `meta.status: "pending_approval"` instead of executing immediately.

Returns `K9O_COLLECTION_NOT_FOUND` (404) if the collection does not exist and `K9O_NOT_FOUND` (404) if the record id does not exist.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `collection` | path | yes | The collection's name. Example: `"products"`. |
| `id` | path | yes | The record's id: the value of its `id` column, up to 256 characters. Example: `"prod_demo00000001"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | The record was soft-deleted: hidden from reads and purged after the collection's retention window; restorable until then. |
| `data.id` | string | yes | The deleted record's id, as given in the path. |
| `meta` | object | yes | Request metadata: cost, timing, request and trace ids. |

- **202**: Accepted

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | The write was queued for approval (HTTP 202) because a bound approval policy requires it, or `requireApproval=true` was passed. It expires after 28 days unless decided. |
| `data.id` | string | yes | The pending change's id (`apr_...`). Approve or reject it through the pending-approvals API. |
| `data.status` | enum ("pending_approval") | yes | Always `pending_approval`: nothing has been written. The write runs when the change is approved. |
| `data.collection` | string | yes | The collection the change targets. |
| `data.operation` | enum ("insert", "update", "delete") | yes | The write that was queued. |
| `data.makerId` | string | yes | Who proposed the change: the accountable originator on a delegated call, otherwise the caller (a user id, or `tok_...` for a token). |
| `data.proposedPayload` | object | yes | The request body as sent, applied when the change is approved: column name to value. Empty for a delete. |
| `data.targetRecordId` | object | yes | The record an update or delete targets; null for an insert. |
| _one of_ | | |  |
| _or_ | | |  |
| `meta` | object | yes | Request metadata (cost, timing, request and trace ids), plus `approval`. |
| `meta.approval` | object | yes | Marks the answer as queued for approval. |
| `meta.approval.status` | enum ("pending_approval") | yes |  |


## Errors

| HTTP | Code | When |
|---|---|---|
| 401 | `K9O_SESSION_EXPIRED` | Your session has expired; sign in again to delete records. |
| 401 | `K9O_INVALID_CREDENTIALS` | The credentials provided are not valid; the delete request was rejected. |
| 403 | `K9O_ACCESS_DENIED` | Your role does not permit deleting records from this collection. |
| 404 | `K9O_COLLECTION_NOT_FOUND` | The target collection does not exist in this project. |
| 409 | `K9O_STATE_CONFLICT` | The record has live dependent rows referencing it through a foreign key that is not ON DELETE CASCADE; remove the dependants or declare the foreign key ON DELETE CASCADE. |

## Code samples

### cURL

```bash
curl -X DELETE 'https://<org>.api-<region>.k9o.io/@storefront/data/products/prod_demo00000001' \
  -H 'Authorization: Bearer $K9O_TOKEN'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/data/products/prod_demo00000001', {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`
  },
});
const { data, meta } = await res.json();
```

### k9o CLI

```bash
k9o data delete <collection> <id> --data <data>
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.from('products').delete().eq('id', 'prod_demo00000001')
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.from_("products").delete().eq("id", "prod_demo00000001")
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.From("products").Delete().Eq("id", "prod_demo00000001")
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.from("products").delete().eq("id", "prod_demo00000001").await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.from("products").delete().eq("id", "prod_demo00000001")
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.From("products").DeleteAsync().Eq("id", "prod_demo00000001")
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.from("products").delete().eq("id", "prod_demo00000001")
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->from('products')->delete()->eq('id', 'prod_demo00000001')
```

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.from("products").delete().eq("id", "prod_demo00000001")
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.from("products").delete().eq("id", "prod_demo00000001")
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.from('products').delete().eq('id', 'prod_demo00000001')
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.from('products').delete().eq('id', 'prod_demo00000001')
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/delete-record
