GitHub v3 REST API

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
http://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
http://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

Create a deployment status

Users with push access can create deployment statuses for a given deployment.

GitHub Apps require read & write access to “Deployments” and read-only access to “Repo contents” (for private repos). OAuth Apps require the repo_deployment scope.

post
http://HOSTNAME/api/v3/repos/{owner}/{repo}/deployments/{deployment_id}/statuses

Path Parameters

ownerstringrequired
repostringrequired
deployment_idintegerrequired

deployment_id parameter

Body

application/json
statestringrequired

The state of the status. Can be one of error, failure, inactive, in_progress, queued, pending, or success. Note: To use the inactive state, you must provide the application/vnd.github.ant-man-preview+json custom media type. When you set a transient deployment to inactive, the deployment will be shown as destroyed in GitHub.

Allowed values:errorfailureinactivein_progressqueuedpendingsuccess

target_urlstring

The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Note: It’s recommended to use the log_url parameter, which replaces target_url.

Default:

log_urlstring

The full URL of the deployment’s output. This parameter replaces target_url. We will continue to accept target_url to support legacy uses, but we recommend replacing target_url with log_url. Setting log_url will automatically set target_url to the same value. Default: ""
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

Default:

descriptionstring

A short description of the status. The maximum description length is 140 characters.

Default:

environmentstring

Name for the target deployment environment, which can be changed when setting a deploy status. For example, production, staging, or qa.

Allowed values:productionstagingqa

environment_urlstring

Sets the URL for accessing your environment. Default: ""
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

Default:

auto_inactiveboolean

Adds a new inactive status to all prior non-transient, non-production environment deployments with the same repository and environment name as the created status’s deployment. An inactive status is only added to deployments that had a success state. Default: true
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

Response

application/json

Response

Deployment Status

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
post/repos/{owner}/{repo}/deployments/{deployment_id}/statuses

Body

{ "environment": "production", "state": "success", "log_url": "https://example.com/deployment/42/output", "description": "Deployment finished successfully." }
 
application/json

Get a deployment status

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

get
http://HOSTNAME/api/v3/repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}

Path Parameters

ownerstringrequired
repostringrequired
deployment_idintegerrequired

deployment_id parameter

status_idintegerrequired

Response

application/json

Response

Deployment Status

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/{status_id}
 
application/json

Create a repository dispatch event

You can use this endpoint to trigger a webhook event called repository_dispatch when you want activity that happens outside of GitHub Enterprise Server to trigger a GitHub Actions workflow or GitHub App webhook. You must configure your GitHub Actions workflow or GitHub App to run when the repository_dispatch event occurs. For an example repository_dispatch webhook payload, see “RepositoryDispatchEvent.”

The client_payload parameter is available for any extra information that your workflow might need. This parameter is a JSON payload that will be passed on when the webhook event is dispatched. For example, the client_payload can include a message that a user would like to send using a GitHub Actions workflow. Or the client_payload can be used as a test to debug your workflow.

This endpoint requires write access to the repository by providing either:

This input example shows how you can use the client_payload as a test to debug your workflow.

post
http://HOSTNAME/api/v3/repos/{owner}/{repo}/dispatches

Path Parameters

ownerstringrequired
repostringrequired

Body

application/json
event_typestringrequired

A custom webhook event name.

>= 1 characters<= 100 characters

client_payloadobject

JSON payload with extra information about the webhook event that your action or worklow may use.

* Additional properties are allowed.

Response

Response

post/repos/{owner}/{repo}/dispatches

Body

{ "event_type": "on-demand-test", "client_payload": { "unit": false, "integration": true } }