# Update notification setting

> PUT /v1/notification-settings/{kind}. Sets one kind's email setting.

Source: https://legion.ambient.xyz/docs/api/notifications/update-notification-setting

`PUT https://api.legion.ambient.xyz/v1/notification-settings/{kind}`

Authenticate with an API key: `Authorization: Bearer $LEGION_API_KEY`.

Sets one kind's email setting. Only an owner may: a member is 403 `owner_required`. `member_ids` is required, and only read, when `recipients` is `selected`: it must name at least one
member (400 `selected_members_required`) and only members of the organization (400 `not_a_member`). A selected member who later leaves the organization is no longer emailed. Idempotent.

## Path parameters

- `kind`, NotificationKind, required

## Request body

- `email_enabled`, boolean, required
- `recipients`, NotificationRecipients, required: Who an emailed notification goes to.
- `member_ids`, array of string (uuid)

Example:

```json
{
  "email_enabled": false,
  "recipients": "all_members",
  "member_ids": [
    "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b"
  ]
}
```

## Responses

### 200

The kind's setting as saved.

- `kind`, NotificationKind, required: What a notification is about. Hosts: `host_added` (a host registered and waits for review), `host_approved` (Ambient approved it, also after a quarantine), `host_flagged` (Ambient quarantined it), `host_removed`, `host_offline` (no contact for 5 minutes), `host_online` (back after being offline), `benchmark_completed`. Rentals, the organization's own and those on its hosts: `rental_started`, `rental_stopped`, `rental_failed`. Money: `payout_sent`, `credit_added`, `out_of_credit` (the organization ran out of credit and its rentals were stopped). Team: `member_joined`, `member_removed`. `platform_update`: news from Legion for every organization. `member_removed` is a person removed by an owner or who left. `platform_update` is reserved: nothing emits it yet, and the email settings do not list it until something does. Clients must accept a kind they do not know. Promo codes: `promo_credit_granted` (a promo code's credit or discount was added), `promo_credit_expiring` (promo credit expires within 3 days; once per grant), `promo_redemption_held` (a redemption waits for a person at Ambient to look at it). `host_clock_off`: the clock of one of the organization's hosts has been more than 30 seconds off for 15 minutes; once per episode, with one reminder if it is still off 7 days later, and nothing when it recovers. `host_isolation_off`: one of the organization's approved hosts has not reported user-namespace isolation (`Host.isolation`) for 15 minutes while online, with the command that turns it on and the date from which the host is no longer offered without it; once per episode, with one reminder 2 days before that date if it is still off, and nothing when it is turned on. `host_start_hold`: new rentals are paused on one of the organization's hosts because models keep failing to start on it (`Host.start_hold`); once per pause, with why and how to end it. Auto top-up: `auto_top_up_changed` (a person changed the settings, saved or removed the card; in the feed only by default) and `auto_top_up_paused` (auto top-up stopped charging the card, with why and how to fix it; emailed to owners by default).
- `email_enabled`, boolean, required
- `recipients`, NotificationRecipients, required: Who an emailed notification goes to.
- `member_ids`, array of string (uuid), required: The selected members, when `recipients` is `selected`; empty otherwise.
- `is_default`, boolean, required: Nobody has changed this kind; it has Legion's default.

Example:

```json
{
  "kind": "host_added",
  "email_enabled": false,
  "recipients": "all_members",
  "member_ids": [
    "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b"
  ],
  "is_default": false
}
```

### 400

The request is malformed or fails validation. An image reference that
is not a container image reference answers `invalid_image_reference`.

### 401

Missing, unknown, expired or revoked credentials.

### 403

The caller lacks the permission this operation requires (`forbidden`),
or signed in without having joined an organization yet
(`no_organization`; `getOnboarding` and the invitation and
organization operations under it work), or could not sign in
(`email_unverified`, `account_conflict`, and `domain_not_allowed`). `not_invited` is no longer returned to
session tokens.

`access_not_approved`: a signed-in person who is not approved
for the beta yet. Every operation that takes a credential answers it to
them, except `getMe` and `joinMyWaitlist`; the problem carries
`access` (`waitlisted` or `not_requested`, and the email). Approved
means a member of an organization, holding a pending invitation, or Legion; an API key always belongs to a member.

`oauth_token_mcp_only`: the caller sent an OAuth access token (`lgo_`), which is accepted
only by `mcpMessage` and the tool calls it dispatches. Every other operation answers it, whatever
the token's scope. Use an API key or the Legion web app.

`org_suspended`: the caller's organization is suspended. Every operation that takes a
credential answers it, by session or API key, except `getMe` (which shows `org.suspended_at` and
`org.suspension_reason`) and the support operations under `/v1/support/`.

`terms_not_accepted`: an approved caller who has not accepted
the current version of the Terms of Use and the Acceptable Use Policy. Every operation that takes a credential answers it, except `getMe`,
`acceptLegalDocuments`, `joinMyWaitlist` and the wind-down operations
(`listRentals`, `stopRental`, `deleteRental`, `listHosts`,
`updateListing` with `listed` false, `removeHost`); the problem
carries `legal`. An API key acts for the person who created it, so it
is refused until that person accepts. Terminal
operations also return
`session_required` (called with an API key) and `step_up_required`
(neither a sign-in nor a step-up challenge within the step-up window).

### 500

An unexpected server error. Safe to retry.

## Errors

- 400 [`selected_members_required`](https://legion.ambient.xyz/docs/errors#selected_members_required)
- 400 [`not_a_member`](https://legion.ambient.xyz/docs/errors#not_a_member)
- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 403 [`owner_required`](https://legion.ambient.xyz/docs/errors#owner_required)

## Example request

```sh
curl -s -X PUT "https://api.legion.ambient.xyz/v1/notification-settings/$KIND" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "email_enabled": false,
  "recipients": "all_members",
  "member_ids": [
    "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b"
  ]
}'
```
