# Queue Migration

`POST /migrations/queue` · Core · Storage & Schema

Proposes one or more migration files for admin approval by inserting them into the pending-migration queue with status `queued`. The body accepts an array of migration payloads; each queued row carries a SHA-256 checksum of the migration content, ensuring byte-identical execution at apply time. Emits a `migration.queued` audit event covering all rows in the batch. Returns `data: PendingMigration[]` for the queued rows. Requires `PROJECT_ADMIN`.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `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` | array of object | yes | One entry per submitted migration, in the order submitted. |
| `data.[]id` | string | yes | The pending migration's id (`pmig_...`). |
| `data.[]version` | integer | yes | The migration's version, an integer from 1 to 2147483647. Versions apply in ascending order. |
| `data.[]slug` | string | yes | The migration's slug, as given when it was submitted. |
| `data.[]status` | enum ("queued", "pending_approval") | yes | `queued`: a project admin can apply it. `pending_approval`: it touches a protected collection (or loosens a collection's gate scope), and applies only when a different project admin grants the linked approval. |
| `data.[]approvalId` | object | yes | The linked approval (`apr_...`) when the migration is governed by one; otherwise null. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.[]affectedCollections` | array of string | yes | The collections the migration's operations and policy section touch. |
| `meta` | object | yes | Request metadata: cost, timing and correlation ids. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 400 | `K9O_INVALID_FIELD_VALUE` | The request body is not a JSON object with a migrations array; fix the request and retry. |
| 403 | `K9O_ACCESS_DENIED` | Queuing migrations requires the PROJECT_ADMIN role. |

## Code samples

### cURL

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

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/migrations/queue', {
  method: 'POST',
  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.queue()
```

### k9o

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

### sdk-go

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

### k9o

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

### dev.k9o:core

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

### K9o.Core

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

### k9o

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

### k9o/sdk

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


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