---
updatedAt: 2026-05-06T16:56:50.000Z
agentTools:
  projectIndex: https://docs.onsched.com/llms.txt
---

# Replace unavailability blocks

Set multiple unavailability blocks. Replaces all existing blocks for the specified resources,
locations, or services.


# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Onsched API",
    "version": "3.25.0"
  },
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://api-stage.onsched.com/v3/oauth/token",
            "scopes": {
              "read": "Read access to the API. Write also satisfies GET.",
              "write": "Write access to the API (POST, PUT, PATCH, DELETE). Also satisfies GET."
            }
          }
        }
      },
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "x-readme": {
          "name": "apiKey"
        }
      },
      "clientIdAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-client-id",
        "x-readme": {
          "name": "apiKey"
        }
      }
    },
    "schemas": {
      "SetUnavailabilityBlocks": {
        "type": "object",
        "properties": {
          "LocationId": {
            "type": "string",
            "format": "uuid",
            "description": "Optional location identifier"
          },
          "ResourceId": {
            "type": "string",
            "format": "uuid",
            "description": "Optional resource identifier"
          },
          "ServiceId": {
            "type": "string",
            "format": "uuid",
            "description": "Optional service identifier"
          },
          "blocks": {
            "type": "array",
            "description": "Array of unavailability blocks",
            "items": {
              "type": "object",
              "properties": {
                "startTime": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2024-03-20T10:00:00Z"
                },
                "endTime": {
                  "type": "string",
                  "format": "date-time",
                  "example": "2024-03-20T11:00:00Z"
                },
                "reason": {
                  "type": "string",
                  "example": "Maintenance"
                }
              },
              "required": [
                "startTime",
                "endTime"
              ]
            }
          }
        },
        "description": "At least one of LocationId, ResourceId, or ServiceId must be provided"
      },
      "Unavailability": {
        "type": "object",
        "description": "Persisted unavailability block row returned by create/set endpoints and embedded on appointments.\n",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "CompanyId": {
            "type": "string",
            "format": "uuid"
          },
          "LocationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "ResourceId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "ServiceId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "AppointmentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "format": "date-time"
          },
          "endTime": {
            "type": "string",
            "format": "date-time"
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "reasonType": {
            "type": "string",
            "nullable": true
          },
          "externalId": {
            "type": "string",
            "nullable": true
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    },
    {
      "bearerAuth": [],
      "apiKeyAuth": [],
      "clientIdAuth": []
    }
  ],
  "servers": [
    {
      "url": "https://api-stage.onsched.com",
      "description": "Stage server"
    }
  ],
  "x-readme": {
    "oauth-options": {
      "useInsecureClientAuthentication": true
    }
  },
  "paths": {
    "/v3/unavailability/setUnavailabilityBlocks": {
      "post": {
        "summary": "Replace unavailability blocks",
        "tags": [
          "Unavailability"
        ],
        "security": [
          {
            "oauth2": []
          },
          {
            "bearerAuth": [],
            "apiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetUnavailabilityBlocks"
              }
            }
          }
        },
        "description": "Set multiple unavailability blocks. Replaces all existing blocks for the specified resources,\nlocations, or services.\n",
        "responses": {
          "201": {
            "description": "Unavailability blocks set successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Unavailability"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body."
          }
        }
      }
    }
  }
}
```