# Lock a period

Source: https://amanucci.com/fr/docs/developers/api/ledger/lockPeriod

## POST /v1/entities/{entityId}/periods/{periodId}/lock

Lock a period

Close and lock a period: the four close checks (every posted entry balances; the 55x bank shelf equals the latest verified statement up to the period's end; no live unposted proposal; no live review case for the period), their record, the status change, its history row and the balance SNAPSHOT, in ONE transaction. Any red check refuses the lock with 409 `close_checks_red` naming each one in `checks` — and nothing is written; a signed `lockPeriodWithOverride` may argue them. The snapshot is written inside the lock because a locked period takes no new entries, so staleness is impossible by construction. A period that cannot make this move answers 409 `invalid_transition`; no step-up is required, because §0's signed-act list is closed and does not name a green lock.

Operation ID: `lockPeriod`

### Parameters

```json
[
  {
    "schema": {
      "type": "string",
      "format": "uuid"
    },
    "required": true,
    "name": "entityId",
    "in": "path"
  },
  {
    "schema": {
      "type": "string",
      "format": "uuid"
    },
    "required": true,
    "name": "periodId",
    "in": "path"
  }
]
```

### Request body

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/PeriodAct"
      }
    }
  }
}
```

### Responses

#### 200 The period is closed and locked.

```json
{
  "application/json": {
    "schema": {
      "$ref": "#/components/schemas/PeriodLockResult"
    }
  }
}
```

#### 401 Dead or absent credential (`unauthenticated`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 403 Authenticated, present, and refused: a missing grant, a missing seat, or a missing step-up.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 404 Absent, or hidden from this asker — the two are indistinguishable (`not-found`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 409 The world is not in the state the request assumed: a stale `expectedSeq`, or a transition already made.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 422 The request did not satisfy the schema (`invalid-input`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 429 Too many requests on this door's bucket (`rate-limited`); refused before any handler ran, `Retry-After` says when to come back.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 503 Temporarily unavailable; `Retry-After` says when to come back.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```
