# Update a project monitor

## `PATCH /v1/projects/{projectId}/monitors/{alertId}`

Updates a project monitor. Requires `monitors:write` and organization admin privileges.

### Path parameters

- `projectId` (integer, required)
- `alertId` (string (uuid), required)

### Header parameters

- `Authorization` (string, required): `Bearer <token>`. [Authentication](https://spice.ai/docs/cloud/api/management#authentication) lists the tokens it accepts.
- `X-Org-Name` (string, optional): The organization to act on, by handle. Omit it to act on the organization the credential is bound to; sending it blank is a 400, not the same as omitting it. A user credential may name any organization its owner belongs to; a machine credential is pinned to its own. A portal session token is bound to none, so it must send this header on every route but `GET /v1/orgs` (400 `org_assertion_required` otherwise). Pattern: `^[A-Za-z0-9._-]{1,255}$`.

### Request body

Required.

Content type: `application/json`

- `name` (string): Minimum length: `1`. Maximum length: `100`.
- `description` (string | null): Maximum length: `500`.
- `status` (string): Allowed values: `active`, `disabled`.
- `templateId` (string)
- `spec` (object)
- `target` (object): Omit to keep the existing destination.

  One of:
  - **type: email** (object)
    - `type` (string, required): Value: `email`.
    - `recipientUserIds` (array of integer): Organization members to email, by user ID. Maximum items: `50`.
    - `emails` (array of string (email)): Maximum items: `20`.
  - **type: http** (object)
    - `type` (string, required): Value: `http`.
    - `url` (string (uri), required): The URL each notification is sent to, using `method`. Must be https and must resolve to a public address. Minimum length: `1`. Maximum length: `2048`.
    - `method` (string): A create that omits it uses POST. An update that omits it keeps the stored method. Allowed values: `POST`, `PUT`, `PATCH`.
    - `token` (string): Bearer token sent with each delivery. Stored encrypted and never returned. Minimum length: `1`. Maximum length: `512`.
  - **type: slack** (object)
    - `type` (string, required): Value: `slack`.
    - `channelId` (string, required): Slack conversation id. The organization must already have Slack connected. Minimum length: `9`. Maximum length: `32`. Pattern: `^[CGD][A-Z0-9]{8,31}$`.
    - `channelName` (string): Minimum length: `1`. Maximum length: `80`.
- `recipientUserIds` (array of integer)

### Example request

```bash
curl -X PATCH "https://api.spice.ai/v1/projects/<projectId>/monitors/<alertId>" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string",
    "description": "string",
    "status": "active",
    "templateId": "string",
    "spec": {},
    "target": {
      "type": "email"
    },
    "recipientUserIds": [
      0
    ]
  }'
```

```http
PATCH /v1/projects/<projectId>/monitors/<alertId> HTTP/1.1
Host: api.spice.ai
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 185

{
  "name": "string",
  "description": "string",
  "status": "active",
  "templateId": "string",
  "spec": {},
  "target": {
    "type": "email"
  },
  "recipientUserIds": [
    0
  ]
}
```

### Responses

**200 OK**

Monitor updated

**400 Bad Request**

Invalid request or monitor ID

**401 Unauthorized**

Unauthorized

**403 Forbidden**

Insufficient scope or role

**404 Not Found**

Project or monitor not found

**409 Conflict**

Duplicate monitor name or monitor changed during update

**413 Content Too Large**

Request body too large

**422 Unprocessable Content**

Destination is unavailable or project configuration is incomplete

**500 Internal Server Error**

Internal server error

**502 Bad Gateway**

Monitor backend update failed

## `PATCH /v1/orgs/{orgId}/projects/{projectId}/monitors/{alertId}`

The org is `orgId` in the path. Updates a project monitor. Requires `monitors:write` and organization admin privileges.

### Path parameters

- `orgId` (integer, required): The org id from GET /v1/orgs. Minimum: `1`.
- `projectId` (integer, required)
- `alertId` (string (uuid), required)

### Header parameters

- `Authorization` (string, required): `Bearer <token>`. [Authentication](https://spice.ai/docs/cloud/api/management#authentication) lists the tokens it accepts.
- `X-Org-Name` (string, optional): When present, X-Org-Name must name the same org as orgId. Otherwise the request returns org\_path\_mismatch (400). Pattern: `^[A-Za-z0-9._-]{1,255}$`.

### Request body

Required.

Content type: `application/json`

- `name` (string): Minimum length: `1`. Maximum length: `100`.
- `description` (string | null): Maximum length: `500`.
- `status` (string): Allowed values: `active`, `disabled`.
- `templateId` (string)
- `spec` (object)
- `target` (object): Omit to keep the existing destination.

  One of:
  - **type: email** (object)
    - `type` (string, required): Value: `email`.
    - `recipientUserIds` (array of integer): Organization members to email, by user ID. Maximum items: `50`.
    - `emails` (array of string (email)): Maximum items: `20`.
  - **type: http** (object)
    - `type` (string, required): Value: `http`.
    - `url` (string (uri), required): The URL each notification is sent to, using `method`. Must be https and must resolve to a public address. Minimum length: `1`. Maximum length: `2048`.
    - `method` (string): A create that omits it uses POST. An update that omits it keeps the stored method. Allowed values: `POST`, `PUT`, `PATCH`.
    - `token` (string): Bearer token sent with each delivery. Stored encrypted and never returned. Minimum length: `1`. Maximum length: `512`.
  - **type: slack** (object)
    - `type` (string, required): Value: `slack`.
    - `channelId` (string, required): Slack conversation id. The organization must already have Slack connected. Minimum length: `9`. Maximum length: `32`. Pattern: `^[CGD][A-Z0-9]{8,31}$`.
    - `channelName` (string): Minimum length: `1`. Maximum length: `80`.
- `recipientUserIds` (array of integer)

### Example request

```bash
curl -X PATCH "https://api.spice.ai/v1/orgs/<orgId>/projects/<projectId>/monitors/<alertId>" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string",
    "description": "string",
    "status": "active",
    "templateId": "string",
    "spec": {},
    "target": {
      "type": "email"
    },
    "recipientUserIds": [
      0
    ]
  }'
```

```http
PATCH /v1/orgs/<orgId>/projects/<projectId>/monitors/<alertId> HTTP/1.1
Host: api.spice.ai
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 185

{
  "name": "string",
  "description": "string",
  "status": "active",
  "templateId": "string",
  "spec": {},
  "target": {
    "type": "email"
  },
  "recipientUserIds": [
    0
  ]
}
```

### Responses

**200 OK**

Monitor updated

**400 Bad Request**

Invalid request or monitor ID. orgId is not a valid org id (`invalid_org_id`), or X-Org-Name does not name that org (`org_path_mismatch`).

**401 Unauthorized**

Unauthorized

**403 Forbidden**

Insufficient scope or role. The caller is not a member of the org (`org_forbidden`). A machine credential named a different org (`org_assertion_mismatch`). The org is deleted (`org_deleted`).

**404 Not Found**

Project or monitor not found

**409 Conflict**

Duplicate monitor name or monitor changed during update

**413 Content Too Large**

Request body too large

**422 Unprocessable Content**

Destination is unavailable or project configuration is incomplete

**500 Internal Server Error**

Internal server error

**502 Bad Gateway**

Monitor backend update failed

## `PATCH /v1/apps/{appId}/monitors/{alertId}` (deprecated)

Legacy alias of `/v1/projects/{projectId}/monitors/{alertId}` — projects were previously called apps. Updates a project monitor. Requires `monitors:write` and organization admin privileges.

### Path parameters

- `appId` (integer, required)
- `alertId` (string (uuid), required)

### Header parameters

- `Authorization` (string, required): `Bearer <token>`. [Authentication](https://spice.ai/docs/cloud/api/management#authentication) lists the tokens it accepts.
- `X-Org-Name` (string, optional): The organization to act on, by handle. Omit it to act on the organization the credential is bound to; sending it blank is a 400, not the same as omitting it. A user credential may name any organization its owner belongs to; a machine credential is pinned to its own. A portal session token is bound to none, so it must send this header on every route but `GET /v1/orgs` (400 `org_assertion_required` otherwise). Pattern: `^[A-Za-z0-9._-]{1,255}$`.

### Request body

Required.

Content type: `application/json`

- `name` (string): Minimum length: `1`. Maximum length: `100`.
- `description` (string | null): Maximum length: `500`.
- `status` (string): Allowed values: `active`, `disabled`.
- `templateId` (string)
- `spec` (object)
- `target` (object): Omit to keep the existing destination.

  One of:
  - **type: email** (object)
    - `type` (string, required): Value: `email`.
    - `recipientUserIds` (array of integer): Organization members to email, by user ID. Maximum items: `50`.
    - `emails` (array of string (email)): Maximum items: `20`.
  - **type: http** (object)
    - `type` (string, required): Value: `http`.
    - `url` (string (uri), required): The URL each notification is sent to, using `method`. Must be https and must resolve to a public address. Minimum length: `1`. Maximum length: `2048`.
    - `method` (string): A create that omits it uses POST. An update that omits it keeps the stored method. Allowed values: `POST`, `PUT`, `PATCH`.
    - `token` (string): Bearer token sent with each delivery. Stored encrypted and never returned. Minimum length: `1`. Maximum length: `512`.
  - **type: slack** (object)
    - `type` (string, required): Value: `slack`.
    - `channelId` (string, required): Slack conversation id. The organization must already have Slack connected. Minimum length: `9`. Maximum length: `32`. Pattern: `^[CGD][A-Z0-9]{8,31}$`.
    - `channelName` (string): Minimum length: `1`. Maximum length: `80`.
- `recipientUserIds` (array of integer)

### Example request

```bash
curl -X PATCH "https://api.spice.ai/v1/apps/<appId>/monitors/<alertId>" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string",
    "description": "string",
    "status": "active",
    "templateId": "string",
    "spec": {},
    "target": {
      "type": "email"
    },
    "recipientUserIds": [
      0
    ]
  }'
```

```http
PATCH /v1/apps/<appId>/monitors/<alertId> HTTP/1.1
Host: api.spice.ai
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 185

{
  "name": "string",
  "description": "string",
  "status": "active",
  "templateId": "string",
  "spec": {},
  "target": {
    "type": "email"
  },
  "recipientUserIds": [
    0
  ]
}
```

### Responses

**200 OK**

Monitor updated

**400 Bad Request**

Invalid request or monitor ID

**401 Unauthorized**

Unauthorized

**403 Forbidden**

Insufficient scope or role

**404 Not Found**

Project or monitor not found

**409 Conflict**

Duplicate monitor name or monitor changed during update

**413 Content Too Large**

Request body too large

**422 Unprocessable Content**

Destination is unavailable or project configuration is incomplete

**500 Internal Server Error**

Internal server error

**502 Bad Gateway**

Monitor backend update failed

OpenAPI: [api.spice.ai/openapi.json](https://api.spice.ai/openapi.json)
