> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.elacity.ai/llms.txt.
> For full documentation content, see https://docs.elacity.ai/llms-full.txt.

# Update in-app notification preference

PATCH /api/in-app-notifications/preferences/{eventType}
Content-Type: application/json

Toggle whether the current user receives in-app notifications for a specific event type

Reference: https://docs.elacity.ai/api-reference/elacity-prm-api/in-app-notifications/in-app-notifications-update-preference

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /in-app-notifications/preferences/{eventType}:
    patch:
      operationId: in-app-notifications-update-preference
      summary: Update in-app notification preference
      description: >-
        Toggle whether the current user receives in-app notifications for a
        specific event type
      tags:
        - subpackage_inAppNotifications
      parameters:
        - name: eventType
          in: path
          required: true
          schema:
            $ref: >-
              #/components/schemas/InAppNotificationsPreferencesEventTypePatchParametersEventType
        - name: X-API-Key
          in: header
          description: API key for programmatic access
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/In-App
                  Notifications_inAppNotifications.updatePreference_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                orgSlug:
                  type: string
                enabled:
                  type: boolean
              required:
                - orgSlug
                - enabled
servers:
  - url: /api
components:
  schemas:
    InAppNotificationsPreferencesEventTypePatchParametersEventType:
      type: string
      enum:
        - agent.stale
        - agent.drifted
        - agent.error
        - deployment.complete
        - deployment.error
        - deployment.partial
        - deployment.timeout
        - deployment.pending_approval
        - deployment.approved
        - environment.inaccessible
      title: InAppNotificationsPreferencesEventTypePatchParametersEventType
    In-App Notifications_inAppNotifications.updatePreference_Response_200:
      oneOf:
        - description: Any type
        - description: Any type
      title: In-App Notifications_inAppNotifications.updatePreference_Response_200
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for programmatic access

```

## SDK Code Examples

```python
import requests

url = "https://api/in-app-notifications/preferences/agent.stale"

payload = {
    "orgSlug": "string",
    "enabled": True
}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api/in-app-notifications/preferences/agent.stale';
const options = {
  method: 'PATCH',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"orgSlug":"string","enabled":true}'
};

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://api/in-app-notifications/preferences/agent.stale"

	payload := strings.NewReader("{\n  \"orgSlug\": \"string\",\n  \"enabled\": true\n}")

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

	req.Header.Add("X-API-Key", "<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://api/in-app-notifications/preferences/agent.stale")

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

request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"orgSlug\": \"string\",\n  \"enabled\": true\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://api/in-app-notifications/preferences/agent.stale")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"orgSlug\": \"string\",\n  \"enabled\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api/in-app-notifications/preferences/agent.stale', [
  'body' => '{
  "orgSlug": "string",
  "enabled": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api/in-app-notifications/preferences/agent.stale");
var request = new RestRequest(Method.PATCH);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"orgSlug\": \"string\",\n  \"enabled\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "orgSlug": "string",
  "enabled": true
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api/in-app-notifications/preferences/agent.stale")! 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()
```