# Update flag link

PATCH https://app.launchdarkly.com/api/v2/flag-links/projects/{projectKey}/flags/{featureFlagKey}/{id}
Content-Type: application/json

Update a flag link. Updating a flag link 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).

Reference: https://launchdarkly.com/docs/api/flag-links-beta/update-flag-link

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/flag-links/projects/{projectKey}/flags/{featureFlagKey}/{id}:
    patch:
      operationId: update-flag-link
      summary: Update flag link
      description: >-
        Update a flag link. Updating a flag link 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).
      tags:
        - subpackage_flagLinksBeta
      parameters:
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: featureFlagKey
          in: path
          description: The feature flag key
          required: true
          schema:
            type: string
            format: string
        - name: id
          in: path
          description: The flag link ID
          required: true
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Flag link response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlagLinkRep'
        '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'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '409':
          description: Status conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusConflictErrorRep'
        '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
    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
    TimestampRep:
      type: object
      properties:
        milliseconds:
          $ref: '#/components/schemas/UnixMillis'
        seconds:
          type: integer
          format: int64
        rfc3339:
          type: string
        simple:
          type: string
      title: TimestampRep
    FlagLinkMember:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
        _id:
          type: string
        firstName:
          type: string
        lastName:
          type: string
      required:
        - _links
        - _id
      title: FlagLinkMember
    FlagLinkRep:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        _key:
          type: string
          description: The flag link key
        _integrationKey:
          type: string
          description: >-
            The integration key for an integration whose
            <code>manifest.json</code> includes the <code>flagLink</code>
            capability, if this is a flag link for an existing integration
        _id:
          type: string
          description: The ID of this flag link
        _deepLink:
          type: string
          description: The URL for the external resource the flag is linked to
        _timestamp:
          $ref: '#/components/schemas/TimestampRep'
          description: >-
            The time to mark this flag link as associated with the external URL.
            Defaults to the creation time of the flag link, but can be set to
            another time during creation.
        title:
          type: string
          description: The title of the flag link
        description:
          type: string
          description: The description of the flag link
        _metadata:
          type: object
          additionalProperties:
            type: string
          description: >-
            The metadata required by this integration in order to create a flag
            link, if this is a flag link for an existing integration. Defined in
            the integration's <code>manifest.json</code> file under
            <code>flagLink</code>.
        _createdAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the flag link was created
        _member:
          $ref: '#/components/schemas/FlagLinkMember'
          description: Details on the member associated with this flag link
      required:
        - _links
        - _id
        - _deepLink
        - _timestamp
        - _createdAt
      title: FlagLinkRep
    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
    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
    StatusConflictErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: StatusConflictErrorRep
    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/flag-links/projects/projectKey/flags/featureFlagKey/id"

payload = [
    {
        "op": "replace",
        "path": "/title"
    }
]
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/flag-links/projects/projectKey/flags/featureFlagKey/id';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '[{"op":"replace","path":"/title"}]'
};

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/flag-links/projects/projectKey/flags/featureFlagKey/id"

	payload := strings.NewReader("[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/title\"\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/flag-links/projects/projectKey/flags/featureFlagKey/id")

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\": \"/title\"\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/flag-links/projects/projectKey/flags/featureFlagKey/id")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/title\"\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.launchdarkly.com/api/v2/flag-links/projects/projectKey/flags/featureFlagKey/id', [
  'body' => '[
  {
    "op": "replace",
    "path": "/title"
  }
]',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/flag-links/projects/projectKey/flags/featureFlagKey/id");
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\": \"/title\"\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": "/title"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/flag-links/projects/projectKey/flags/featureFlagKey/id")! 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()
```