# Create a notification destination

`POST /apis/cra.diagrid.io/v1beta1/projects/{ProjectId}/notificationdestinations`

Create a notification destination in your project.

## Request

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `ProjectId` | string | Yes | Unique identifier of the project. |

### Request body

The notification destination to create.

`application/json`

- `apiVersion` (string)
- `kind` (string)
- `metadata` (object)
  - `name` (string)
  - `uid` (string)
  - `resourceVersion` (integer)
  - `createdAt` (string)
  - `updatedAt` (string)
  - `deletedAt` (string)
  - `labels` (object<string, string>)
  - `annotations` (object)
- `spec` (object) — NotificationDestinationSpec is the desired state of a NotificationDestination.
  - `type` (string) — Required. Immutable. Type selects the channel and which config block applies. One of: `webhook`.
  - `webhook` (object) — WebhookDestinationConfig configures delivery to an HTTP endpoint.
    - `url` (string) — Required. URL is the endpoint each matching notification is POSTed to.
    - `authToken` (string) — Write-only. AuthToken is the bearer token sent with every delivery. It is write-only: the value is moved into the project's secret store when the destination is written, and reading the destination back never returns it. Sending it again replaces the stored token.
    - `authTokenSet` (boolean) — Read-only. AuthTokenSet reports whether the destination authenticates its deliveries. The token itself is never returned, so this is how a reader tells a webhook that carries credentials from one that does not.
    - `headers` (object<string, string>) — Headers are extra request headers sent with every delivery. Content-Type and Authorization are set from the destination's own body and credentials and cannot be overridden here.
    - `bodyTemplate` (string) — BodyTemplate is a Go text template rendering the request body. Its data is the notification: .Type, .Labels and .Message. A `json` function is available and should wrap every interpolated value in a JSON body, as in `{"text": {{ .Message | json }}}`. Empty sends the notification serialized as JSON.
    - `responseCheck` (object) — WebhookResponseCheck decides from one field of a webhook's JSON response body whether a 2xx response was a successful delivery. A body that is not JSON is a failure.
      - `field` (string) — Required. Field is the dot-separated path of a field in the JSON response body, such as `ok` or `result.status`. An empty Field removes the check from the destination.
      - `value` (string) — Value is the value the field must have for the delivery to succeed, compared as text, so `true` matches both the boolean and the string. Empty: the delivery succeeds only when the field is missing, null or an empty string, for an endpoint that adds an `error` field only on failure.
      - `messageField` (string) — MessageField is the dot-separated path of the field that describes a failure, such as `error` or `error.message`. Its value is added to the delivery error.
- `status` (object) — NotificationDestinationStatus is the public status of a NotificationDestination.
  - `status` (string) — Status is the current processing status of the resource.
  - `updatedAt` (string) — UpdatedAt is the time of the last status update.
  - `messages` (object[]) — Messages contains any status messages, such as error details.
    - `message` (string)
  - `processedSpecVersion` (integer (int64)) — ProcessedSpecVersion is the spec version last processed by the consuming controller.

Example:

```json
{
  "apiVersion": "cra.diagrid.io/v1beta1",
  "kind": "NotificationDestination",
  "metadata": {
    "name": "ops-webhook"
  },
  "spec": {
    "type": "webhook",
    "webhook": {
      "url": "https://hooks.example.com/catalyst-alerts",
      "authToken": "<token>"
    }
  }
}
```

`application/vnd.api+json`

JSONAPI.org specification notification destination response wrapper for UI.

