# Update phase status for release

PUT https://app.launchdarkly.com/api/v2/projects/{projectKey}/flags/{flagKey}/release/phases/{phaseId}
Content-Type: application/json

Updates the execution status of a phase of a release

Reference: https://launchdarkly.com/docs/api/releases-beta/update-phase-status

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/flags/{flagKey}/release/phases/{phaseId}:
    put:
      operationId: update-phase-status
      summary: Update phase status for release
      description: Updates the execution status of a phase of a release
      tags:
        - subpackage_releasesBeta
      parameters:
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: flagKey
          in: path
          description: The flag key
          required: true
          schema:
            type: string
            format: string
        - name: phaseId
          in: path
          description: The phase ID
          required: true
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Action succeeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Release'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '404':
          description: release or phase not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePhaseStatusInput'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    PhaseStatus:
      type: string
      title: PhaseStatus
    ReleaseGuardianConfigurationInput:
      type: object
      properties:
        monitoringWindowMilliseconds:
          type: integer
          format: int64
          description: The monitoring window in milliseconds
        rolloutWeight:
          type: integer
          description: The rollout weight
        rollbackOnRegression:
          type: boolean
          description: Whether or not to rollback on regression
        randomizationUnit:
          type: string
          description: The randomization unit for the measured rollout
      title: ReleaseGuardianConfigurationInput
    ReleaserAudienceConfigInput:
      type: object
      properties:
        audienceId:
          type: string
          description: UUID of the audience.
        releaseGuardianConfiguration:
          $ref: '#/components/schemas/ReleaseGuardianConfigurationInput'
          description: >-
            Optional configuration details for the specified audience. Will
            default to the release pipeline's audience configuration if omitted.
        notifyMemberIds:
          type: array
          items:
            type: string
          description: >-
            An array of member IDs. These members are notified to review the
            approval request.
        notifyTeamKeys:
          type: array
          items:
            type: string
          description: >-
            An array of team keys. The members of these teams are notified to
            review the approval request.
      title: ReleaserAudienceConfigInput
    UpdatePhaseStatusInput:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/PhaseStatus'
          description: Status of the phase
        audiences:
          type: array
          items:
            $ref: '#/components/schemas/ReleaserAudienceConfigInput'
          description: >-
            Extra configuration for audiences required upon phase
            initialization.
      title: UpdatePhaseStatusInput
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    MemberSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        _id:
          type: string
          description: The member's ID
        firstName:
          type: string
          description: The member's first name
        lastName:
          type: string
          description: The member's last name
        role:
          type: string
          description: >-
            The member's base role. If the member has no additional roles, this
            role will be in effect.
        email:
          type: string
          description: The member's email address
      required:
        - _links
        - _id
        - role
        - email
      title: MemberSummary
    TokenSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
        _id:
          type: string
        name:
          type: string
          description: The name of the token
        ending:
          type: string
          description: The last few characters of the token
        serviceToken:
          type: boolean
          description: Whether this is a service token
      title: TokenSummary
    CompletedBy:
      type: object
      properties:
        member:
          $ref: '#/components/schemas/MemberSummary'
          description: The LaunchDarkly member who marked this phase as complete
        token:
          $ref: '#/components/schemas/TokenSummary'
          description: The service token used to mark this phase as complete
      title: CompletedBy
    EnvironmentSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        key:
          type: string
          description: A project-unique key for the environment
        name:
          type: string
          description: A human-friendly name for the environment
        color:
          type: string
          description: The color used to indicate this environment in the UI
      required:
        - _links
        - key
        - name
        - color
      title: EnvironmentSummary
    ReleaseStrategy:
      type: string
      title: ReleaseStrategy
    ReleaseGuardianConfiguration:
      type: object
      properties:
        monitoringWindowMilliseconds:
          type: integer
          format: int64
          description: The monitoring window in milliseconds
        rolloutWeight:
          type: integer
          description: The rollout weight percentage
        rollbackOnRegression:
          type: boolean
          description: Whether or not to roll back on regression
        randomizationUnit:
          type: string
          description: The randomization unit for the measured rollout
      required:
        - monitoringWindowMilliseconds
        - rolloutWeight
        - rollbackOnRegression
      title: ReleaseGuardianConfiguration
    AudienceConfiguration:
      type: object
      properties:
        releaseStrategy:
          $ref: '#/components/schemas/ReleaseStrategy'
          description: The release strategy
        requireApproval:
          type: boolean
          description: Whether or not the audience requires approval
        notifyMemberIds:
          type: array
          items:
            type: string
          description: >-
            An array of member IDs. These members are notified to review the
            approval request.
        notifyTeamKeys:
          type: array
          items:
            type: string
          description: >-
            An array of team keys. The members of these teams are notified to
            review the approval request.
        releaseGuardianConfiguration:
          $ref: '#/components/schemas/ReleaseGuardianConfiguration'
          description: The configuration for the release guardian.
      required:
        - releaseStrategy
        - requireApproval
      title: AudienceConfiguration
    AudienceStatus:
      type: string
      title: AudienceStatus
    ReleaseAudience:
      type: object
      properties:
        _id:
          type: string
          description: The audience ID
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        environment:
          $ref: '#/components/schemas/EnvironmentSummary'
          description: >-
            Details about the environment. If the environment is deleted, this
            field will be omitted.
        name:
          type: string
          description: The release phase name
        configuration:
          $ref: '#/components/schemas/AudienceConfiguration'
          description: The audience configuration
        segmentKeys:
          type: array
          items:
            type: string
          description: A list of segment keys
        status:
          $ref: '#/components/schemas/AudienceStatus'
          description: The audience status
        _ruleIds:
          type: array
          items:
            type: string
          description: The rules IDs added or updated by this audience
      required:
        - _id
        - name
      title: ReleaseAudience
    PhaseConfiguration:
      type: object
      properties: {}
      title: PhaseConfiguration
    ReleasePhase:
      type: object
      properties:
        _id:
          type: string
          description: The phase ID
        _name:
          type: string
          description: The release phase name
        complete:
          type: boolean
          description: Whether this phase is complete
        _creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release phase was created
        _completionDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release phase was completed
        _completedBy:
          $ref: '#/components/schemas/CompletedBy'
          description: Details about how this phase was marked as complete
        _audiences:
          type: array
          items:
            $ref: '#/components/schemas/ReleaseAudience'
          description: >-
            A logical grouping of one or more environments that share attributes
            for rolling out changes
        status:
          $ref: '#/components/schemas/PhaseStatus'
          description: Status of the phase
        started:
          type: boolean
          description: Whether or not this phase has started
        _startedDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release phase was started
        configuration:
          $ref: '#/components/schemas/PhaseConfiguration'
          description: The phase configuration
      required:
        - _id
        - _name
        - complete
        - _creationDate
        - _audiences
      title: ReleasePhase
    Release:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        name:
          type: string
          description: The release pipeline name
        releasePipelineKey:
          type: string
          description: The release pipeline key
        releasePipelineDescription:
          type: string
          description: The release pipeline description
        phases:
          type: array
          items:
            $ref: '#/components/schemas/ReleasePhase'
          description: An ordered list of the release pipeline phases
        _version:
          type: integer
          description: The release version
        _releaseVariationId:
          type: string
          description: >-
            The chosen release variation ID to use across all phases of a
            release
        _canceledAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the release was canceled
      required:
        - name
        - releasePipelineKey
        - releasePipelineDescription
        - phases
        - _version
      title: Release
    InvalidRequestErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: InvalidRequestErrorRep
    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
    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/projects/projectKey/flags/flagKey/release/phases/phaseId"

payload = {}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/projects/projectKey/flags/flagKey/release/phases/phaseId';
const options = {
  method: 'PUT',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{}'
};

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/projects/projectKey/flags/flagKey/release/phases/phaseId"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PUT", 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/projects/projectKey/flags/flagKey/release/phases/phaseId")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.put("https://app.launchdarkly.com/api/v2/projects/projectKey/flags/flagKey/release/phases/phaseId")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://app.launchdarkly.com/api/v2/projects/projectKey/flags/flagKey/release/phases/phaseId', [
  'body' => '{}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/projectKey/flags/flagKey/release/phases/phaseId");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/projects/projectKey/flags/flagKey/release/phases/phaseId")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```