# Deployments

> Source: https://developers.cloud66.com/v3/endpoints/deployments/

## Get Deployment

URL: https://developers.cloud66.com/v3/endpoints/deployments/#get
Endpoint: GET /stacks/:stack_id/deployments/:deployment_id
OAuth scope: public

Get information of a single deployment.

**Related models:** Deployment

### Parameters

- `stack_id` (string, required) — The stack UID
- `deployment_id` (integer, required) — The deployment ID

### Response

```json
{
  "response": {
    "id": 107,
    "triggered_by": "test@cloud66.com",
    "triggered_via": {
      "code": 0,
      "meaning": "web"
    },
    "started_at": "2014-08-29T17:46:16Z",
    "finished_at": "2014-08-29T17:58:23Z",
    "outcome": {
      "code": 1,
      "meaning": "success"
    },
    "git_hash": "5675fcd8f9e6dc534ecf1410c0661c066097e310",
    "deploy_session": "OhBHNzkXSl",
    "deploy_type": {
      "code": 0,
      "meaning": "build"
    },
    "is_head": true,
    "is_live": true,
    "reverted": null,
    "reverted_by": null,
    "reverted_at": null,
    "is_deploying": false,
    "commit_url": "https://github.com/cloud66-samples/rails-test/commit/5675fcd8f9e6dc534ecf1410c0661c066097e310"
  }
}
```

---

## List Deployments

URL: https://developers.cloud66.com/v3/endpoints/deployments/#list
Endpoint: GET /stacks/:stack_id/deployments
OAuth scope: public

Get list of all deployments of a stack.

**Related models:** Deployment, Pagination

### Parameters

- `stack_id` (string, required) — The stack UID

### Response

```json
{
  "response": [
    {
      "id": 107,
      "triggered_by": "test@cloud66.com",
      "triggered_via": {
        "code": 0,
        "meaning": "web"
      },
      "started_at": "2014-08-29T17:46:16Z",
      "finished_at": "2014-08-29T17:58:23Z",
      "outcome": {
        "code": 1,
        "meaning": "success"
      },
      "git_hash": "5675fcd8f9e6dc534ecf1410c0661c066097e310",
      "deploy_session": "OhBHNzkXSl",
      "deploy_type": {
        "code": 0,
        "meaning": "build"
      },
      "is_head": true,
      "is_live": true,
      "reverted": null,
      "reverted_by": null,
      "reverted_at": null,
      "is_deploying": false,
      "commit_url": "https://github.com/cloud66-samples/rails-test/commit/5675fcd8f9e6dc534ecf1410c0661c066097e310"
    }
  ],
  "count": 1,
  "pagination": {
    "previous": null,
    "next": null,
    "current": 1,
    "per_page": 30,
    "count": 1,
    "pages": 1
  }
}
```

---

## Redeploy Stack

URL: https://developers.cloud66.com/v3/endpoints/deployments/#create
Endpoint: POST /stacks/:stack_id/deployments
OAuth scope: redeploy

Redeploy a stack.

**Related models:** Deployment

### Parameters

- `stack_id` (string, required) — The stack UID
- `git_ref` (string, optional) — Git reference (branch, tag or hash). Non-docker only.
- `services` (string, optional) — Deploy only the service(s) & image(s) specified (Docker only).
- `deployment_profile` (string, optional) — Deploy using a deployment profile
- `user_reference` (string, optional) — Adds a value to the metadata field of the Stack Action (to allow you to match actions against your own identifiers). Max 255 chars.

### Response

```json
{
  "response": {
    "id": 108,
    "message": "Deployment scheduled",
    "queued": true
  }
}
```

---

## Cancel Deployment

URL: https://developers.cloud66.com/v3/endpoints/deployments/#cancel
Endpoint: DELETE /stacks/:stack_id/deployments/:deployment_id
OAuth scope: redeploy

Cancel a deployment.

**Related models:** Deployment

### Parameters

- `stack_id` (string, required) — The stack UID
- `deployment_id` (integer, required) — The deployment ID

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Deployment cancelled"
  }
}
```
