# Get deployment

GET https://app.launchdarkly.com/api/v2/engineering-insights/deployments/{deploymentID}

Get a deployment by ID.

The deployment ID is returned as part of the [List deployments](https://launchdarkly.com/docs/api/insights-deployments-beta/get-deployments) response. It is the `id` field of each element in the `items` array.

### Expanding the deployment response

LaunchDarkly supports expanding the deployment response to include additional fields.

To expand the response, append the `expand` query parameter and include the following:

* `pullRequests` includes details on all of the pull requests associated with each deployment
* `flagReferences` includes details on all of the references to flags in each deployment

For example, use `?expand=pullRequests` to include the `pullRequests` field in the response. By default, this field is **not** included in the response.


Reference: https://launchdarkly.com/docs/api/insights-deployments-beta/get-deployment

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/engineering-insights/deployments/{deploymentID}:
    get:
      operationId: get-deployment
      summary: Get deployment
      description: >
        Get a deployment by ID.


        The deployment ID is returned as part of the [List
        deployments](https://launchdarkly.com/docs/api/insights-deployments-beta/get-deployments)
        response. It is the `id` field of each element in the `items` array.


        ### Expanding the deployment response


        LaunchDarkly supports expanding the deployment response to include
        additional fields.


        To expand the response, append the `expand` query parameter and include
        the following:


        * `pullRequests` includes details on all of the pull requests associated
        with each deployment

        * `flagReferences` includes details on all of the references to flags in
        each deployment


        For example, use `?expand=pullRequests` to include the `pullRequests`
        field in the response. By default, this field is **not** included in the
        response.
      tags:
        - subpackage_insightsDeploymentsBeta
      parameters:
        - name: deploymentID
          in: path
          description: The deployment ID
          required: true
          schema:
            type: string
            format: string
        - name: expand
          in: query
          description: >-
            Expand properties in response. Options: `pullRequests`,
            `flagReferences`
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Deployment response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeploymentRep'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationFailedErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    DeploymentStatus:
      type: string
      title: DeploymentStatus
    DeploymentKind:
      type: string
      title: DeploymentKind
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    DeploymentCollectionRep:
      type: object
      properties:
        totalCount:
          type: integer
          description: The total number of deployments
        items:
          type: array
          items:
            $ref: '#/components/schemas/DeploymentRep'
          description: A list of deployments
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - totalCount
        - items
      title: DeploymentCollectionRep
    FlagReferenceRep:
      type: object
      properties:
        projectKey:
          type: string
          description: The project key
        flagKey:
          type: string
          description: The flag key
        referencesAdded:
          type: integer
          description: The number of references added
        referencesRemoved:
          type: integer
          description: The number of references removed
      required:
        - projectKey
        - flagKey
        - referencesAdded
        - referencesRemoved
      title: FlagReferenceRep
    FlagReferenceCollectionRep:
      type: object
      properties:
        totalCount:
          type: integer
          description: The total number of flag references
        items:
          type: array
          items:
            $ref: '#/components/schemas/FlagReferenceRep'
          description: A list of flag references
      required:
        - totalCount
        - items
      title: FlagReferenceCollectionRep
    PullRequestLeadTimeRep:
      type: object
      properties:
        codingDurationMs:
          type: integer
          format: int64
          description: The coding duration in milliseconds
        reviewDurationMs:
          type: integer
          format: int64
          description: The review duration in milliseconds
        maxWaitDurationMs:
          type: integer
          format: int64
          description: >-
            The max wait duration between merge time and deploy start time in
            milliseconds
        avgWaitDurationMs:
          type: integer
          format: int64
          description: >-
            The average wait duration between merge time and deploy start time
            in milliseconds
        maxDeployDurationMs:
          type: integer
          format: int64
          description: The max deploy duration in milliseconds
        avgDeployDurationMs:
          type: integer
          format: int64
          description: The average deploy duration in milliseconds
        maxTotalLeadTimeMs:
          type: integer
          format: int64
          description: The max total lead time in milliseconds
        avgTotalLeadTimeMs:
          type: integer
          format: int64
          description: The average total lead time in milliseconds
      required:
        - codingDurationMs
      title: PullRequestLeadTimeRep
    PullRequestRep:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The pull request internal ID
        externalId:
          type: string
          description: The pull request number
        title:
          type: string
          description: The pull request title
        status:
          type: string
          description: The pull request status
        author:
          type: string
          description: The pull request author
        createTime:
          $ref: '#/components/schemas/UnixMillis'
          description: The pull request create time
        mergeTime:
          $ref: '#/components/schemas/UnixMillis'
          description: The pull request merge time
        mergeCommitKey:
          type: string
          description: The pull request merge commit key
        baseCommitKey:
          type: string
          description: The pull request base commit key
        headCommitKey:
          type: string
          description: The pull request head commit key
        filesChanged:
          type: integer
          description: The number of files changed
        linesAdded:
          type: integer
          description: The number of lines added
        linesDeleted:
          type: integer
          description: The number of lines deleted
        url:
          type: string
          description: The pull request URL
        deployments:
          $ref: '#/components/schemas/DeploymentCollectionRep'
          description: A list of deployments associated with the pull request
        flagReferences:
          $ref: '#/components/schemas/FlagReferenceCollectionRep'
          description: A list of flag references associated with the pull request
        leadTime:
          $ref: '#/components/schemas/PullRequestLeadTimeRep'
          description: The lead time for the pull request in a given environment
      required:
        - id
        - externalId
        - title
        - status
        - author
        - createTime
        - baseCommitKey
        - headCommitKey
        - filesChanged
        - linesAdded
        - linesDeleted
        - url
      title: PullRequestRep
    PullRequestCollectionRep:
      type: object
      properties:
        totalCount:
          type: integer
          description: The total number of pull requests
        items:
          type: array
          items:
            $ref: '#/components/schemas/PullRequestRep'
          description: A list of pull requests
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - totalCount
        - items
      title: PullRequestCollectionRep
    LeadTimeStagesRep:
      type: object
      properties:
        codingDurationMs:
          type: integer
          format: int64
          description: The coding duration in milliseconds
        reviewDurationMs:
          type: integer
          format: int64
          description: The review duration in milliseconds
        waitDurationMs:
          type: integer
          format: int64
          description: >-
            The wait duration between merge time and deploy start time in
            milliseconds
        deployDurationMs:
          type: integer
          format: int64
          description: The deploy duration in milliseconds
        totalLeadTimeMs:
          type: integer
          format: int64
          description: The total lead time in milliseconds
      required:
        - codingDurationMs
      title: LeadTimeStagesRep
    DeploymentRep:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The deployment ID
        applicationKey:
          type: string
          description: The application key
        applicationVersion:
          type: string
          description: The application version
        startedAt:
          $ref: '#/components/schemas/UnixMillis'
          description: The time the deployment started
        endedAt:
          $ref: '#/components/schemas/UnixMillis'
          description: The time the deployment ended
        durationMs:
          type: integer
          format: int64
          description: The duration of the deployment in milliseconds
        status:
          $ref: '#/components/schemas/DeploymentStatus'
          description: The status of the deployment
        kind:
          $ref: '#/components/schemas/DeploymentKind'
          description: The kind of deployment
        active:
          type: boolean
          description: Whether the deployment is active
        metadata:
          type: object
          additionalProperties:
            description: Any type
          description: The metadata associated with the deployment
        archived:
          type: boolean
          description: Whether the deployment is archived
        environmentKey:
          type: string
          description: The environment key
        numberOfContributors:
          type: integer
          description: The number of contributors
        numberOfPullRequests:
          type: integer
          description: The number of pull requests
        linesAdded:
          type: integer
          format: int64
          description: The number of lines added
        linesDeleted:
          type: integer
          format: int64
          description: The number of lines deleted
        leadTime:
          type: integer
          format: int64
          description: >-
            The total lead time from first commit to deployment end in
            milliseconds
        pullRequests:
          $ref: '#/components/schemas/PullRequestCollectionRep'
          description: The pull requests contained in the deployment
        flagReferences:
          $ref: '#/components/schemas/FlagReferenceCollectionRep'
          description: The flag references contained in the deployment
        leadTimeStages:
          $ref: '#/components/schemas/LeadTimeStagesRep'
          description: The lead time stages for the deployment
      required:
        - id
        - applicationKey
        - applicationVersion
        - startedAt
        - status
        - kind
        - active
        - archived
        - environmentKey
        - numberOfContributors
        - numberOfPullRequests
        - linesAdded
        - linesDeleted
        - leadTime
      title: DeploymentRep
    FailureReasonRep:
      type: object
      properties:
        attribute:
          type: string
          description: The attribute that failed validation
        reason:
          type: string
          description: The reason the attribute failed validation
      required:
        - attribute
        - reason
      title: FailureReasonRep
    ValidationFailedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
        errors:
          type: array
          items:
            $ref: '#/components/schemas/FailureReasonRep'
          description: List of validation errors
      required:
        - code
        - message
        - errors
      title: ValidationFailedErrorRep
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    NotFoundErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: NotFoundErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID"

headers = {"Authorization": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID';
const options = {method: 'GET', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```