---
title: "Notifications, webhooks and CI"
description: "Notifications, webhooks, checks, CI runs and security alerts."
canonical_url: "https://forges.link/reference/notifications"
---
# Notifications, webhooks and CI

> Notifications, webhooks, checks, CI runs and security alerts.

For an operation that the forge lacks, see [Unsupported operations](https://forges.link/reference/provider#unsupported-operations).

## `provider.notifications`

Reading and clearing the notifications of the authenticated account.

### `notifications.list()`

Lists the account's notifications.

**Capability:** `notifications.list`. Anonymous providers reject it.

```ts
notifications.list(options?: NotificationListOptions): ForgeListing<Notification>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`NotificationListOptions`](https://forges.link/reference/data-model#notificationlistoptions) |

**Returns:** `ForgeListing<Notification>`

<api-explorer verb="notifications.list">



</api-explorer>

### `notifications.markRead()`

Marks a notification as read.

**Capability:** `notifications.markRead`. Read-only and anonymous providers reject it.

```ts
notifications.markRead(ref: NotificationRef, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`NotificationRef`](https://forges.link/reference/data-model#notificationref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="notifications.markRead">



</api-explorer>

### `notifications.markDone()`

Marks a notification as done, which clears it from the inbox where the forge has that state.

**Capability:** `notifications.markDone`. Read-only and anonymous providers reject it.

```ts
notifications.markDone(ref: NotificationRef, options?: NotificationWriteOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`NotificationRef`](https://forges.link/reference/data-model#notificationref) |
| `options?` | [`NotificationWriteOptions`](https://forges.link/reference/data-model#notificationwriteoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="notifications.markDone">



</api-explorer>

### `notifications.unsubscribe()`

Stops notifications for the notification's thread, and on some forges also clears the notification.

**Capability:** `notifications.unsubscribe`. Read-only and anonymous providers reject it.

```ts
notifications.unsubscribe(ref: NotificationRef, options?: NotificationWriteOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`NotificationRef`](https://forges.link/reference/data-model#notificationref) |
| `options?` | [`NotificationWriteOptions`](https://forges.link/reference/data-model#notificationwriteoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="notifications.unsubscribe">



</api-explorer>

### `notifications.markAllRead()`

Marks every notification as read, or those of one repository.

**Capability:** `notifications.markAllRead`. Read-only and anonymous providers reject it.

```ts
notifications.markAllRead(options?: BulkNotificationOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`BulkNotificationOptions`](https://forges.link/reference/data-model#bulknotificationoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="notifications.markAllRead">



</api-explorer>

### `notifications.markAllDone()`

Marks every notification as done, or those of one repository.

**Capability:** `notifications.markAllDone`. Read-only and anonymous providers reject it.

```ts
notifications.markAllDone(options?: BulkNotificationOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`BulkNotificationOptions`](https://forges.link/reference/data-model#bulknotificationoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="notifications.markAllDone">



</api-explorer>

### `notifications.unreadCount()`

The number of unread notifications.

**Capability:** `notifications.unreadCount`. Anonymous providers reject it.

```ts
notifications.unreadCount(options?: BaseOptions): Promise<number>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<number>`

<api-explorer verb="notifications.unreadCount">



</api-explorer>

## `provider.sources`

Long-lived push streams of events.

### `sources.stream()`

Push delivery over a long-lived connection. Iteration ends when the signal
aborts or the consumer stops iterating; a dropped connection throws
`StreamClosedError` carrying the last cursor. There is no automatic
reconnection.

**Capability:** `sources.stream`.

```ts
sources.stream(options?: StreamOptions): AsyncIterable<StreamItem>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`StreamOptions`](https://forges.link/reference/data-model#streamoptions) |

**Returns:** [`AsyncIterable<StreamItem>`](https://forges.link/reference/data-model#streamitem)

## `provider.webhooks`

Receiving webhook deliveries, and managing the hooks registered on the forge.

### `webhooks.verify()`

Checks a delivery's signature or token against the secret.

**Capability:** `webhooks.ingest`.

```ts
webhooks.verify(delivery: WebhookDelivery): Promise<boolean>
```

| Parameter | Type |
| --- | --- |
| `delivery` | [`WebhookDelivery`](https://forges.link/reference/data-model#webhookdelivery) |

**Returns:** `Promise<boolean>`

### `webhooks.ingest()`

Verifies the delivery, then translates it into normalised events.

**Example**

```ts
const events = await provider.webhooks.ingest({
  headers: request.headers,
  body: await request.text(),
})
```

**Capability:** `webhooks.ingest`.

```ts
webhooks.ingest(delivery: WebhookDelivery): Promise<ForgeEvent[]>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `delivery` | [`WebhookDelivery`](https://forges.link/reference/data-model#webhookdelivery) | The headers and the raw body of the request, exactly as received. |

**Returns:** [`Promise<ForgeEvent[]>`](https://forges.link/reference/data-model#forgeevent)

### `webhooks.events`

Normalised kinds and actions this provider can deliver, whatever a hook is subscribed to.

**type:** [`WebhookEventType[]`](https://forges.link/reference/data-model#webhookeventtype)

### `webhooks.list()`

Hooks on a repository, or on an organisation or workspace when `target` is a namespace ref.

**Capability:** `webhooks.list`. Anonymous providers reject it.

```ts
webhooks.list(target: RepoRef, options?: PageOptions): ForgeListing<Webhook>
```

| Parameter | Type |
| --- | --- |
| `target` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Webhook>`

<api-explorer verb="webhooks.list">



</api-explorer>

### `webhooks.create()`

Registers a webhook. A repeat registers a second one, or rejects where the forge refuses a second hook for the same URL.

**Capability:** `webhooks.create`. Read-only and anonymous providers reject it.

```ts
webhooks.create(target: RepoRef, input: WebhookInput, options?: BaseOptions): Promise<Webhook>
```

| Parameter | Type |
| --- | --- |
| `target` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `input` | [`WebhookInput`](https://forges.link/reference/data-model#webhookinput) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<Webhook>`](https://forges.link/reference/data-model#webhook)

<api-explorer verb="webhooks.create">



</api-explorer>

### `webhooks.update()`

Changes a webhook.

**Capability:** `webhooks.update`. Read-only and anonymous providers reject it.

```ts
webhooks.update(ref: WebhookRef, update: WebhookUpdate, options?: BaseOptions): Promise<Webhook>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`WebhookRef`](https://forges.link/reference/data-model#webhookref) |
| `update` | [`WebhookUpdate`](https://forges.link/reference/data-model#webhookupdate) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<Webhook>`](https://forges.link/reference/data-model#webhook)

<api-explorer verb="webhooks.update">



</api-explorer>

### `webhooks.delete()`

Deletes a webhook. A repeat can reject with `NotFoundError` once the webhook is gone.

**Capability:** `webhooks.delete`. Read-only and anonymous providers reject it.

```ts
webhooks.delete(ref: WebhookRef, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`WebhookRef`](https://forges.link/reference/data-model#webhookref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="webhooks.delete">



</api-explorer>

### `webhooks.rotateSecret()`

Replaces the signing secret in place. `false` where the forge can only do it by recreating the hook.

**Capability:** `webhooks.rotateSecret`. Read-only and anonymous providers reject it.

```ts
webhooks.rotateSecret(ref: WebhookRef, secret: string, options?: BaseOptions): Promise<Webhook>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`WebhookRef`](https://forges.link/reference/data-model#webhookref) |
| `secret` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<Webhook>`](https://forges.link/reference/data-model#webhook)

<api-explorer verb="webhooks.rotateSecret">



</api-explorer>

### `webhooks.deliveries()`

Lists the recent deliveries of a webhook.

**Capability:** `webhooks.deliveries`. Anonymous providers reject it.

```ts
webhooks.deliveries(ref: WebhookRef, options?: PageOptions): ForgeListing<WebhookDeliveryRecord>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`WebhookRef`](https://forges.link/reference/data-model#webhookref) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<WebhookDeliveryRecord>`

<api-explorer verb="webhooks.deliveries">



</api-explorer>

### `webhooks.redeliver()`

Sends a past delivery again. A repeat sends it once more.

**Capability:** `webhooks.redeliver`. Read-only and anonymous providers reject it.

```ts
webhooks.redeliver(ref: WebhookDeliveryRef, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`WebhookDeliveryRef`](https://forges.link/reference/data-model#webhookdeliveryref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="webhooks.redeliver">



</api-explorer>

## `provider.checks`

Reading and reporting the checks on a commit.

### `checks.list()`

Every check on a commit: check runs, commit statuses, jobs or policy evaluations.

**Capability:** `checks.list`.

```ts
checks.list(repo: RepoRef, sha: string, options?: BaseOptions): Promise<Page<Check>>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `sha` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<Page<Check>>`](https://forges.link/reference/data-model#check)

<api-explorer verb="checks.list">



</api-explorer>

### `checks.get()`

Reads one check. Rejects for a `CheckRef.type` the forge cannot read on its own.

**Capability:** `checks.get`.

```ts
checks.get(ref: CheckRef, options?: BaseOptions): Promise<Check>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CheckRef`](https://forges.link/reference/data-model#checkref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<Check>`](https://forges.link/reference/data-model#check)

### `checks.report()`

Writes a commit status, or a check run where the credential can (GitHub app auth). A repeat writes a second check
run; a second commit status with the same name takes the place of the first, except on GitLab, which rejects a
repeat of a status that is still pending.

**Capability:** `checks.report`. Read-only and anonymous providers reject it.

```ts
checks.report(repo: RepoRef, sha: string, input: CheckReportInput, options?: BaseOptions): Promise<Check>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `sha` | `string` |
| `input` | [`CheckReportInput`](https://forges.link/reference/data-model#checkreportinput) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<Check>`](https://forges.link/reference/data-model#check)

<api-explorer verb="checks.report">



</api-explorer>

### `checks.rerun()`

Re-runs a check. Rejects for a `CheckRef.type` the forge cannot re-run. A repeat can start another run.

**Capability:** `checks.rerun`. Read-only and anonymous providers reject it.

```ts
checks.rerun(ref: CheckRef, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CheckRef`](https://forges.link/reference/data-model#checkref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="checks.rerun">



</api-explorer>

## `provider.ci`

Reading CI runs and their jobs, and re-running the jobs that failed.

### `ci.runs()`

Lists the CI runs of a repository.

**Capability:** `ci.runs`.

```ts
ci.runs(repo: RepoRef, query?: CiRunQuery): ForgeListing<CiRun>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `query?` | [`CiRunQuery`](https://forges.link/reference/data-model#cirunquery) |

**Returns:** `ForgeListing<CiRun>`

<api-explorer verb="ci.runs">



</api-explorer>

### `ci.getRun()`

Reads one CI run.

**Capability:** `ci.getRun`.

```ts
ci.getRun(ref: CiRunRef, options?: BaseOptions): Promise<CiRun>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CiRunRef`](https://forges.link/reference/data-model#cirunref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<CiRun>`](https://forges.link/reference/data-model#cirun)

<api-explorer verb="ci.getRun">



</api-explorer>

### `ci.jobs()`

Lists the jobs of a CI run.

**Capability:** `ci.jobs`.

```ts
ci.jobs(ref: CiRunRef, options?: PageOptions): ForgeListing<CiJob>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CiRunRef`](https://forges.link/reference/data-model#cirunref) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<CiJob>`

<api-explorer verb="ci.jobs">



</api-explorer>

### `ci.getJob()`

Reads one CI job. Where the forge has no endpoint for it (`capabilities.ci.getJob` is `'emulated'`), it lists the jobs
of the ref's `run` page by page until the id matches, which costs a request for each page read, so the ref must
name its run.

**Capability:** `ci.getJob`.

```ts
ci.getJob(ref: CiJobRef, options?: BaseOptions): Promise<CiJob>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CiJobRef`](https://forges.link/reference/data-model#cijobref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<CiJob>`](https://forges.link/reference/data-model#cijob)

### `ci.log()`

The job's log as it arrives.

**Capability:** `ci.log`.

```ts
ci.log(ref: CiJobRef, options?: BaseOptions): Promise<ReadableStream<Uint8Array>>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CiJobRef`](https://forges.link/reference/data-model#cijobref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<ReadableStream<Uint8Array>>`

<api-explorer verb="ci.log">



</api-explorer>

### `ci.rerunFailed()`

Re-runs the jobs of a CI run that failed, and the jobs that depend on them. A repeat can start another attempt.

**Capability:** `ci.rerunFailed`. Read-only and anonymous providers reject it.

```ts
ci.rerunFailed(ref: CiRunRef, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CiRunRef`](https://forges.link/reference/data-model#cirunref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="ci.rerunFailed">



</api-explorer>

## `provider.securityAlerts`

Reading the security alerts of a repository.

### `securityAlerts.list()`

Lists the security alerts of a repository.

**Capability:** `securityAlerts.list`.

```ts
securityAlerts.list(repo: RepoRef, options?: SecurityAlertListOptions): ForgeListing<SecurityAlert>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`SecurityAlertListOptions`](https://forges.link/reference/data-model#securityalertlistoptions) |

**Returns:** `ForgeListing<SecurityAlert>`

<api-explorer verb="securityAlerts.list">



</api-explorer>

## Checks helpers

Import from `forges/helpers`. It only needs `checks.list()`, so it works on any forge that has it.

### `WaitForChecksOptions`

Options for [`waitForChecks`](https://forges.link/reference/notifications#waitforchecks).

**extends:** [`BaseOptions`](https://forges.link/reference/requests#baseoptions)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `timeout?` | `number` | `600000` | Milliseconds before it gives up. `Infinity` waits for good. |
| `interval?` | `number` | `15000` | Milliseconds between reads. Each read is a `checks.list()`, so mind the rate limit. |
| `signal?` | `AbortSignal` |  | Aborts the operation's requests, and the operation rejects with the signal's reason. Writes the forge has already received are not undone. Inherited from [`BaseOptions`](https://forges.link/reference/requests#baseoptions). |

### `WaitForChecksResult`

What [`waitForChecks`](https://forges.link/reference/notifications#waitforchecks) found on its last read.

| Member | Type | Description |
| --- | --- | --- |
| `timedOut` | `boolean` | Time ran out with checks still running, or with none at all. |
| `state` | [`ChecksSummary['state']`](https://forges.link/reference/data-model#checkssummary) | Summed up like `Thread.checks`: `failure` when any check failed, even if others are still pending at the timeout, and `unknown` when the commit has no checks. |
| `checks` | [`Check[]`](https://forges.link/reference/data-model#check) | Every check from the last read. |
| `pending` | [`Check[]`](https://forges.link/reference/data-model#check) | The checks from the last read that were still running. |
| `warnings?` | [`ForgeWarning[]`](https://forges.link/reference/requests#forgewarning) | Sources the last read could not reach, whose checks are missing from `checks` and `state`. |

### `waitForChecks()`

Polls `checks.list()` until every check on the commit has finished, or `timeout` runs out. No checks yet counts as
pending, and `neutral` or `unknown` as finished; a failure does not end the wait. It sees only the checks a read
returns, so a check that registers late, or one that a read with `warnings` leaves out, can still be running.

**Example**

```ts
import { waitForChecks } from 'forges/helpers'

const { state, timedOut, warnings } = await waitForChecks(provider, repo, sha)
```

```ts
function waitForChecks(provider: ForgeProvider, repo: RepoRef, sha: string, options: WaitForChecksOptions = {}): Promise<WaitForChecksResult>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `provider` | [`ForgeProvider`](https://forges.link/reference/provider) | The provider to read the checks with. |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | The repository of the commit. |
| `sha` | `string` | The commit to wait for. |
| `options?` | [`WaitForChecksOptions`](https://forges.link/reference/notifications#waitforchecksoptions) | The `timeout`, the `interval` between reads, and a `signal` to stop waiting. Defaults to `{}`. |

**Returns:** [`Promise<WaitForChecksResult>`](https://forges.link/reference/notifications#waitforchecksresult)


## Sitemap

See the full [sitemap](https://forges.link/sitemap.md) for all pages.
