# Update approval request settings

PATCH https://app.launchdarkly.com/api/v2/approval-requests/projects/{projectKey}/settings
Content-Type: application/json

Perform a partial update to approval request settings

Reference: https://launchdarkly.com/docs/api/approvals-beta/patch-approval-request-settings

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/approval-requests/projects/{projectKey}/settings:
    patch:
      operationId: patch-approval-request-settings
      summary: Update approval request settings
      description: Perform a partial update to approval request settings
      tags:
        - subpackage_approvalsBeta
      parameters:
        - name: projectKey
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
        - name: LD-API-Version
          in: header
          description: Version of the endpoint.
          required: true
          schema:
            $ref: >-
              #/components/schemas/ApiV2ApprovalRequestsProjectsProjectKeySettingsPatchParametersLdApiVersion
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalRequestSettings'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        description: Approval request settings to update
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApprovalRequestSettingsPatch'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    ApiV2ApprovalRequestsProjectsProjectKeySettingsPatchParametersLdApiVersion:
      type: string
      enum:
        - beta
      title: >-
        ApiV2ApprovalRequestsProjectsProjectKeySettingsPatchParametersLdApiVersion
    ApprovalRequestSettingsPatch:
      type: object
      properties:
        autoApplyApprovedChanges:
          type:
            - boolean
            - 'null'
          description: >
            Automatically apply changes that have been approved by all
            reviewers. This field is only applicable for approval services other
            than LaunchDarkly.
        bypassApprovalsForPendingChanges:
          type: boolean
          description: Whether to skip approvals for pending changes
        canApplyDeclinedChanges:
          type: boolean
          description: >-
            Allow applying the change as long as at least one person has
            approved
        canReviewOwnRequest:
          type: boolean
          description: >-
            Allow someone who makes an approval request to apply their own
            change
        environmentKey:
          type: string
        minNumApprovals:
          type: integer
          description: >
            Sets the amount of approvals required before a member can apply a
            change. The minimum is one and the maximum is five.
        required:
          type: boolean
          description: If approvals are required for this environment
        requiredApprovalTags:
          type: array
          items:
            type: string
          description: >
            Require approval only on flags with the provided tags. Otherwise all
            flags will require approval.
        resourceKind:
          type: string
        serviceConfig:
          type: object
          additionalProperties:
            description: Any type
          description: Arbitrary service-specific configuration
        serviceKind:
          type: string
          description: Which service to use for managing approvals
        serviceKindConfigurationId:
          type:
            - string
            - 'null'
          description: >
            Optional integration configuration ID of a custom approval
            integration. This is an Enterprise-only feature.
      required:
        - environmentKey
        - resourceKind
      title: ApprovalRequestSettingsPatch
    ApprovalRequestSetting:
      type: object
      properties:
        required:
          type: boolean
          description: If approvals are required for this environment
        bypassApprovalsForPendingChanges:
          type: boolean
          description: Whether to skip approvals for pending changes
        minNumApprovals:
          type: integer
          description: >
            Sets the amount of approvals required before a member can apply a
            change. The minimum is one and the maximum is five.
        canReviewOwnRequest:
          type: boolean
          description: >-
            Allow someone who makes an approval request to apply their own
            change
        canApplyDeclinedChanges:
          type: boolean
          description: >-
            Allow applying the change as long as at least one person has
            approved
        autoApplyApprovedChanges:
          type:
            - boolean
            - 'null'
          description: >
            Automatically apply changes that have been approved by all
            reviewers. This field is only applicable for approval services other
            than LaunchDarkly.
        serviceKind:
          type: string
          description: Which service to use for managing approvals
        serviceConfig:
          type: object
          additionalProperties:
            description: Any type
          description: Arbitrary service-specific configuration
        requiredApprovalTags:
          type: array
          items:
            type: string
          description: >
            Require approval only on flags with the provided tags. Otherwise all
            flags will require approval.
        serviceKindConfigurationId:
          type:
            - string
            - 'null'
          description: >
            Optional integration configuration ID of a custom approval
            integration. This is an Enterprise-only feature.
      required:
        - required
        - bypassApprovalsForPendingChanges
        - minNumApprovals
        - canReviewOwnRequest
        - canApplyDeclinedChanges
        - serviceKind
        - serviceConfig
        - requiredApprovalTags
      description: >-
        Configuration that controls how changes to a resource are gated by
        approvals.
      title: ApprovalRequestSetting
    ApprovalRequestSettingWithEnvs:
      type: object
      properties:
        environments:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ApprovalRequestSetting'
          description: Environment-specific overrides.
        _default:
          $ref: '#/components/schemas/ApprovalRequestSetting'
        _strict:
          $ref: '#/components/schemas/ApprovalRequestSetting'
      title: ApprovalRequestSettingWithEnvs
    ApprovalRequestSettings:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/ApprovalRequestSettingWithEnvs'
      title: ApprovalRequestSettings
    Error:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
      required:
        - message
        - code
      title: Error
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/approval-requests/projects/default/settings"

