2020-07-28 23:09:34 +05:30
---
2023-06-20 00:43:36 +05:30
stage: Deploy
group: Environments
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-07-28 23:09:34 +05:30
type: concepts, howto
---
2021-11-11 11:23:49 +05:30
# Freeze Periods API **(FREE)**
2020-05-24 23:13:21 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29382) in GitLab 13.0.
2021-02-22 17:27:13 +05:30
You can use the Freeze Periods API to manipulate GitLab [Freeze Period ](../user/project/releases/index.md#prevent-unintentional-releases-by-setting-a-deploy-freeze ) entries.
2020-05-24 23:13:21 +05:30
## Permissions and security
2023-04-23 21:23:45 +05:30
Users with Reporter [permissions ](../user/permissions.md ) or greater can read
Freeze Period API endpoints. Only users with the Maintainer role can modify
Freeze Periods.
2020-05-24 23:13:21 +05:30
2023-01-13 00:05:48 +05:30
## List freeze periods
2020-05-24 23:13:21 +05:30
2023-01-13 00:05:48 +05:30
Paginated list of freeze periods, sorted by `created_at` in ascending order.
2020-05-24 23:13:21 +05:30
```plaintext
GET /projects/:id/freeze_periods
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | ----------------------------------------------------------------------------------- |
2023-04-23 21:23:45 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2020-05-24 23:13:21 +05:30
Example request:
```shell
2020-11-24 15:15:51 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/19/freeze_periods"
2020-05-24 23:13:21 +05:30
```
Example response:
```json
[
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 8 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:06:41.566Z"
}
]
```
2023-01-13 00:05:48 +05:30
## Get a freeze period by a `freeze_period_id`
2020-05-24 23:13:21 +05:30
2023-01-13 00:05:48 +05:30
Get a freeze period for the given `freeze_period_id` .
2020-05-24 23:13:21 +05:30
```plaintext
GET /projects/:id/freeze_periods/:freeze_period_id
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | ----------------------------------------------------------------------------------- |
2023-04-23 21:23:45 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2023-01-13 00:05:48 +05:30
| `freeze_period_id` | integer | yes | The ID of the freeze period. |
2020-05-24 23:13:21 +05:30
Example request:
```shell
2020-11-24 15:15:51 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1"
2020-05-24 23:13:21 +05:30
```
Example response:
```json
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 8 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:06:41.566Z"
}
```
2023-01-13 00:05:48 +05:30
## Create a freeze period
2020-05-24 23:13:21 +05:30
2023-01-13 00:05:48 +05:30
Create a freeze period.
2020-05-24 23:13:21 +05:30
```plaintext
POST /projects/:id/freeze_periods
```
| Attribute | Type | Required | Description |
| -------------------| --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
2023-04-23 21:23:45 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2023-01-13 00:05:48 +05:30
| `freeze_start` | string | yes | Start of the freeze period in [cron ](https://crontab.guru/ ) format. |
| `freeze_end` | string | yes | End of the freeze period in [cron ](https://crontab.guru/ ) format. |
2021-11-18 22:05:49 +05:30
| `cron_timezone` | string | no | The time zone for the cron fields, defaults to UTC if not provided. |
2020-05-24 23:13:21 +05:30
Example request:
```shell
2020-11-24 15:15:51 +05:30
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: < your_access_token > " \
2020-05-24 23:13:21 +05:30
--data '{ "freeze_start": "0 23 * * 5", "freeze_end": "0 7 * * 1", "cron_timezone": "UTC" }' \
2021-02-22 17:27:13 +05:30
--request POST "https://gitlab.example.com/api/v4/projects/19/freeze_periods"
2020-05-24 23:13:21 +05:30
```
Example response:
```json
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 7 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:03:35.702Z"
}
```
2023-01-13 00:05:48 +05:30
## Update a freeze period
2020-05-24 23:13:21 +05:30
2023-01-13 00:05:48 +05:30
Update a freeze period for the given `freeze_period_id` .
2020-05-24 23:13:21 +05:30
```plaintext
2021-10-27 15:23:28 +05:30
PUT /projects/:id/freeze_periods/:freeze_period_id
2020-05-24 23:13:21 +05:30
```
| Attribute | Type | Required | Description |
| ------------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
2023-04-23 21:23:45 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2023-01-13 00:05:48 +05:30
| `freeze_period_id` | integer | yes | The ID of the freeze period. |
| `freeze_start` | string | no | Start of the freeze period in [cron ](https://crontab.guru/ ) format. |
| `freeze_end` | string | no | End of the freeze period in [cron ](https://crontab.guru/ ) format. |
2021-11-18 22:05:49 +05:30
| `cron_timezone` | string | no | The time zone for the cron fields. |
2020-05-24 23:13:21 +05:30
Example request:
```shell
2020-11-24 15:15:51 +05:30
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: < your_access_token > " \
2020-05-24 23:13:21 +05:30
--data '{ "freeze_end": "0 8 * * 1" }' \
2021-02-22 17:27:13 +05:30
--request PUT "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1"
2020-05-24 23:13:21 +05:30
```
Example response:
```json
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 8 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:06:41.566Z"
}
```
2023-01-13 00:05:48 +05:30
## Delete a freeze period
2020-05-24 23:13:21 +05:30
2023-01-13 00:05:48 +05:30
Delete a freeze period for the given `freeze_period_id` .
2020-05-24 23:13:21 +05:30
```plaintext
DELETE /projects/:id/freeze_periods/:freeze_period_id
```
| Attribute | Type | Required | Description |
| ------------- | -------------- | -------- | ----------------------------------------------------------------------------------- |
2023-04-23 21:23:45 +05:30
| `id` | integer or string | yes | The ID or [URL-encoded path of the project ](rest/index.md#namespaced-path-encoding ). |
2023-01-13 00:05:48 +05:30
| `freeze_period_id` | integer | yes | The ID of the freeze period. |
2020-05-24 23:13:21 +05:30
Example request:
```shell
2020-11-24 15:15:51 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1"
2020-05-24 23:13:21 +05:30
```