*REST API › Endpoint reference › Catalog & inventory › Availability*

# Correct or close an unavailability

> With `action: "edit"` it corrects the dates or the type; with `action: "finish_now"` it closes it at this instant, which is the "came back early" case.

`expectedUpdatedAt` is the optimistic lock: copy it from the read and, if someone touched it in the meantime, the request is rejected with 409 `conflict` and nothing is written; read it again and retry. `edit` only applies to a manual unavailability that has not started yet: one created by a task or by a schedule is changed from its source, and one already started can only be closed; both respond 409. Its new start has to be later than now and its end after its start (400 `validation_error` with `errors[0].path` on the field, as with an `absenceType` of another resource type), and on a space the new window cannot fall on its bookings (409). `finish_now` only closes an unavailability in progress —`unavailable`, already started and not yet ended—, also one that comes from a schedule; any other responds 409, and so does one created by a task. `warningCount` is always 0 here: overlapping commitments are counted when the unavailability is declared. On a space it responds 503 `service_unavailable` while space unavailabilities are switched off for the account.

`PATCH /api/v1/availability/unavailabilities/{unavailabilityId}` — scope `availability:write`

Scope: `availability:write` · 120/min · Idempotency-Key · MCP: `filmo_unavailabilities_update`

## Authorizations

Bearer API key with the scope below. `availability:write`

## Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | string | No | Unique identifier of the request, chosen by the client (a UUID works). Between 1 and 255 characters: an empty header is rejected with 400 `validation_error`, because the client would believe itself protected. Repeating the same key with the SAME body within 24 h returns the stored response without executing again, with the `Idempotent-Replay: true` header. With a DIFFERENT body it returns 422. It is the safe way to retry after a network timeout. |

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `unavailabilityId` | string | Yes | Unavailability identifier. |

## Body

Body schema: `UnavailabilityUpdateBody`

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | string | Yes | "edit" corrects the unavailability; "finish_now" closes it right now. `edit`, `finish_now` |
| `expectedUpdatedAt` | string<date-time> | Yes | Last modification date you read. If it does not match, the request is rejected. |
| `startDate` | string<date-time> | No | New start. |
| `endDate` | string<date-time> | No | New end. |
| `absenceType` | string | No | New absence type; null clears it. `vacation`, `sick`, `personal`, `training`, `maintenance`, `inspection`, `repair`, `reserved`, `academic`, `event`, `closure`, `other` |
| `reason` | string | No | New reason; null clears it. Not returned by the API. |

## Request examples

*Correct or close an unavailability*

**cURL**

```bash
curl https://app.filmo.io/api/v1/availability/unavailabilities/unav_8f2a1c \
  --request PATCH \
  --header "Authorization: Bearer $FILMO_API_KEY" \
  --header "Idempotency-Key: $(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)" \
  --header 'Content-Type: application/json' \
  --data '{
  "action": "finish_now",
  "expectedUpdatedAt": "2026-07-20T10:12:31+02:00"
}'
```

**Node.js**

```javascript
fetch('https://app.filmo.io/api/v1/availability/unavailabilities/unav_8f2a1c', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer YOUR_FILMO_API_KEY',
    'Idempotency-Key': crypto.randomUUID(),
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    action: 'finish_now',
    expectedUpdatedAt: '2026-07-20T10:12:31+02:00'
  })
})
```

**Python**

```python
import uuid
import requests

requests.patch(
    "https://app.filmo.io/api/v1/availability/unavailabilities/unav_8f2a1c",
    headers={
      "Authorization": "Bearer YOUR_FILMO_API_KEY",
      "Idempotency-Key": str(uuid.uuid4()),
      "Content-Type": "application/json"
    },
    json={
      "action": "finish_now",
      "expectedUpdatedAt": "2026-07-20T10:12:31+02:00"
    }
)
```

## Response

Response schema: `UnavailabilityResultDto`

