# Rescore a comparison test run

POST

/v1/test-runs/{testRunId}/rescore

```sh
curl --request POST \
  --url https://example.com/v1/test-runs/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/rescore \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "projectId": "example" }'
```

Starts a new comparison test run of the same test set version, candidate and settings that replays nothing: it scores the run’s replays again, with the corrections recorded on them since (a changed answer corrected on the replay itself; `changes.new` lists the items to correct). The run rescored stays as it was; the new one names it (`comparison.rescoreOf`, `summary.rescoreOf`). A case whose replays can’t be read again keeps its scores (`rescored: false`). Needs `admin` on the run’s test set and `write` on its project.

## Authorizations

- **[bearerAuth](https://docs.kindgi.com/v0.8.0/reference/api.md#bearerauth)**

## Parameters

### Path Parameters

**testRunId**

required

string format: uuid

TestRunId — opaque branded UUID.

## Request Body

application/json

Body of `POST /v1/test-runs/{testRunId}/rescore`: optional.

object

**projectId**

The run’s project, needed only from a runtime that doesn’t record it on the run.

string

##### Examplegenerated

```json
{
  "projectId": "example"
}
```

## Responses

### 201

The rescore started.

application/json

object

**testRunId**

required

string format: uuid

**dryRunPreview**

object

**_key_**

additional properties

any

##### Examplegenerated

```json
{
  "testRunId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
  "dryRunPreview": {}
}
```

### 400

`bad-input`: `projectId` is required (this runtime doesn’t record the run’s project), or isn’t a project here. `dispatcher-input-invalid`: this runtime can’t rescore (it doesn’t read replays and their corrections again).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 401

Missing / malformed / expired / revoked bearer token.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 403

`permission-denied`: the caller may not make this change. Without an authorization store, `key-project-mismatch` (`details.keyProjectId`, `details.projectId`): the API key or session is limited to a project, and this acts in another one, the record’s or its agent’s or test set’s (with a store, that is `permission-denied`, or the record isn’t found).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 404

No test run with that id under this workspace.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 409

`test-run-not-rescorable`: only a completed comparison of a test set can be rescored.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 413

The request body is over the API’s limit (`request-too-large`; `details.maxBytes` says how much).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 429

`rate-limit-exceeded` with `details.limit: "api-requests"`, on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; `Retry-After` says when to send it again.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

### 503

The authorization store couldn’t be reached (`authz-backend-unavailable`), or the database was too busy for the authorization check (`database-busy`), so the request wasn’t run; `Retry-After` (whole seconds) says when to try again. Or `tenant-state-unavailable` (with `Retry-After`), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

## See also

- [`GET /v1/test-runs/{testRunId}`: Fetch a test run](https://docs.kindgi.com/v0.8.0/reference/api/operations/testrunsget.md)
- [`POST /v1/test-runs/{testRunId}/cancel`: Cancel a test run](https://docs.kindgi.com/v0.8.0/reference/api/operations/testrunscancel.md)
- [`GET /v1/test-runs/{testRunId}/events`: Stream test-run events (SSE)](https://docs.kindgi.com/v0.8.0/reference/api/operations/testrunsevents.md)
- [Error code `authz-backend-unavailable`](https://docs.kindgi.com/v0.8.0/reference/errors.md#authz-backend-unavailable)
- [Error code `bad-input`](https://docs.kindgi.com/v0.8.0/reference/errors.md#bad-input)
- [Error code `database-busy`](https://docs.kindgi.com/v0.8.0/reference/errors.md#database-busy)
- [Error code `dispatcher-input-invalid`](https://docs.kindgi.com/v0.8.0/reference/errors.md#dispatcher-input-invalid)
- [Error code `key-project-mismatch`](https://docs.kindgi.com/v0.8.0/reference/errors.md#key-project-mismatch)
- [Error code `permission-denied`](https://docs.kindgi.com/v0.8.0/reference/errors.md#permission-denied)
- [Error code `rate-limit-exceeded`](https://docs.kindgi.com/v0.8.0/reference/errors.md#rate-limit-exceeded)
- [Error code `request-too-large`](https://docs.kindgi.com/v0.8.0/reference/errors.md#request-too-large)
- [Error code `tenant-state-unavailable`](https://docs.kindgi.com/v0.8.0/reference/errors.md#tenant-state-unavailable)
- [Error code `test-run-not-rescorable`](https://docs.kindgi.com/v0.8.0/reference/errors.md#test-run-not-rescorable)
- [Every error code](https://docs.kindgi.com/v0.8.0/reference/errors.md)
