Policies
Brown Out Policy
The brownout policy allows performing scheduled downtime on your API. This can be useful for helping notify clients of an impending deprecation or for scheduling maintenance.
This policy uses cron schedules to check if a request
should experience a brownout or not. When a request falls into a scheduled
brownout an error response will be return. The error response can be customized
by setting the problem
properties.
For more information using brownouts to alert clients on impending API changes/deprecations see our blog post How to version an API
Configuration
The configuration shows how to configure the policy in the 'policies.json' document.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
cronSchedule
<string | string[]> (Required) -The cron schedule for when this policy is enabled. This can be a single cron string or an array of multiple cron strings.problem
<object> -The problem that is returned in the response body when this policy is enabled.type
<string> -The type of problem.title
<string> -The title of problem.detail
<string> -The detail of problem.status
<number> -Http status code of the problem.
Using the Policy
Cron Schedules#
This policy accepts a single cron schedule or an array of cron schedules. Any time a requests falls withing that schedule the brownout response will be set.
Example schedules could be:
Every Day between 2am and 3am
Every Hour on the hour, and the 15th, 30th, and 45th minutes
This can also be written as:
Cron Expression Format#
This policy uses the linux cron syntax with the addition that you can optionally specify seconds by prepending the minute field with another field.
All linux cron features are supported, including
- lists
- ranges
- ranges in lists
- step values
- month names (jan,feb,... - case insensitive)
- weekday names (mon,tue,... - case insensitive)
- time nicknames (@yearly, @annually, @monthly, @weekly, @daily, @hourly - case insensitive)
To test out cron patterns try using a tool like crontab.guru.
Read more about how policies work