- `data` (object) — Required.
  - `type` (string) — Type of the resource object.
  - `id` (string) — Unique identifier of the resource object.
  - `attributes` (object)
    - `apiVersion` (string)
    - `kind` (string)
    - `metadata` (object)
      - `name` (string)
      - `uid` (string)
      - `resourceVersion` (integer)
      - `createdAt` (string)
      - `updatedAt` (string)
      - `deletedAt` (string)
      - `labels` (object<string, string>)
      - `annotations` (object)
    - `spec` (object) — NotificationDestinationSpec is the desired state of a NotificationDestination.
      - `type` (string) — Required. Immutable. Type selects the channel and which config block applies. One of: `webhook`.
      - `webhook` (object) — WebhookDestinationConfig configures delivery to an HTTP endpoint.
        - `url` (string) — Required. URL is the endpoint each matching notification is POSTed to.
        - `authToken` (string) — Write-only. AuthToken is the bearer token sent with every delivery. It is write-only: the value is moved into the project's secret store when the destination is written, and reading the destination back never returns it. Sending it again replaces the stored token.
        - `authTokenSet` (boolean) — Read-only. AuthTokenSet reports whether the destination authenticates its deliveries. The token itself is never returned, so this is how a reader tells a webhook that carries credentials from one that does not.
        - `headers` (object<string, string>) — Headers are extra request headers sent with every delivery. Content-Type and Authorization are set from the destination's own body and credentials and cannot be overridden here.
        - `bodyTemplate` (string) — BodyTemplate is a Go text template rendering the request body. Its data is the notification: .Type, .Labels and .Message. A `json` function is available and should wrap every interpolated value in a JSON body, as in `{"text": {{ .Message | json }}}`. Empty sends the notification serialized as JSON.
        - `responseCheck` (object) — WebhookResponseCheck decides from one field of a webhook's JSON response body whether a 2xx response was a successful delivery. A body that is not JSON is a failure.
          - `field` (string) — Required. Field is the dot-separated path of a field in the JSON response body, such as `ok` or `result.status`. An empty Field removes the check from the destination.
          - `value` (string) — Value is the value the field must have for the delivery to succeed, compared as text, so `true` matches both the boolean and the string. Empty: the delivery succeeds only when the field is missing, null or an empty string, for an endpoint that adds an `error` field only on failure.
          - `messageField` (string) — MessageField is the dot-separated path of the field that describes a failure, such as `error` or `error.message`. Its value is added to the delivery error.
    - `status` (object) — NotificationDestinationStatus is the public status of a NotificationDestination.
      - `status` (string) — Status is the current processing status of the resource.
      - `updatedAt` (string) — UpdatedAt is the time of the last status update.
      - `messages` (object[]) — Messages contains any status messages, such as error details.
        - `message` (string)
      - `processedSpecVersion` (integer (int64)) — ProcessedSpecVersion is the spec version last processed by the consuming controller.
  - `relationships` (object<string, object>) — Members of the relationships object represent references from the resource object in which it's defined to other resource objects.
    - Any of:
      - **option 1**
      - **option 2**
      - **option 3**
  - `links` (object<string, object>) — Link members related to the primary data.
    - One of:
      - **string (uri-reference)** — A string containing the link's URL.
      - **object**
        - `href` (string (uri-reference)) — Required. A string containing the link's URL.
        - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
  - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
- `links` (object<string, object>) — Link members related to the primary data.
  - One of:
    - **string (uri-reference)** — A string containing the link's URL.
    - **object**
      - `href` (string (uri-reference)) — Required. A string containing the link's URL.
      - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.

## Responses

### 201 — The created notification destination.

`application/json`

- `apiVersion` (string)
- `kind` (string)
- `metadata` (object)
  - `name` (string)
  - `uid` (string)
  - `resourceVersion` (integer)
  - `createdAt` (string)
  - `updatedAt` (string)
  - `deletedAt` (string)
  - `labels` (object<string, string>)
  - `annotations` (object)
- `spec` (object) — NotificationDestinationSpec is the desired state of a NotificationDestination.
  - `type` (string) — Required. Immutable. Type selects the channel and which config block applies. One of: `webhook`.
  - `webhook` (object) — WebhookDestinationConfig configures delivery to an HTTP endpoint.
    - `url` (string) — Required. URL is the endpoint each matching notification is POSTed to.
    - `authToken` (string) — Write-only. AuthToken is the bearer token sent with every delivery. It is write-only: the value is moved into the project's secret store when the destination is written, and reading the destination back never returns it. Sending it again replaces the stored token.
    - `authTokenSet` (boolean) — Read-only. AuthTokenSet reports whether the destination authenticates its deliveries. The token itself is never returned, so this is how a reader tells a webhook that carries credentials from one that does not.
    - `headers` (object<string, string>) — Headers are extra request headers sent with every delivery. Content-Type and Authorization are set from the destination's own body and credentials and cannot be overridden here.
    - `bodyTemplate` (string) — BodyTemplate is a Go text template rendering the request body. Its data is the notification: .Type, .Labels and .Message. A `json` function is available and should wrap every interpolated value in a JSON body, as in `{"text": {{ .Message | json }}}`. Empty sends the notification serialized as JSON.
    - `responseCheck` (object) — WebhookResponseCheck decides from one field of a webhook's JSON response body whether a 2xx response was a successful delivery. A body that is not JSON is a failure.
      - `field` (string) — Required. Field is the dot-separated path of a field in the JSON response body, such as `ok` or `result.status`. An empty Field removes the check from the destination.
      - `value` (string) — Value is the value the field must have for the delivery to succeed, compared as text, so `true` matches both the boolean and the string. Empty: the delivery succeeds only when the field is missing, null or an empty string, for an endpoint that adds an `error` field only on failure.
      - `messageField` (string) — MessageField is the dot-separated path of the field that describes a failure, such as `error` or `error.message`. Its value is added to the delivery error.
