# Update change request state PUT https://app.unleash-instance.example.com/api/admin/projects/{projectId}/change-requests/{id}/state **Enterprise feature** This endpoint will update the state of a change request if the business rules allow it. The state can be one of the following: Draft, In review, Approved, Cancelled, Applied. In order to be approved, the change request must have at least one change and the number of approvals must be greater than or equal to the number of approvals required for the environment. Once a change request has been approved, it can be applied. Once a change request has been applied, it cannot be changed. Once a change request has been cancelled, it cannot be changed. Any change to a change request in the state of Approved will result in the state being set to In Review and the number of approvals will be reset. Reference: https://docs.getunleash.io/api/update-change-request-state ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: This endpoint will update the state of a change request version: endpoint_changeRequests.updateChangeRequestState paths: /api/admin/projects/{projectId}/change-requests/{id}/state: put: operationId: update-change-request-state summary: This endpoint will update the state of a change request description: >- **Enterprise feature** This endpoint will update the state of a change request if the business rules allow it. The state can be one of the following: Draft, In review, Approved, Cancelled, Applied. In order to be approved, the change request must have at least one change and the number of approvals must be greater than or equal to the number of approvals required for the environment. Once a change request has been approved, it can be applied. Once a change request has been applied, it cannot be changed. Once a change request has been cancelled, it cannot be changed. Any change to a change request in the state of Approved will result in the state being set to In Review and the number of approvals will be reset. tags: - - subpackage_changeRequests parameters: - name: projectId in: path required: true schema: type: string - name: id in: path required: true schema: type: string - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: changeRequestSchema content: application/json: schema: $ref: '#/components/schemas/changeRequestSchema' components: schemas: SetStrategySortOrderSchemaItems: type: object properties: id: type: string description: The ID of the strategy sortOrder: type: number format: double description: The new sort order of the strategy required: - id - sortOrder setStrategySortOrderSchema: type: array items: $ref: '#/components/schemas/SetStrategySortOrderSchemaItems' ChangeRequestChangeSchemaPayload: oneOf: - type: string - type: boolean - type: object additionalProperties: description: Any type - type: number format: double - $ref: '#/components/schemas/setStrategySortOrderSchema' ChangeRequestChangeSchemaCreatedBy: type: object properties: username: type: - string - 'null' description: The user's username. imageUrl: type: - string - 'null' format: uri description: The URL where the user's image can be found. ChangeRequestChangeSchemaScheduleConflictsChangeRequestsItems: type: object properties: id: type: number format: double description: The ID of the change request. title: type: string description: >- The title of the change request, if any. Only present if there is a title. required: - id ChangeRequestChangeSchemaScheduleConflicts: type: object properties: changeRequests: type: array items: $ref: >- #/components/schemas/ChangeRequestChangeSchemaScheduleConflictsChangeRequestsItems description: >- The list of scheduled change requests that would cause conflict with this change. required: - changeRequests changeRequestChangeSchema: type: object properties: id: type: number format: double description: The ID of this change. action: type: string description: The kind of action that the change contains information about. conflict: type: string description: >- A description of the conflict caused by this change. Only present if there are any conflicts. payload: $ref: '#/components/schemas/ChangeRequestChangeSchemaPayload' description: The data required to perform this action. createdBy: $ref: '#/components/schemas/ChangeRequestChangeSchemaCreatedBy' description: The user who created this change. createdAt: type: string format: date-time description: When this change was suggested scheduleConflicts: $ref: '#/components/schemas/ChangeRequestChangeSchemaScheduleConflicts' description: >- Information about scheduled change requests that would casue conflicts with this change if applied. required: - id - action ChangeRequestDefaultChangeSchemaPayload: type: object properties: {} changeRequestDefaultChangeSchema: type: object properties: action: type: string description: The kind of action this is. payload: $ref: '#/components/schemas/ChangeRequestDefaultChangeSchemaPayload' description: The necessary data to perform this change. required: - action - payload changeRequestFeatureSchema: type: object properties: name: type: string description: The name of the feature conflict: type: string description: >- A string describing the conflicts related to this change. Only present if there are any concflicts on the feature level. changes: type: array items: $ref: '#/components/schemas/changeRequestChangeSchema' description: >- List of changes inside change request. This list may be empty when listing all change requests for a project. defaultChange: $ref: '#/components/schemas/changeRequestDefaultChangeSchema' required: - name - changes ChangeRequestSegmentChangeSchemaPayload: oneOf: - type: string - type: boolean - type: object additionalProperties: description: Any type - type: number format: double - $ref: '#/components/schemas/setStrategySortOrderSchema' ChangeRequestSegmentChangeSchemaCreatedBy: type: object properties: username: type: - string - 'null' description: The user's username. imageUrl: type: - string - 'null' format: uri description: The URL where the user's image can be found. ChangeRequestSegmentChangeSchemaScheduleConflictsChangeRequestsItems: type: object properties: id: type: number format: double description: The ID of the change request. title: type: string description: >- The title of the change request, if any. Only present if there is a title. required: - id ChangeRequestSegmentChangeSchemaScheduleConflicts: type: object properties: changeRequests: type: array items: $ref: >- #/components/schemas/ChangeRequestSegmentChangeSchemaScheduleConflictsChangeRequestsItems description: >- The list of scheduled change requests that would cause conflict with this change. required: - changeRequests changeRequestSegmentChangeSchema: type: object properties: id: type: number format: double description: The ID of this change. action: type: string description: The kind of action that the change contains information about. conflict: type: string description: >- A description of the conflict caused by this change. Only present if there are any conflicts. payload: $ref: '#/components/schemas/ChangeRequestSegmentChangeSchemaPayload' description: The data required to perform this action. createdBy: $ref: '#/components/schemas/ChangeRequestSegmentChangeSchemaCreatedBy' description: The user who created this change. createdAt: type: string format: date-time description: When this change was suggested scheduleConflicts: $ref: >- #/components/schemas/ChangeRequestSegmentChangeSchemaScheduleConflicts description: >- Information about scheduled change requests that would casue conflicts with this change if applied. name: type: string description: The current name of the segment required: - id - action - payload - name ChangeRequestApprovalSchemaCreatedBy: type: object properties: id: type: number format: double description: The ID of the user who gave this approval. username: type: string description: The approving user's username. imageUrl: type: string format: uri description: The URL where the user's image can be found. changeRequestApprovalSchema: type: object properties: createdBy: $ref: '#/components/schemas/ChangeRequestApprovalSchemaCreatedBy' description: Information about the user who gave this approval. createdAt: type: string format: date-time description: When the approval was given. required: - createdBy - createdAt ChangeRequestCommentSchemaCreatedBy: type: object properties: username: type: - string - 'null' description: The user's username. imageUrl: type: - string - 'null' format: uri description: The URL where the user's image can be found. changeRequestCommentSchema: type: object properties: id: type: number format: double description: The comment's ID. Unique per change request. text: type: string description: The content of the comment. createdBy: $ref: '#/components/schemas/ChangeRequestCommentSchemaCreatedBy' description: Information about the user who posted the comment createdAt: type: string format: date-time description: When the comment was made. required: - text - createdBy - createdAt ChangeRequestSchemaOneOf0CreatedBy: type: object properties: username: type: - string - 'null' imageUrl: type: - string - 'null' format: uri description: The URL of the user's profile image. ChangeRequestSchemaOneOf0State: type: string enum: - value: Draft - value: In review - value: Approved - value: Applied - value: Cancelled - value: Rejected ChangeRequestSchema0: type: object properties: id: type: number format: double description: This change requests's ID. title: type: string description: A title describing the change request's content. environment: type: string description: The environment in which the changes should be applied. minApprovals: type: number format: double description: >- The minimum number of approvals required before this change request can be applied. project: type: string description: The project this change request belongs to. features: type: array items: $ref: '#/components/schemas/changeRequestFeatureSchema' description: >- The list of features and their changes that relate to this change request. segments: type: array items: $ref: '#/components/schemas/changeRequestSegmentChangeSchema' description: >- The list of segments and their changes that relate to this change request. approvals: type: array items: $ref: '#/components/schemas/changeRequestApprovalSchema' description: A list of approvals that this change request has received. rejections: type: array items: $ref: '#/components/schemas/changeRequestApprovalSchema' description: 'A list of rejections that this change request has received. ' comments: type: array items: $ref: '#/components/schemas/changeRequestCommentSchema' description: All comments that have been made on this change request. createdBy: $ref: '#/components/schemas/ChangeRequestSchemaOneOf0CreatedBy' description: The user who created this change request. createdAt: type: string format: date-time description: When this change request was created. stateTimestamps: type: object additionalProperties: type: string format: date-time description: >- A mapping of each state this change request has entered to the most recent time when it entered that state. If a change request has entered the same state multiple times, only the most recent timestamp will be included. state: $ref: '#/components/schemas/ChangeRequestSchemaOneOf0State' description: The current state of the change request. required: - id - environment - minApprovals - project - features - segments - createdBy - createdAt - stateTimestamps - state ChangeRequestSchemaOneOf1CreatedBy: type: object properties: username: type: - string - 'null' imageUrl: type: - string - 'null' format: uri description: The URL of the user's profile image. ChangeRequestSchemaOneOf1State: type: string enum: - value: Scheduled ChangeRequestScheduleSchemaOneOf0Status: type: string enum: - value: pending ChangeRequestScheduleSchema0: type: object properties: scheduledAt: type: string format: date-time description: When this change request will be applied. status: $ref: '#/components/schemas/ChangeRequestScheduleSchemaOneOf0Status' description: The status of the schedule. required: - scheduledAt - status ChangeRequestScheduleSchemaOneOf1Status: type: string enum: - value: failed ChangeRequestScheduleSchema1: type: object properties: scheduledAt: type: string format: date-time description: When Unleash last attempted to apply this change request. status: $ref: '#/components/schemas/ChangeRequestScheduleSchemaOneOf1Status' description: The status of the schedule. reason: type: string description: The reason the scheduled failed to apply. failureReason: type: - string - 'null' description: >- The reason the scheduled failed to apply. Deprecated in favor of the `reason` property. required: - scheduledAt - status - reason ChangeRequestScheduleSchemaOneOf2Status: type: string enum: - value: suspended ChangeRequestScheduleSchema2: type: object properties: scheduledAt: type: string format: date-time description: >- When Unleash would have attempted to apply this change request if the schedule was not suspended. status: $ref: '#/components/schemas/ChangeRequestScheduleSchemaOneOf2Status' description: The status of the schedule. reason: type: string description: Why the schedule was suspended. required: - scheduledAt - status - reason changeRequestScheduleSchema: oneOf: - $ref: '#/components/schemas/ChangeRequestScheduleSchema0' - $ref: '#/components/schemas/ChangeRequestScheduleSchema1' - $ref: '#/components/schemas/ChangeRequestScheduleSchema2' ChangeRequestSchema1: type: object properties: id: type: number format: double description: This change requests's ID. title: type: string description: A title describing the change request's content. environment: type: string description: The environment in which the changes should be applied. minApprovals: type: number format: double description: >- The minimum number of approvals required before this change request can be applied. project: type: string description: The project this change request belongs to. features: type: array items: $ref: '#/components/schemas/changeRequestFeatureSchema' description: >- The list of features and their changes that relate to this change request. segments: type: array items: $ref: '#/components/schemas/changeRequestSegmentChangeSchema' description: >- The list of segments and their changes that relate to this change request. approvals: type: array items: $ref: '#/components/schemas/changeRequestApprovalSchema' description: A list of approvals that this change request has received. rejections: type: array items: $ref: '#/components/schemas/changeRequestApprovalSchema' description: 'A list of rejections that this change request has received. ' comments: type: array items: $ref: '#/components/schemas/changeRequestCommentSchema' description: All comments that have been made on this change request. createdBy: $ref: '#/components/schemas/ChangeRequestSchemaOneOf1CreatedBy' description: The user who created this change request. createdAt: type: string format: date-time description: When this change request was created. stateTimestamps: type: object additionalProperties: type: string format: date-time description: >- A mapping of each state this change request has entered to the most recent time when it entered that state. If a change request has entered the same state multiple times, only the most recent timestamp will be included. state: $ref: '#/components/schemas/ChangeRequestSchemaOneOf1State' description: The current state of the change request. schedule: $ref: '#/components/schemas/changeRequestScheduleSchema' required: - id - environment - minApprovals - project - features - segments - createdBy - createdAt - stateTimestamps - state - schedule changeRequestSchema: oneOf: - $ref: '#/components/schemas/ChangeRequestSchema0' - $ref: '#/components/schemas/ChangeRequestSchema1' ``` ## SDK Code Examples ```python import requests url = "https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state" headers = {"Authorization": ""} response = requests.put(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state'; const options = {method: 'PUT', headers: {Authorization: ''}}; 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.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state" req, _ := http.NewRequest("PUT", url, nil) req.Header.Add("Authorization", "") 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.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = '' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state") .header("Authorization", "") .asString(); ``` ```php request('PUT', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state"); var request = new RestRequest(Method.PUT); request.AddHeader("Authorization", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/id/state")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ```