---
title: "Create an availability rule for a package"
method: POST
path: "/shop/packages/{packageId}/availability-rules"
tags: ["Packages"]
---

# Create an availability rule for a package

`POST /shop/packages/{packageId}/availability-rules`

Adds a new `AvailabilityRule` to a `Package`. With
`is_available: true` the rule opens new bookable windows; with
`is_available: false` it blocks them. Any `false` rule overrides
any `true` rule for the same period. Omitting date/time/weekday
filters means the rule applies always.

`date_from` defaults to today in the package's timezone when
omitted. Requires the `SETTINGS_MANAGE` permission on the package's
site.

## Request body

- object
  - `is_available` boolean, required — When true, this rule opens bookable windows for the package. When false, it closes them. Any `false` rule overrides any `true` rule for the same time period.
  - `date_from` string, date, nullable — First date this rule applies (inclusive). Defaults to today in the package's timezone when omitted.
  - `date_to` string, date, nullable — Last date this rule applies (inclusive). When omitted, the rule has no end date.
  - `time_from` string, nullable — Start of the daily time window in 24-hour `HH:MM` format.
  - `time_to` string, nullable — End of the daily time window in 24-hour `HH:MM` format.
  - `min_duration` integer, nullable — Match the rule only when the package's total duration is ≥ this many minutes. Omit to apply to any duration.
  - `max_duration` integer, nullable — Match the rule only when the package's total duration is ≤ this many minutes.
  - `weekdays` string[] — Days of the week the rule applies on. Empty / omitted means every day.

## Response `201`

A single `AvailabilityRule` belonging to a `Package`.

- object
  - `data` AvailabilityRule, required
    - `id` string, object-id, required — The ID of the availability rule.
    - `date_from` string, date, required — The start of the rule period.
    - `date_to` string, date, required — The end of the rule period.
    - `is_available` boolean, required — Whether the resource is available during this period. Any `false` rules will override `true` rules.
    - `max_duration` integer — Maximum number of minutes.
    - `min_duration` integer — Minimum number of minutes.
    - `time_from` string, required — The daily start time of the time period, in 24 hour format.
    - `time_to` string, required — The daily end time of the time period, in 24 hour format.
    - `weekdays` string[] — The weekdays this rule applies to.

## Other responses

- `401` — The user is unauthenticated
- `403` — The authenticated user does not have permission.
- `404` — The resource couldn't be found
- `422` — The request didn't pass validation

---

[API](https://skmtc.dev/try/apis/trybe-api.md) · [All operations](https://skmtc.dev/try/apis/trybe-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/try/trybe-api/revisions/f37f92702da5/schema)
