# Cancel Pending Migration

`DELETE /migrations/pending/{pendingId}` · Core · Storage & Schema

Cancels a queued pending migration that the calling user authored, transitioning it from `queued` to `cancelled` without executing any DDL. The row is retained permanently for audit-trail purposes.

Only the original author (the operator whose subject ID matches `queuedBy`) may cancel; any other caller receives `K9O_FORBIDDEN` (403) even if they hold a project role. Returns `data: { pendingId, status: 'cancelled' }`.

Attempting cancellation on a non-`queued` row returns `K9O_INVALID_FIELD_VALUE` (400). Emits a `migration.cancelled` audit event.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `pendingId` | path | yes | The pending migration's id (`pmig_...`). Example: `"pmig_4Fh2kQ9xLm7a"`. |
| `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 pending migration that was cancelled. |
| `data.pendingId` | string | yes | The pending migration's id (`pmig_...`). |
| `data.status` | enum ("cancelled") | yes | Always `cancelled`. |
| `meta` | object | yes | Request metadata: cost, timing and correlation ids. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 403 | `K9O_ACCESS_DENIED` | You can only cancel a pending migration you originally queued; another admin must reject it instead. |

## Code samples

### cURL

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

### fetch

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

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.migrations.deletePending('pmig_4Fh2kQ9xLm7a')
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.migrations.delete_pending("pmig_4Fh2kQ9xLm7a")
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Migrations.DeletePending(ctx, "pmig_4Fh2kQ9xLm7a")
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.migrations.delete_pending("pmig_4Fh2kQ9xLm7a").await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.migrations().deletePending("pmig_4Fh2kQ9xLm7a")
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Migrations.DeletePendingAsync("pmig_4Fh2kQ9xLm7a")
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.migrations.delete_pending("pmig_4Fh2kQ9xLm7a")
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->migrations->delete_pending('pmig_4Fh2kQ9xLm7a')
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/cancel-pending-migration
