# Check a deploy's blocks against what runs

POST

/v1/deployments/check

```sh
curl --request POST \
  --url https://example.com/v1/deployments/check \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "agents": [ "example" ], "flows": [ "example" ], "blocks": [ { "id": "example", "version": "example" } ], "replace": [ { "blockId": "example", "reason": "example" } ] }'
```

What `POST /v1/deployments` answers about the pack’s data blocks against what runs, with nothing written: `kindgi deploy` asks it before it builds the image. For each block, the newest version that runs in a project of one of `agents` (a project’s own version, or a segment pin inside one; every project, whoever asks) is compared with the body’s: a newer one stops the deploy unless `replace` names the block. Equal passes, a newer one in the files passes, and a block that runs nowhere passes. Then, on a runtime with plan limits, `agents` and `flows` are counted as the deploy would count them, in `projectId` or else the default project: past the most the license key runs, it’s refused as the deploy would be (`plan-limit-reached`); at its plan or past it, the answer has `planWarning`. It takes the deploy’s own right: admin on `projectId`, else on the workspace.

## Authorizations

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

## Request Bodyrequired

application/json

object

**projectId**

The project the deploy goes into: the check takes the deploy’s own right, admin on it. Absent: the workspace’s default project, admin on the workspace. Every project of the pack’s agents counts, whichever this is.

string format: uuid

**agents**

required

The pack’s agents, by id: the image index’s.

Array\<string>

<= 500 items

**flows**

The pack’s flows, by id: the image index’s. With `agents`, what the plan limits count; absent: no flows.

Array\<string>

<= 500 items

**blocks**

required

The pack’s blocks, each at its version in the files; a block named once.

Array\<object>

<= 500 items

object

**id**

required

string

\>= 1 characters

**version**

required

string

**replace**

As the deploy’s `replace`: a block named once.

Array\<object>

object

**blockId**

required

string

\>= 1 characters

**reason**

required

Why the older version goes back: 1 to 500 characters, no control characters.

string

\>= 1 characters <= 500 characters

##### Examplegenerated

```json
{
  "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
  "agents": [
    "example"
  ],
  "flows": [
    "example"
  ],
  "blocks": [
    {
      "id": "example",
      "version": "example"
    }
  ],
  "replace": [
    {
      "blockId": "example",
      "reason": "example"
    }
  ]
}
```

## Responses

### 200

The deploy can go: the blocks it puts back on purpose, and the ones `replace` names that need none.

application/json

object

**replaced**

required

The blocks `replace` names that a newer version runs for: the deploy puts each back, and records it.

Array\<object>

object

**blockId**

required

string

**from**

required

The newest version that runs now.

string

**to**

required

The files’ version.

string

**notNeeded**

required

The blocks `replace` names that nothing newer runs for: nothing to replace.

Array\<string>

**planWarning**

The plan limits’ counts that are at their plan or past it, with this write: flows and agents in production, against the license key’s plan or the workspace’s own limit. Past `most`, new ones are refused (`plan-limit-reached`); what runs keeps running.

object

\>= 1 properties

**flows**

object

**plan**

required

The plan’s number: the license key’s, or the workspace’s own limit (`TenantLimits`).

integer

**most**

required

The most it runs: its plan and a margin. A write past this is refused.

integer

**inUse**

required

How many run in production, with this write.

integer

**agents**

object

**plan**

required

The plan’s number: the license key’s, or the workspace’s own limit (`TenantLimits`).

integer

**most**

required

The most it runs: its plan and a margin. A write past this is refused.

integer

**inUse**

required

How many run in production, with this write.

integer

##### Examplegenerated

```json
{
  "replaced": [
    {
      "blockId": "example",
      "from": "example",
      "to": "example"
    }
  ],
  "notNeeded": [
    "example"
  ],
  "planWarning": {
    "flows": {
      "plan": 1,
      "most": 1,
      "inUse": 1
    },
    "agents": {
      "plan": 1,
      "most": 1,
      "inUse": 1
    }
  }
}
```

### 400

`bad-input`: a body that isn’t `{ projectId?, agents, flows?, blocks, replace? }`, a block named twice, a version that isn’t one, or a `replace` reason that isn’t 1 to 500 characters with no control characters (`details.issues`).

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

No admin on `projectId` (`forbidden`), or a key limited to another project; without it, no admin on the workspace. Or, as `POST /v1/deployments` answers it, `plan-limit-reached`: this adds flows or agents to production past the most this runtime’s license key runs, so none of them is added; what runs keeps running. `details` has `projectId` (on a reinstate, when its version records one); `over`, each count over (flows first) with its `limit` (`flows` or `agents`), the number it adds (`adding`), and the key’s `plan`, `most` and `inUse` when they count this workspace alone; the first of them again at the top (`details.limit`, …); `newIds`, the `flows` and `agents` it adds; and `next`, where a larger plan is, when the runtime names one. Without an authorization store, `key-project-mismatch` (`details.keyProjectId`): the API key or session is limited to a project, and this writes above it, to the workspace, an org or a team (with a store, that is `permission-denied`).

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

`deploy-would-put-back-older-blocks`, as `POST /v1/deployments` answers it: each block in `details.blocks` (`DeployCheckStop`).

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.

### 501

`runs-in-unsupported`: this runtime doesn’t read the agents’ pins and Latest, or the agent versions that pin each block, so it can’t check; its deploys aren’t checked either.

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"
  }
}
```

### 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

- [Plan limits](https://docs.kindgi.com/v0.8.1/deploy/self-hosted/plan-limits.md)
- [Ship a pack from CI](https://docs.kindgi.com/v0.8.1/deploy/ship-from-ci.md)
- [Kindgi 0.4.0](https://docs.kindgi.com/v0.8.1/releases/0.4.0.md)
- [Error code `authz-backend-unavailable`](https://docs.kindgi.com/v0.8.1/reference/errors.md#authz-backend-unavailable)
- [Error code `bad-input`](https://docs.kindgi.com/v0.8.1/reference/errors.md#bad-input)
- [Error code `database-busy`](https://docs.kindgi.com/v0.8.1/reference/errors.md#database-busy)
- [Error code `deploy-would-put-back-older-blocks`](https://docs.kindgi.com/v0.8.1/reference/errors.md#deploy-would-put-back-older-blocks)
- [Error code `key-project-mismatch`](https://docs.kindgi.com/v0.8.1/reference/errors.md#key-project-mismatch)
- [Error code `permission-denied`](https://docs.kindgi.com/v0.8.1/reference/errors.md#permission-denied)
- [Error code `plan-limit-reached`](https://docs.kindgi.com/v0.8.1/reference/errors.md#plan-limit-reached)
- [Error code `rate-limit-exceeded`](https://docs.kindgi.com/v0.8.1/reference/errors.md#rate-limit-exceeded)
- [Error code `request-too-large`](https://docs.kindgi.com/v0.8.1/reference/errors.md#request-too-large)
- [Error code `runs-in-unsupported`](https://docs.kindgi.com/v0.8.1/reference/errors.md#runs-in-unsupported)
- [Error code `tenant-state-unavailable`](https://docs.kindgi.com/v0.8.1/reference/errors.md#tenant-state-unavailable)
- [Every error code](https://docs.kindgi.com/v0.8.1/reference/errors.md)
