# Hand the running server a renewed license key

PUT

/v1/license

```sh
curl --request PUT \
  --url https://example.com/v1/license \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "key": "example" }'
```

What the renewal hands the deployment’s running server (`kindgi license renew --runtime`), so it runs the new key without a restart. The server checks the key offline, as it does at a start: signed by a key it trusts, for the same licensee and use as the key it runs, and newer (a later `exp`, or the same `exp` and an `iat` no earlier). The same key again is taken as it is. It answers the license status with the new key. Only the deployment’s own token (`KINDGI_API_TOKEN`), or a system key holding `system:license`, hands it a key; anyone else is refused (`license-operator-only`), and the refusal recorded, before the body is read. A deployment that doesn’t take a key this way answers 404.

## Authorizations

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

## Request Bodyrequired

application/json

object

**key**

required

The whole license key, `kgi_lk_…`.

string

\>= 1 characters <= 4096 characters

##### Examplegenerated

```json
{
  "key": "example"
}
```

## Responses

### 200

The license status, with the new key.

application/json

object

**mode**

required

`development`: a runtime before 0.7.0 under `KINDGI_DEV`, which ran with no key; the key’s fields are absent, and `preview` may be present. From 0.7.0 a development runtime has a key too, and answers `licensed`.

string

Allowed values: development licensed

**name**

Whose key: the name the banner prints.

string

**use**

string

Allowed values: production non-production

**expiresAt**

string format: date-time

**startsUntil**

Until when the runtime starts with this key: `expiresAt` plus the 14-day grace.

string format: date-time

**daysLeft**

Whole days until it expires; negative once it has.

integer

**standing**

`expiring`: 30 days or fewer left. `grace`: expired, and the runtime still starts with it (for 14 days). `expired`: past the grace too: this server runs on, but won’t start with it again.

string

Allowed values: valid expiring grace expired

**renewBy**

Which way to the next key applies: `command`, a key this deployment renews itself (`kindgi license renew`); `contact`, a key Kindgi issued (write to Kindgi).

string

Allowed values: command contact

**renew**

How to get the next key, as the banner says it, with where the deployment keeps its key and renewer. Present from 30 days before the key expires, and only to the deployment’s own token.

string

**preview**

This build’s own expiry: a preview release stops starting 90 days after it was released, in every mode, unless a production key exempts it. Absent when nothing expires: a build from source, or a production key.

object

**version**

required

This build’s release, `0.1.8`.

string

**releasedAt**

required

string format: date-time

**expiresAt**

required

From then on, it no longer starts: `releasedAt` plus 90 days.

string format: date-time

**daysLeft**

required

Whole days until then; negative once it has passed.

integer

**standing**

required

`expiring`: 30 days or fewer left. `expired`: past it: this server runs on, but won’t start again; run a newer release.

string

Allowed values: valid expiring expired

**limits**

What the key limits, and how much of it is in use: set only when the key carries limits (a production key’s). A count it doesn’t name isn’t limited. Only the deployment’s own token, or a system key holding `system:license`, reads it.

object

**flows**

One count the key limits.

object

**plan**

required

The number the key carries.

integer

\>= 1

**most**

required

The most this runtime runs: past it, it refuses new ones.

integer

\>= 1

**inUse**

required

How many it counts now.

integer

**agents**

One count the key limits.

object

**plan**

required

The number the key carries.

integer

\>= 1

**most**

required

The most this runtime runs: past it, it refuses new ones.

integer

\>= 1

**inUse**

required

How many it counts now.

integer

##### Example

```json
{
  "mode": "development",
  "use": "production",
  "standing": "valid",
  "renewBy": "command",
  "preview": {
    "standing": "valid"
  }
}
```

### 400

The body isn’t `{ "key": "kgi_lk_…" }` (`bad-input`).

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

Not the deployment’s own token or a system key holding `system:license` (`license-operator-only`). On a runtime serving one tenant, a system key holding anything but `system:license` (`system-key-scope-not-served`).

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

The server checked the key and refused it (`license-key-refused`; `error.details.reason`: `malformed`, `unknown-key`, `bad-signature`, `not-yet-valid`, `expired`, `other-licensee`, `other-use` or `older`). It runs on with the key it has.

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/license`: Where the deployment's license key stands](https://docs.kindgi.com/v0.8.0/reference/api/operations/licenseget.md)
- [Kindgi 0.7.0](https://docs.kindgi.com/v0.8.0/releases/0.7.0.md)
- [Kindgi 0.8.0](https://docs.kindgi.com/v0.8.0/releases/0.8.0.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 `license-key-refused`](https://docs.kindgi.com/v0.8.0/reference/errors.md#license-key-refused)
- [Error code `license-operator-only`](https://docs.kindgi.com/v0.8.0/reference/errors.md#license-operator-only)
- [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 `system-key-scope-not-served`](https://docs.kindgi.com/v0.8.0/reference/errors.md#system-key-scope-not-served)
- [Error code `tenant-state-unavailable`](https://docs.kindgi.com/v0.8.0/reference/errors.md#tenant-state-unavailable)
- [Every error code](https://docs.kindgi.com/v0.8.0/reference/errors.md)