- `status` (object) — NotificationDestinationStatus is the public status of a NotificationDestination.
  - `status` (string) — Status is the current processing status of the resource.
  - `updatedAt` (string) — UpdatedAt is the time of the last status update.
  - `messages` (object[]) — Messages contains any status messages, such as error details.
    - `message` (string)
  - `processedSpecVersion` (integer (int64)) — ProcessedSpecVersion is the spec version last processed by the consuming controller.

Example:

```json
{
  "apiVersion": "cra.diagrid.io/v1beta1",
  "kind": "NotificationDestination",
  "metadata": {
    "name": "ops-webhook"
  },
  "spec": {
    "type": "webhook",
    "webhook": {
      "url": "https://hooks.example.com/catalyst-alerts",
      "authToken": "<token>"
    }
  }
}
```

`application/vnd.api+json`

JSONAPI.org specification notification destination response wrapper for UI.

- `data` (object) — Required.
  - `type` (string) — Type of the resource object.
  - `id` (string) — Unique identifier of the resource object.
  - `attributes` (object)
    - `apiVersion` (string)
    - `kind` (string)
    - `metadata` (object)
      - `name` (string)
      - `uid` (string)
      - `resourceVersion` (integer)
      - `createdAt` (string)
      - `updatedAt` (string)
      - `deletedAt` (string)
      - `labels` (object<string, string>)
      - `annotations` (object)
    - `spec` (object) — NotificationDestinationSpec is the desired state of a NotificationDestination.
      - `type` (string) — Required. Immutable. Type selects the channel and which config block applies. One of: `webhook`.
      - `webhook` (object) — WebhookDestinationConfig configures delivery to an HTTP endpoint.
        - `url` (string) — Required. URL is the endpoint each matching notification is POSTed to.
        - `authToken` (string) — Write-only. AuthToken is the bearer token sent with every delivery. It is write-only: the value is moved into the project's secret store when the destination is written, and reading the destination back never returns it. Sending it again replaces the stored token.
        - `authTokenSet` (boolean) — Read-only. AuthTokenSet reports whether the destination authenticates its deliveries. The token itself is never returned, so this is how a reader tells a webhook that carries credentials from one that does not.
        - `headers` (object<string, string>) — Headers are extra request headers sent with every delivery. Content-Type and Authorization are set from the destination's own body and credentials and cannot be overridden here.
        - `bodyTemplate` (string) — BodyTemplate is a Go text template rendering the request body. Its data is the notification: .Type, .Labels and .Message. A `json` function is available and should wrap every interpolated value in a JSON body, as in `{"text": {{ .Message | json }}}`. Empty sends the notification serialized as JSON.
        - `responseCheck` (object) — WebhookResponseCheck decides from one field of a webhook's JSON response body whether a 2xx response was a successful delivery. A body that is not JSON is a failure.
          - `field` (string) — Required. Field is the dot-separated path of a field in the JSON response body, such as `ok` or `result.status`. An empty Field removes the check from the destination.
          - `value` (string) — Value is the value the field must have for the delivery to succeed, compared as text, so `true` matches both the boolean and the string. Empty: the delivery succeeds only when the field is missing, null or an empty string, for an endpoint that adds an `error` field only on failure.
          - `messageField` (string) — MessageField is the dot-separated path of the field that describes a failure, such as `error` or `error.message`. Its value is added to the delivery error.
    - `status` (object) — NotificationDestinationStatus is the public status of a NotificationDestination.
      - `status` (string) — Status is the current processing status of the resource.
      - `updatedAt` (string) — UpdatedAt is the time of the last status update.
      - `messages` (object[]) — Messages contains any status messages, such as error details.
        - `message` (string)
      - `processedSpecVersion` (integer (int64)) — ProcessedSpecVersion is the spec version last processed by the consuming controller.
  - `relationships` (object<string, object>) — Members of the relationships object represent references from the resource object in which it's defined to other resource objects.
    - Any of:
      - **option 1**
      - **option 2**
      - **option 3**
  - `links` (object<string, object>) — Link members related to the primary data.
    - One of:
      - **string (uri-reference)** — A string containing the link's URL.
      - **object**
        - `href` (string (uri-reference)) — Required. A string containing the link's URL.
        - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
  - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
