# Add an opening-hours or closure rule

`POST /bookings/rules` · Rivier · bookings

Add an opening-hours or closure rule.

- Scope: bookings:admin
- Sdk: bookings.rule.create
- Cli: bookings rule create

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "scopeKind": {
      "type": "string",
      "enum": [
        "location",
        "resource",
        "service"
      ]
    },
    "scopeId": {
      "type": "string",
      "format": "uuid"
    },
    "kind": {
      "type": "string",
      "enum": [
        "open",
        "closed"
      ]
    },
    "weekdays": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 7
      },
      "minItems": 1,
      "maxItems": 7
    },
    "onDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "start": {
      "type": "string",
      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
    },
    "end": {
      "type": "string",
      "pattern": "^(([01]\\d|2[0-3]):[0-5]\\d|24:00)$"
    },
    "validFrom": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "validTo": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "note": {
      "type": "string",
      "maxLength": 200,
      "default": ""
    }
  },
  "required": [
    "scopeKind",
    "scopeId",
    "kind"
  ],
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/bookings/rules' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "scopeKind": "location",
  "scopeId": "string",
  "kind": "open"
}'
```