payload = {
    "environmentKey": "environmentKey",
    "resourceKind": "resourceKind",
    "autoApplyApprovedChanges": True,
    "bypassApprovalsForPendingChanges": False,
    "canApplyDeclinedChanges": True,
    "canReviewOwnRequest": False,
    "minNumApprovals": 1,
    "required": True,
    "requiredApprovalTags": ["require-approval"],
    "serviceKind": "launchdarkly",
    "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"
}
headers = {
    "LD-API-Version": "beta",
    "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/approval-requests/projects/default/settings';
const options = {
  method: 'PATCH',
  headers: {
    'LD-API-Version': 'beta',
    Authorization: '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"environmentKey":"environmentKey","resourceKind":"resourceKind","autoApplyApprovedChanges":true,"bypassApprovalsForPendingChanges":false,"canApplyDeclinedChanges":true,"canReviewOwnRequest":false,"minNumApprovals":1,"required":true,"requiredApprovalTags":["require-approval"],"serviceKind":"launchdarkly","serviceKindConfigurationId":"1ef45a85-218f-4428-a8b2-a97e5f56c258"}'
};

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/approval-requests/projects/default/settings"

	payload := strings.NewReader("{\n  \"environmentKey\": \"environmentKey\",\n  \"resourceKind\": \"resourceKind\",\n  \"autoApplyApprovedChanges\": true,\n  \"bypassApprovalsForPendingChanges\": false,\n  \"canApplyDeclinedChanges\": true,\n  \"canReviewOwnRequest\": false,\n  \"minNumApprovals\": 1,\n  \"required\": true,\n  \"requiredApprovalTags\": [\n    \"require-approval\"\n  ],\n  \"serviceKind\": \"launchdarkly\",\n  \"serviceKindConfigurationId\": \"1ef45a85-218f-4428-a8b2-a97e5f56c258\"\n}")

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

	req.Header.Add("LD-API-Version", "beta")
	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/approval-requests/projects/default/settings")

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

request = Net::HTTP::Patch.new(url)
request["LD-API-Version"] = 'beta'
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"environmentKey\": \"environmentKey\",\n  \"resourceKind\": \"resourceKind\",\n  \"autoApplyApprovedChanges\": true,\n  \"bypassApprovalsForPendingChanges\": false,\n  \"canApplyDeclinedChanges\": true,\n  \"canReviewOwnRequest\": false,\n  \"minNumApprovals\": 1,\n  \"required\": true,\n  \"requiredApprovalTags\": [\n    \"require-approval\"\n  ],\n  \"serviceKind\": \"launchdarkly\",\n  \"serviceKindConfigurationId\": \"1ef45a85-218f-4428-a8b2-a97e5f56c258\"\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/approval-requests/projects/default/settings")
  .header("LD-API-Version", "beta")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"environmentKey\": \"environmentKey\",\n  \"resourceKind\": \"resourceKind\",\n  \"autoApplyApprovedChanges\": true,\n  \"bypassApprovalsForPendingChanges\": false,\n  \"canApplyDeclinedChanges\": true,\n  \"canReviewOwnRequest\": false,\n  \"minNumApprovals\": 1,\n  \"required\": true,\n  \"requiredApprovalTags\": [\n    \"require-approval\"\n  ],\n  \"serviceKind\": \"launchdarkly\",\n  \"serviceKindConfigurationId\": \"1ef45a85-218f-4428-a8b2-a97e5f56c258\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.launchdarkly.com/api/v2/approval-requests/projects/default/settings', [
  'body' => '{
  "environmentKey": "environmentKey",
  "resourceKind": "resourceKind",
  "autoApplyApprovedChanges": true,
  "bypassApprovalsForPendingChanges": false,
  "canApplyDeclinedChanges": true,
  "canReviewOwnRequest": false,
  "minNumApprovals": 1,
  "required": true,
  "requiredApprovalTags": [
    "require-approval"
  ],
  "serviceKind": "launchdarkly",
  "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
    'LD-API-Version' => 'beta',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/approval-requests/projects/default/settings");
var request = new RestRequest(Method.PATCH);
request.AddHeader("LD-API-Version", "beta");
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"environmentKey\": \"environmentKey\",\n  \"resourceKind\": \"resourceKind\",\n  \"autoApplyApprovedChanges\": true,\n  \"bypassApprovalsForPendingChanges\": false,\n  \"canApplyDeclinedChanges\": true,\n  \"canReviewOwnRequest\": false,\n  \"minNumApprovals\": 1,\n  \"required\": true,\n  \"requiredApprovalTags\": [\n    \"require-approval\"\n  ],\n  \"serviceKind\": \"launchdarkly\",\n  \"serviceKindConfigurationId\": \"1ef45a85-218f-4428-a8b2-a97e5f56c258\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "LD-API-Version": "beta",
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "environmentKey": "environmentKey",
  "resourceKind": "resourceKind",
  "autoApplyApprovedChanges": true,
  "bypassApprovalsForPendingChanges": false,
  "canApplyDeclinedChanges": true,
  "canReviewOwnRequest": false,
  "minNumApprovals": 1,
  "required": true,
  "requiredApprovalTags": ["require-approval"],
  "serviceKind": "launchdarkly",
  "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/approval-requests/projects/default/settings")! 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()
```