GitHub v3 REST API

List deployments

Simple filtering of deployments is available via query parameters:

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/deployments

Query Parameters

shastring

The SHA recorded at creation time.

Default:none

refstring

The name of the ref. This can be a branch, tag, or SHA.

Default:none

taskstring

The name of the task for the deployment (e.g., deploy or deploy:migrations).

Default:none

environmentstring | null

The name of the environment that was deployed to (e.g., staging or production).

Default:none

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Path Parameters

ownerstringrequired
repostringrequired

Response

200 application/json

Response

A request for a specific ref(branch,sha,tag) to be deployed

urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/1

idintegerrequired

Unique identifier of the deployment

Example:42

node_idstringrequired

Example:MDEwOkRlcGxveW1lbnQx

shastringrequired

Example:a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d

refstringrequired

The ref to deploy. This can be a branch, tag, or sha.

Example:topic-branch

taskstringrequired

Parameter to specify a task to execute

Example:deploy

payloadOne Of
required
Variant 1object
* Additional properties are allowed.
original_environmentstring

Example:staging

environmentstringrequired

Name for the target deployment environment.

Example:production

descriptionstring | nullrequired

Example:Deploy request from hubot

creatorobject | nullrequired

Simple User

Show Child Parameters
created_atstring(date-time)required

Example:2012-07-20T01:19:13Z

updated_atstring(date-time)required

Example:2012-07-20T01:19:13Z

statuses_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/1/statuses

repository_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example

transient_environmentboolean

Specifies if the given environment is will no longer exist at some point in the future. Default: false.

Example:true

production_environmentboolean

Specifies if the given environment is one that end-users directly interact with. Default: false.

Example:true

performed_via_github_appobject | null

GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub.

Show Child Parameters
get/repos/{owner}/{repo}/deployments
 
200 application/json

Create a deployment

Deployments offer a few configurable parameters with certain defaults.

The ref parameter can be any named branch, tag, or SHA. At GitHub Enterprise Server we often deploy branches and verify them
before we merge a pull request.

The environment parameter allows deployments to be issued to different runtime environments. Teams often have
multiple environments for verifying their applications, such as production, staging, and qa. This parameter
makes it easier to track which environments have requested deployments. The default environment is production.

The auto_merge parameter is used to ensure that the requested ref is not behind the repository’s default branch. If
the ref is behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds,
the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will
return a failure response.

By default, commit statuses for every submitted context must be in a success
state. The required_contexts parameter allows you to specify a subset of contexts that must be success, or to
specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do
not require any contexts or create any commit statuses, the deployment will always succeed.

The payload parameter is available for any extra information that a deployment system might need. It is a JSON text
field that will be passed on when a deployment event is dispatched.

The task parameter is used by the deployment system to allow different execution paths. In the web world this might
be deploy:migrations to run schema changes on the system. In the compiled world this could be a flag to compile an
application with debugging enabled.

Users with repo or repo_deployment scopes can create a deployment for a given ref.

Merged branch response

You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating
a deployment. This auto-merge happens when:

  • Auto-merge option is enabled in the repository
  • Topic branch does not include the latest changes on the base branch, which is master in the response example
  • There are no merge conflicts

If there are no new commits in the base branch, a new request to create a deployment should give a successful
response.

Merge conflict response

This error happens when the auto_merge option is enabled and when the default branch (in this case master), can’t
be merged into the branch that’s being deployed (in this case topic-branch), due to merge conflicts.

Failed commit status checks

This error happens when the required_contexts parameter indicates that one or more contexts need to have a success
status for the commit to be deployed, but one or more of the required contexts do not have a state of success.

post
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/deployments

Path Parameters

ownerstringrequired
repostringrequired

Body

application/json
refstringrequired

The ref to deploy. This can be a branch, tag, or SHA.

taskstring

Specifies a task to execute (e.g., deploy or deploy:migrations).

Default:deploy

auto_mergeboolean

Attempts to automatically merge the default branch into the requested ref, if it’s behind the default branch.

Default:true

required_contextsarray[string]

The status contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts.

payloadOne Of
Variant 1object
* Additional properties are allowed.
environmentstring

Name for the target deployment environment (e.g., production, staging, qa).

Default:production

descriptionstring | null

Short description of the deployment.

Default:

transient_environmentboolean

Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: false
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

Default:false

production_environmentboolean

Specifies if the given environment is one that end-users directly interact with. Default: true when environment is production and false otherwise.
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

Response

application/json

Response

Deployment

A request for a specific ref(branch,sha,tag) to be deployed

urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/1

idintegerrequired

Unique identifier of the deployment

Example:42

node_idstringrequired

Example:MDEwOkRlcGxveW1lbnQx

shastringrequired

Example:a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d

refstringrequired

