Web API

GET freeze status

If you want to implement a complete code freeze it may not be enough to simply stop people merging into your protected branch on Github, you may also want to block any deployments from happening in whatever software you use to push your code to production.

To achieve this we offer an endpoint for each project that provides JSON formatted data about whether there is currently a merge freeze in place or not. By querying this endpoint you can add a condition in your deployment script to only continue if your protected branch is not frozen.

Before using the endpoint you must first generate an access token. You can do this by clicking “Generate an access token” in the Deployments API panel of a protected branch. These access tokens do not expire. If you feel that your access token has been compromised and you’d like to generate another one you can simply click “Regenerate” to create a new one. Please note, however, that your old access token will cease to work from that point onwards.

The HTTP method and url to get your protected branch’s Merge Freeze data is as follows: GET https://www.mergefreeze.com/api/branches/[Github account name]/[Github repository name]/[protected branch name]/?access_token=[Access token]

The exact url for your project can be found in the "Web API" panel of your project.

The endpoint will return the following fields:

Field name

Data type

Description

branch

String

The name of the protected branch

repository

String

The full name (account + repository name) of the protected branch’s Github repository

frozen

Boolean

Whether or not there is currently a merge freeze in place

frozen_by

String or Null

The name of the person who implemented the merge freeze (may be “scheduled freeze” if a recurring freeze is responsible for the frozen state, or “slack user” if a Slack user has implemented a merge freeze but we don’t have their name). Will return null if there is no merge freeze currently in place.

For example:

{
"branch": "master",
"repository": "Team-FooBar/My-App",
"frozen": true,
"frozen_by": "John Wick"
}

POST freeze status

In certain situations you may also want to programmatically freeze or unfreeze a branch. This can be done via the following endpoint:POST https://www.mergefreeze.com/api/branches/[Github account name]/[Github repository name]/[protected branch name]/?access_token=[Access token]

You must also send the following parameters either by including them as json in the body of the request or as form data:

Param name

Data type

Description

frozen

Boolean

true if you want the project to be frozen.

false if you'd like the project to be unfrozen.

user_name

String

The name of the person implementing the change.

The exact url for your project and an example using curl can be found in the "Web API" panel of your project.

This endpoint will return the same fields as the "GET freeze status" endpoint above.

Errors/warnings

If a required parameter is missing or invalid you will receive an HTTP 400 status with a json payload containing an error field describing the error.

If you attempt to freeze a project that is already frozen (or unfreeze an unfrozen project) the change will not take place but you will still receive an HTTP 200 status, although you will receive a warning field in the response describing the warning in addition to the normal fields returned in a successful response.

Allow deployments but block merging

If you’d like to perform a deployment while still keeping a merge freeze in place you can click the “Allow deployments” button. This button only shows up if your branch is currently frozen and you have created an access token for the Web API (an indication that you may be using it).

Clicking this button will change the Web API response’s frozen field to false but the merge freeze will stay on in all other places, so your team members will not be able to merge into the protected branch.

This can be undone by clicking the “Undo” link.