| Status | Description |
| --- | --- |
| 200 | Successful response. |
| 400 | Invalid request (validation_error): malformed query or body. `errors[]` lists every offending field with its stable code. |
| 401 | Authentication failed (unauthorized, api_key_invalid, api_key_revoked, api_key_expired, api_key_owner_inactive, api_key_owner_not_admin). |
| 403 | Not allowed (insufficient_scope: the API key does not have the required scope, named in `requiredScope`; forbidden: the owner of the key lacks the permission the operation requires). `insufficient_scope` is answered before the request counts against the rate limit, so it carries no `RateLimit-*` headers; `forbidden` does. |
| 404 | Resource not found (not_found): it does not exist or is outside the scope of the API key. |
| 409 | Conflict (conflict): the current state of the resource prevents the operation, a request with that Idempotency-Key is already in progress, or another conditional write (`If-Match`) held the resource for more than five seconds. `errors[0].code` says which: `in_progress` and `lock_timeout` are solved by retrying; `invalid_state` is not, because the state of the resource forbids the operation. |
| 422 | Idempotency-Key reused (idempotency_key_reused): the same key was used before with a different body. Change the key. |
| 429 | Rate limit exceeded (rate_limited): retry after `Retry-After` seconds; `RateLimit-*` says which quota ran out. |
| 500 | Internal error (internal_error). |
| 503 | Service unavailable (service_unavailable): the feature this operation writes to is switched off for the account. The request is correct; it works again once the feature is switched on. |

**200**

| Name | Type | Description |
| --- | --- | --- |
| `data` | object | Result of declaring or updating an unavailability. |
| `data.availability` | object | The unavailability as it now stands. |
| `data.availability.id` | string | Unique identifier of the unavailability. |
| `data.availability.resourceType` | string | Which resource: staff, vehicle or space. |
| `data.availability.resourceId` | string | Identifier of that resource. |
| `data.availability.resourceName` | string | Resource name; null if not recorded. |
| `data.availability.startDate` | string<date-time> | Start of the unavailability in ISO 8601 UTC. |
| `data.availability.endDate` | string<date-time> | End of the unavailability in ISO 8601 UTC. |
| `data.availability.state` | string | Declared state. This list only returns `unavailable` windows that have not ended yet, so it is always `unavailable` here; `available` and `unknown` exist as declarations but are not listed. |
| `data.availability.absenceType` | string | Absence type. Only emitted for vehicles and spaces, where it is operational; for staff it is health data and is returned as null. |
| `data.availability.updatedAt` | string<date-time> | Last modification in ISO 8601 UTC; null if not recorded. |
| `data.warningCount` | integer | Commitments of the resource that overlap this unavailability. |
| `meta` | object | Additional information about the response. |
| `meta.warnings` | object[] | Lifecycle warnings; present only when the operation is deprecated. |
| `meta.warnings.code` | string | Stable warning code. `deprecated` |
| `meta.warnings.message` | string | For people: what is deprecated, until when, and what to use. |
| `meta.warnings.sunset` | string | Day (YYYY-MM-DD) the operation stops being served. |
| `meta.warnings.replacement` | string | `operationId` of the operation to use instead, or null if there is none. |
| `meta.warnings.link` | string | Where the deprecation is documented (the changelog). |

*Example response · 200*

```json
{
  "data": {
    "availability": {
      "id": "availability_9f3a2b",
      "resourceType": "Example resource type",
      "resourceId": "resource_9f3a2b",
      "resourceName": "Example resource name",
      "startDate": "2026-09-01T08:00:00.000Z",
      "endDate": "2026-09-01T08:00:00.000Z",
      "state": "Madrid",
      "absenceType": "Example absence type",
      "updatedAt": "2026-09-01T08:00:00.000Z"
    },
    "warningCount": 1
  }
}
```

## Errors

| Status | Codes | Meaning |
| --- | --- | --- |
| 400 | `validation_error` | Malformed query or body. `errors[]` lists every offending field with its stable code. |
| 404 | `not_found` | It does not exist or is outside the scope of the API key. |
| 409 | `conflict` | The current state of the resource prevents the operation, a request with that Idempotency-Key is already in progress, or another conditional write (`If-Match`) held the resource for more than five seconds. `errors[0].code` says which: `in_progress` and `lock_timeout` are solved by retrying; `invalid_state` is not, because the state of the resource forbids the operation. |
| 422 | `idempotency_key_reused` | The same key was used before with a different body. Change the key. |
| 503 | `service_unavailable` | The feature this operation writes to is switched off for the account. The request is correct; it works again once the feature is switched on. |

## Deprecation

This operation is not deprecated. Deprecations are announced with a Deprecation header and a sunset date.

---

Canonical URL: https://docs.filmo.io/rest-api/endpoint-reference/availability/correct-or-close-an-unavailability  
Last updated: 2026-10-25