# Retry failure bucketing

Queue failure bucketing again only after repeated runs are terminal and the previous bucketing attempt failed; raw run results remain unchanged.

## Endpoint

`POST /api/v1/workspaces/{workspace_id}/test-invocations/{invocation_id}/retry-bucketing`

## Authentication

| Class | Authentication | Minimum role | API key |
| --- | --- | --- | --- |
| customer-api | Bearer API key or dashboard session cookie; dashboard mutations also require X-CX-Request: 1. | member | Allowed |

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | path | `string` | Yes | — |
| `invocation_id` | path | `string` | Yes | — |

## Request body

This operation has no request body.

## Example

```bash
curl --request POST 'https://operade.ai/api/v1/workspaces/ws_demo/test-invocations/invo_demo/retry-bucketing' \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

## Responses

| Status | Description | Content |
| --- | --- | --- |
| 4XX | Handled client error | application/json: `ErrorResponse` |
| 202 | Successful Response | application/json: `PendingStatusResponse` |

### 4XX application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | ErrorResponse | — | No | Yes | — | — |
| `error` | `object` | ErrorItem | — | No | Yes | — | — |
| `error.code` | `string` | — | — | No | Yes | — | — |
| `error.details` | `object` | — | — | No | No | — | — |
| `error.message` | `string` | — | — | No | Yes | — | — |

### 202 application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | PendingStatusResponse | — | No | Yes | — | — |
| `status` | `string` | — | — | No | Yes | "pending" | — |

### Response example

```json
{
  "status": "pending"
}
```

## Errors

Reviewed common and route-declared errors are summarized here; the list is not exhaustive. Start with the [distributed error index](/docs/reference/api/errors) to find each code's canonical domain page.

| Status | Code | Description |
| --- | --- | --- |
| 401 | `unauthenticated` | Authentication is missing, invalid, or revoked. |
| 403 | `forbidden` | The authenticated caller does not have access to this operation. |
| 404 | `not_found` | The requested workspace resource was not found. |
| 422 | `validation_failed` | The request did not pass field or business validation. |
| 409 | `invocation_not_ready` | Wait until every run reaches a terminal state before retrying failure bucketing. |
| 409 | `bucketing_not_retryable` | Failure bucketing can be retried only after a failed bucketing attempt. |

## Related operations

- [Run agent tests](/docs/api-reference/test-invocations/create-test-invocation) — `POST /api/v1/workspaces/{workspace_id}/agents/{agent_id}/test-invocations`
- [Get a test invocation](/docs/api-reference/test-invocations/get-test-invocation) — `GET /api/v1/workspaces/{workspace_id}/test-invocations/{invocation_id}`
- [Get a test invocation run](/docs/api-reference/test-invocations/get-test-invocation-run) — `GET /api/v1/workspaces/{workspace_id}/test-invocations/{invocation_id}/runs/{run_id}`