- `links` (object<string, object>) — Link members related to the primary data.
  - One of:
    - **string (uri-reference)** — A string containing the link's URL.
    - **object**
      - `href` (string (uri-reference)) — Required. A string containing the link's URL.
      - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.

### 403 — You are not authorized to perform this action.

`application/json`

In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status. The response contains an object with a single error object.

- `code` (string) — Required. This is the same as the HTTP status of the response.
- `message` (string) — Required. A short description of the error.
- `status` (object) — Required. A status code that indicates the error type.
- `details` (object) — Additional details about the errors.
  - `@type` (string) — The type of error.
  - `reason` (string) — A reason for the error.
  - `domain` (string) — The domain in which the error occurred.
  - `metadata` (object) — Additional metadata about the error.

`application/vnd.api+json`

JSONAPI.org specification error response wrapper for UI.

- `error` (object) — In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status. The response contains an object with a single error object.
  - `code` (string) — Required. This is the same as the HTTP status of the response.
  - `message` (string) — Required. A short description of the error.
  - `status` (object) — Required. A status code that indicates the error type.
  - `details` (object) — Additional details about the errors.
    - `@type` (string) — The type of error.
    - `reason` (string) — A reason for the error.
    - `domain` (string) — The domain in which the error occurred.
    - `metadata` (object) — Additional metadata about the error.
- `meta` (object<string, object>) — Link members related to the primary data.
  - One of:
    - **string (uri-reference)** — A string containing the link's URL.
    - **object**
      - `href` (string (uri-reference)) — Required. A string containing the link's URL.
      - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
- `links` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.

### 409 — The request conflicts with the current state of the notification destination.

`application/json`

In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status. The response contains an object with a single error object.

- `code` (string) — Required. This is the same as the HTTP status of the response.
- `message` (string) — Required. A short description of the error.
- `status` (object) — Required. A status code that indicates the error type.
- `details` (object) — Additional details about the errors.
  - `@type` (string) — The type of error.
  - `reason` (string) — A reason for the error.
  - `domain` (string) — The domain in which the error occurred.
  - `metadata` (object) — Additional metadata about the error.

`application/vnd.api+json`

JSONAPI.org specification error response wrapper for UI.

- `error` (object) — In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status. The response contains an object with a single error object.
  - `code` (string) — Required. This is the same as the HTTP status of the response.
  - `message` (string) — Required. A short description of the error.
  - `status` (object) — Required. A status code that indicates the error type.
  - `details` (object) — Additional details about the errors.
    - `@type` (string) — The type of error.
    - `reason` (string) — A reason for the error.
    - `domain` (string) — The domain in which the error occurred.
    - `metadata` (object) — Additional metadata about the error.
- `meta` (object<string, object>) — Link members related to the primary data.
  - One of:
    - **string (uri-reference)** — A string containing the link's URL.
    - **object**
      - `href` (string (uri-reference)) — Required. A string containing the link's URL.
      - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
- `links` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.

### default — Unexpected error.

`application/json`

In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status. The response contains an object with a single error object.

- `code` (string) — Required. This is the same as the HTTP status of the response.
- `message` (string) — Required. A short description of the error.
- `status` (object) — Required. A status code that indicates the error type.
- `details` (object) — Additional details about the errors.
  - `@type` (string) — The type of error.
  - `reason` (string) — A reason for the error.
  - `domain` (string) — The domain in which the error occurred.
  - `metadata` (object) — Additional metadata about the error.

`application/vnd.api+json`

JSONAPI.org specification error response wrapper for UI.

- `error` (object) — In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status. The response contains an object with a single error object.
  - `code` (string) — Required. This is the same as the HTTP status of the response.
  - `message` (string) — Required. A short description of the error.
  - `status` (object) — Required. A status code that indicates the error type.
  - `details` (object) — Additional details about the errors.
    - `@type` (string) — The type of error.
    - `reason` (string) — A reason for the error.
    - `domain` (string) — The domain in which the error occurred.
    - `metadata` (object) — Additional metadata about the error.
- `meta` (object<string, object>) — Link members related to the primary data.
  - One of:
    - **string (uri-reference)** — A string containing the link's URL.
    - **object**
      - `href` (string (uri-reference)) — Required. A string containing the link's URL.
      - `meta` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
- `links` (object) — Non-standard meta-information that can not be represented as an attribute or relationship.
