# Update an announcement

PATCH https://app.launchdarkly.com/api/v2/announcements/{announcementId}
Content-Type: application/json

Update an announcement

Reference: https://launchdarkly.com/docs/api/announcements/update-announcement-public

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/announcements/{announcementId}:
    patch:
      operationId: update-announcement-public
      summary: Update an announcement
      description: Update an announcement
      tags:
        - subpackage_announcements
      parameters:
        - name: announcementId
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Updated announcement
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnnouncementResponse'
        '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'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        description: Update announcement request body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnnouncementJSONPatch'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    AnnouncementPatchOperation:
      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: AnnouncementPatchOperation
    AnnouncementJSONPatch:
      type: array
      items:
        $ref: '#/components/schemas/AnnouncementPatchOperation'
      title: AnnouncementJSONPatch
    AnnouncementResponseSeverity:
      type: string
      enum:
        - info
        - warning
        - critical
      description: The severity of the announcement
      title: AnnouncementResponseSeverity
    AnnouncementResponseStatus:
      type: string
      enum:
        - active
        - inactive
        - scheduled
      description: The status of the announcement
      title: AnnouncementResponseStatus
    ActionSpecifier:
      type: string
      title: ActionSpecifier
    AnnouncementAccessDeniedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AnnouncementAccessDeniedReasonEffect
    AnnouncementAccessDeniedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AnnouncementAccessDeniedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AnnouncementAccessDeniedReason
    AnnouncementAccessDenied:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/AnnouncementAccessDeniedReason'
      required:
        - action
        - reason
      title: AnnouncementAccessDenied
    AnnouncementAccessAllowedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AnnouncementAccessAllowedReasonEffect
    AnnouncementAccessAllowedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AnnouncementAccessAllowedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AnnouncementAccessAllowedReason
    AnnouncementAccessAllowedRep:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/AnnouncementAccessAllowedReason'
      required:
        - action
        - reason
      title: AnnouncementAccessAllowedRep
    AnnouncementAccessRep:
      type: object
      properties:
        denied:
          type: array
          items:
            $ref: '#/components/schemas/AnnouncementAccessDenied'
        allowed:
          type: array
          items:
            $ref: '#/components/schemas/AnnouncementAccessAllowedRep'
      required:
        - denied
        - allowed
      title: AnnouncementAccessRep
    AnnouncementLink:
      type: object
      properties:
        href:
          type: string
        type:
          type: string
      title: AnnouncementLink
    AnnouncementResponse__links:
      type: object
      properties:
        parent:
          $ref: '#/components/schemas/AnnouncementLink'
      required:
        - parent
      title: AnnouncementResponse__links
    AnnouncementResponse:
      type: object
      properties:
        _id:
          type: string
          description: The ID of the announcement
        isDismissible:
          type: boolean
          description: true if the announcement is dismissible
        title:
          type: string
          description: The title of the announcement
        message:
          type: string
          description: The message of the announcement
        startTime:
          type: integer
          format: int64
          description: >-
            The start time of the announcement. This is a Unix timestamp in
            milliseconds.
        endTime:
          type: integer
          format: int64
          description: >-
            The end time of the announcement. This is a Unix timestamp in
            milliseconds.
        severity:
          $ref: '#/components/schemas/AnnouncementResponseSeverity'
          description: The severity of the announcement
        _status:
          $ref: '#/components/schemas/AnnouncementResponseStatus'
          description: The status of the announcement
        _access:
          $ref: '#/components/schemas/AnnouncementAccessRep'
        _links:
          $ref: '#/components/schemas/AnnouncementResponse__links'
      required:
        - _id
        - isDismissible
        - title
        - message
        - startTime
        - severity
        - _status
        - _links
      description: Announcement response
      title: AnnouncementResponse
    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/announcements/1234567890"

payload = [
    {
        "op": "replace",
        "path": "/exampleField"
    }
]
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/announcements/1234567890';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '[{"op":"replace","path":"/exampleField"}]'
};

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/announcements/1234567890"

	payload := strings.NewReader("[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/exampleField\"\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/announcements/1234567890")

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\": \"/exampleField\"\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/announcements/1234567890")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"op\": \"replace\",\n    \"path\": \"/exampleField\"\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/announcements/1234567890");
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\": \"/exampleField\"\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": "/exampleField"
  ]
] as [String : Any]

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

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