# Update deployment

PATCH https://app.launchdarkly.com/api/v2/engineering-insights/deployments/{deploymentID}
Content-Type: application/json

Update a deployment by ID. Updating a deployment uses a [JSON patch](https://datatracker.ietf.org/doc/html/rfc6902) representation of the desired changes. To learn more, read [Updates](https://launchdarkly.com/docs/api#updates).<br/><br/>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.

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/engineering-insights/deployments/{deploymentID}:
    patch:
      operationId: update-deployment
      summary: Update deployment
      description: >-
        Update a deployment by ID. Updating a deployment uses a [JSON
        patch](https://datatracker.ietf.org/doc/html/rfc6902) representation of
        the desired changes. To learn more, read
        [Updates](https://launchdarkly.com/docs/api#updates).<br/><br/>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.
      tags:
        - subpackage_insightsDeploymentsBeta
      parameters:
        - name: deploymentID
          in: path
          description: The deployment ID
          required: true
          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'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JSONPatch'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    PatchOperation:
      type: object
      properties:
        op:
          type: string
          description: The type of operation to perform
        path:
          type: string
          description: >-
            A JSON Pointer string specifying the part of the document to operate
            on
        value:
          description: A JSON value used in "add", "replace", and "test" operations
      required:
        - op
        - path
      title: PatchOperation
    JSONPatch:
      type: array
      items:
        $ref: '#/components/schemas/PatchOperation'
      title: JSONPatch
    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"

payload = [
    {
        "op": "replace",
        "path": "/status"
    }
]
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '[{"op":"replace","path":"/status"}]'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

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

	payload := strings.NewReader("[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/status\"\n  }\n]")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	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::Patch.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/status\"\n  }\n]"

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.patch("https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/status\"\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.launchdarkly.com/api/v2/engineering-insights/deployments/deploymentID', [
  'body' => '[
  {
    "op": "replace",
    "path": "/status"
  }
]',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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.PATCH);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/status\"\n  }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  [
    "op": "replace",
    "path": "/status"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

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 = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```