Skip to main content

We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the new Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API pages.

Deployment Statuses

List deployment statuses

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

get /repos/{owner}/{repo}/deployments/{deployment_id}/statuses

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
deployment_idintegerpath

deployment_id parameter

per_pageintegerquery

Results per page (max 100)

Default: 30

pageintegerquery

Page number of the results to fetch.

Default: 1

Code samples

Example

Shell
curl \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses
JavaScript @octokit/core.js
await octokit.request('GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses', { owner: 'OWNER', repo: 'REPO', deployment_id: 'DEPLOYMENT_ID' })
GitHub CLI gh api
gh api \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses

Response

Status: 200
[ { "url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1", "id": 1, "node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx", "state": "success", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "description": "Deployment finished successfully.", "environment": "production", "target_url": "https://example.com/deployment/42/output", "created_at": "2012-07-20T01:19:13Z", "updated_at": "2012-07-20T01:19:13Z", "deployment_url": "https://api.github.com/repos/octocat/example/deployments/42", "repository_url": "https://api.github.com/repos/octocat/example", "environment_url": "https://test-branch.lab.acme.com", "log_url": "https://example.com/deployment/42/output" } ]

Status codes

HTTP Status CodeDescription
200

OK

404

Resource not found

Notes

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

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
deployment_idintegerpath

deployment_id parameter

statestringbody

Required. The state of the status. Can be one of error, failure, inactive, in_progress, queued, pending, or success. When you set a transient deployment to inactive, the deployment will be shown as destroyed in GitHub.

target_urlstringbody

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.

log_urlstringbody

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: ""

descriptionstringbody

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

environmentstringbody

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

environment_urlstringbody

Sets the URL for accessing your environment. Default: ""

auto_inactivebooleanbody

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

Code samples

Example

Shell
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses \ -d '{"environment":"production","state":"success","log_url":"https://example.com/deployment/42/output","description":"Deployment finished successfully."}'
JavaScript @octokit/core.js
await octokit.request('POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses', { owner: 'OWNER', repo: 'REPO', deployment_id: 'DEPLOYMENT_ID', environment: 'production', state: 'success', log_url: 'https://example.com/deployment/42/output', description: 'Deployment finished successfully.' })
GitHub CLI gh api
gh api \ --method POST \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses \ -f environment='production' -f state='success' -f log_url='https://example.com/deployment/42/output' -f description='Deployment finished successfully.'

Response

Status: 201
{ "url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1", "id": 1, "node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx", "state": "success", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "description": "Deployment finished successfully.", "environment": "production", "target_url": "https://example.com/deployment/42/output", "created_at": "2012-07-20T01:19:13Z", "updated_at": "2012-07-20T01:19:13Z", "deployment_url": "https://api.github.com/repos/octocat/example/deployments/42", "repository_url": "https://api.github.com/repos/octocat/example", "environment_url": "https://test-branch.lab.acme.com", "log_url": "https://example.com/deployment/42/output" }

Status codes

HTTP Status CodeDescription
201

Created

422

Validation failed

Notes

Get a deployment status

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

get /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}

Parameters

NameTypeInDescription
acceptstringheader

Setting toapplication/vnd.github.v3+json is recommended.

ownerstringpath
repostringpath
deployment_idintegerpath

deployment_id parameter

status_idintegerpath

Code samples

Example

Shell
curl \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses/STATUS_ID
JavaScript @octokit/core.js
await octokit.request('GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}', { owner: 'OWNER', repo: 'REPO', deployment_id: 'DEPLOYMENT_ID', status_id: 'STATUS_ID' })
GitHub CLI gh api
gh api \ -H "Accept: application/vnd.github.v3+json" \ /repos/OWNER/REPO/deployments/DEPLOYMENT_ID/statuses/STATUS_ID

Response

Status: 200
{ "url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1", "id": 1, "node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx", "state": "success", "creator": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "description": "Deployment finished successfully.", "environment": "production", "target_url": "https://example.com/deployment/42/output", "created_at": "2012-07-20T01:19:13Z", "updated_at": "2012-07-20T01:19:13Z", "deployment_url": "https://api.github.com/repos/octocat/example/deployments/42", "repository_url": "https://api.github.com/repos/octocat/example", "environment_url": "https://test-branch.lab.acme.com", "log_url": "https://example.com/deployment/42/output" }

Status codes

HTTP Status CodeDescription
200

OK

404

Resource not found

Notes