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

# Merge Queue API

> API reference for merge queue management

The Merge Queue API provides programmatic access to wit's merge queue for controlled PR merging.

## Endpoints

### Add to Queue

Add a PR to the merge queue.

```typescript theme={null}
const result = await client.mergeQueue.addToQueue.mutate({
  prId: 'pr_123',
  priority: 50, // 0-100
});
```

### Remove from Queue

Remove a PR from the queue.

```typescript theme={null}
await client.mergeQueue.removeFromQueue.mutate({
  prId: 'pr_123',
});
```

### Get Queue Position

Get a PR's position in the queue.

```typescript theme={null}
const position = await client.mergeQueue.getQueuePosition.query({
  prId: 'pr_123',
});

// Response
{
  inQueue: true,
  position: 3,
  totalInQueue: 10,
  estimatedWaitMinutes: 15
}
```

### List Queue

List all PRs in the queue.

```typescript theme={null}
const entries = await client.mergeQueue.listQueue.query({
  repoId: 'repo_123',
  targetBranch: 'main',
  includeCompleted: false,
});
```

### Get Statistics

Get queue statistics.

```typescript theme={null}
const stats = await client.mergeQueue.getStats.query({
  repoId: 'repo_123',
  targetBranch: 'main',
});

// Response
{
  pending: 5,
  processing: 1,
  completedToday: 12,
  failedToday: 2,
  avgMergeTimeMinutes: 8
}
```

### Get/Update Config

```typescript theme={null}
// Get config
const config = await client.mergeQueue.getConfig.query({
  repoId: 'repo_123',
  targetBranch: 'main',
});

// Update config
await client.mergeQueue.updateConfig.mutate({
  repoId: 'repo_123',
  targetBranch: 'main',
  enabled: true,
  strategy: 'adaptive',
  maxBatchSize: 5,
});
```

## Queue Entry Schema

```typescript theme={null}
interface MergeQueueEntry {
  id: string;
  prId: string;
  pr: { number: number; title: string };
  position: number;
  priority: number;
  state: 'pending' | 'testing' | 'ready' | 'merging' | 'completed' | 'failed';
  errorMessage?: string;
  addedAt: string;
  updatedAt: string;
}
```

## Related

* [Merge Queue](/features/merge-queue) - CLI documentation