The ref to deploy. This can be a branch, tag, or sha.

Example:topic-branch

taskstringrequired

Parameter to specify a task to execute

Example:deploy

payloadOne Of
required
Variant 1object
* Additional properties are allowed.
original_environmentstring

Example:staging

environmentstringrequired

Name for the target deployment environment.

Example:production

descriptionstring | nullrequired

Example:Deploy request from hubot

creatorobject | nullrequired

Simple User

Show Child Parameters
created_atstring(date-time)required

Example:2012-07-20T01:19:13Z

updated_atstring(date-time)required

Example:2012-07-20T01:19:13Z

statuses_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/1/statuses

repository_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example

transient_environmentboolean

Specifies if the given environment is will no longer exist at some point in the future. Default: false.

Example:true

production_environmentboolean

Specifies if the given environment is one that end-users directly interact with. Default: false.

Example:true

performed_via_github_appobject | null

GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub.

Show Child Parameters
post/repos/{owner}/{repo}/deployments

Body

{ "ref": "topic-branch", "payload": "{ \"deploy\": \"migrate\" }", "description": "Deploy request from hubot" }
 
application/json

Get a deployment

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/deployments/{deployment_id}

Path Parameters

ownerstringrequired
repostringrequired
deployment_idintegerrequired

deployment_id parameter

Response

application/json

Response

Deployment

A request for a specific ref(branch,sha,tag) to be deployed

urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/1

idintegerrequired

Unique identifier of the deployment

Example:42

node_idstringrequired

Example:MDEwOkRlcGxveW1lbnQx

shastringrequired

Example:a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d

refstringrequired

The ref to deploy. This can be a branch, tag, or sha.

Example:topic-branch

taskstringrequired

Parameter to specify a task to execute

Example:deploy

payloadOne Of
required
Variant 1object
* Additional properties are allowed.
original_environmentstring

Example:staging

environmentstringrequired

Name for the target deployment environment.

Example:production

descriptionstring | nullrequired

Example:Deploy request from hubot

creatorobject | nullrequired

Simple User

Show Child Parameters
created_atstring(date-time)required

Example:2012-07-20T01:19:13Z

updated_atstring(date-time)required

Example:2012-07-20T01:19:13Z

statuses_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/1/statuses

repository_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example

transient_environmentboolean

Specifies if the given environment is will no longer exist at some point in the future. Default: false.

Example:true

production_environmentboolean

Specifies if the given environment is one that end-users directly interact with. Default: false.

Example:true

performed_via_github_appobject | null

GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub.

Show Child Parameters
get/repos/{owner}/{repo}/deployments/{deployment_id}
 
application/json

Delete a deployment

If the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment. Anyone with repo or repo_deployment scopes can delete a deployment.

To set a deployment as inactive, you must:

  • Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment.
  • Mark the active deployment as inactive by adding any non-successful deployment status.

For more information, see “Create a deployment” and “Create a deployment status.”

delete
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/deployments/{deployment_id}

Path Parameters

ownerstringrequired
repostringrequired
deployment_idintegerrequired

deployment_id parameter

Response

Response

delete/repos/{owner}/{repo}/deployments/{deployment_id}
 

List deployment statuses

Users with pull access can view deployment statuses for a deployment:

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/deployments/{deployment_id}/statuses

Query Parameters

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Path Parameters

ownerstringrequired
repostringrequired
deployment_idintegerrequired

deployment_id parameter

Response

application/json

Response

The status of a deployment.

urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/42/statuses/1

idintegerrequired

Example:1

node_idstringrequired

Example:MDE2OkRlcGxveW1lbnRTdGF0dXMx

statestringrequired

The state of the status.

Allowed values:errorfailureinactivependingsuccessqueuedin_progress

Example:success

creatorobject | nullrequired

Simple User

Show Child Parameters
descriptionstringrequired

A short description of the status.

Default:

<= 140 characters

Example:Deployment finished successfully.

environmentstring

The environment of the deployment that the status is for.

Default:

Example:production

target_urlstring(uri)required

Deprecated: the URL to associate with this status.

Default:

Example:https://example.com/deployment/42/output

created_atstring(date-time)required

Example:2012-07-20T01:19:13Z

updated_atstring(date-time)required

Example:2012-07-20T01:19:13Z

deployment_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example/deployments/42

repository_urlstring(uri)required

Example:https://api.github.com/repos/octocat/example

environment_urlstring(uri)

The URL for accessing your environment.

Default:

Example:https://staging.example.com/

log_urlstring(uri)

The URL to associate with this status.

Default:

Example:https://example.com/deployment/42/output

performed_via_github_appobject | null

GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub.

Show Child Parameters
get/repos/{owner}/{repo}/deployments/{deployment_id}/statuses
 
application/json