---
title: "Provider and capabilities"
description: "What every provider has, and how to check what a forge supports."
canonical_url: "https://forges.link/reference/provider"
---
# Provider and capabilities

> What every provider has, and how to check what a forge supports.

See [Capabilities](https://forges.link/concepts/capabilities) for what each level means, and the [capability matrix](https://forges.link/reference/capability-matrix) for every forge.

## Namespaces

| Namespace | Documented under |
| --- | --- |
| [`provider.threads`](https://forges.link/reference/threads#providerthreads) | Issues and pull requests |
| [`provider.repos`](https://forges.link/reference/repositories#providerrepos) | Repositories |
| [`provider.contents`](https://forges.link/reference/repositories#providercontents) | Repositories |
| [`provider.commits`](https://forges.link/reference/repositories#providercommits) | Repositories |
| [`provider.releases`](https://forges.link/reference/repositories#providerreleases) | Repositories |
| [`provider.users`](https://forges.link/reference/repositories#providerusers) | Repositories |
| [`provider.installations`](https://forges.link/reference/repositories#providerinstallations) | Repositories |
| [`provider.orgs`](https://forges.link/reference/repositories#providerorgs) | Repositories |
| [`provider.search`](https://forges.link/reference/repositories#providersearch) | Repositories |
| [`provider.notifications`](https://forges.link/reference/notifications#providernotifications) | Notifications, webhooks and CI |
| [`provider.sources`](https://forges.link/reference/notifications#providersources) | Notifications, webhooks and CI |
| [`provider.webhooks`](https://forges.link/reference/notifications#providerwebhooks) | Notifications, webhooks and CI |
| [`provider.checks`](https://forges.link/reference/notifications#providerchecks) | Notifications, webhooks and CI |
| [`provider.ci`](https://forges.link/reference/notifications#providerci) | Notifications, webhooks and CI |
| [`provider.securityAlerts`](https://forges.link/reference/notifications#providersecurityalerts) | Notifications, webhooks and CI |

## Properties

### `request`

Requests endpoints relative to `baseUrl` or absolute HTTP(S) URLs.
Other origins omit default headers and provider credentials; explicit headers apply.

**type:** [`ForgeRequest`](https://forges.link/reference/requests#forgerequest)

### `forge`

The forge this provider sends requests to; matches `forge` on every ref it returns.

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

### `instance`

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

### `baseUrl`

**type:** `string`

### `authKind`

The `auth.type` the provider was created with; `'anonymous'` when it sends no credentials.

**type:** [`AuthKind`](https://forges.link/reference/providers#authkind)

### `capabilities`

Static, no-network capabilities until `refreshCapabilities()` resolves.

**type:** [`ForgeCapabilities`](https://forges.link/reference/provider#forgecapabilities)

### `webOrigin`

The canonical origin of the forge's website for this instance, such as `https://github.com`
(without any deployment path), or `undefined` when the forge has no website. Useful for
resolving root-relative links and for building a content security policy.

**type:** `HasWeb extends true ? string : string | undefined`

## Methods

### `refreshCapabilities()`

Re-derives capabilities from the instance version. The version is read
once per provider (GHES `/meta`, GitLab, Forgejo and Gitea `/version`).
Updates `capabilities` and returns it.

```ts
refreshCapabilities(): Promise<ForgeCapabilities>
```

**Returns:** [`Promise<ForgeCapabilities>`](https://forges.link/reference/provider#forgecapabilities)

### `rateLimits()`

The request budgets of the latest responses, one per `resource`, read without sending a request. GitHub keeps
a budget per resource, such as `core`, `search` and `graphql`; other forges report one budget with no
`resource`. Empty until a response reports a budget. A budget whose `resetAt` has passed is left out.

**Example**

```ts
const core = forge.rateLimits().find(budget => !budget.resource || budget.resource === 'core')
if (core?.remaining !== undefined && core.limit && core.remaining / core.limit < 0.1) {
  await slowDown(core.resetAt)
}
```

```ts
rateLimits(): RateLimit[]
```

**Returns:** [`RateLimit[]`](https://forges.link/reference/requests#ratelimit)

### `normaliseMarkdown()`

Rewrites Markdown into the dialect the forge renders; returns it unchanged where the forge renders CommonMark.

```ts
normaliseMarkdown(body: string): string
```

| Parameter | Type |
| --- | --- |
| `body` | `string` |

**Returns:** `string`

### `can()`

Whether `verb` is supported, for `kind` where support differs by kind,
including version gates. Every verb is always present and rejects with
`UnsupportedOperationError` when this is `false`: the capability is the
question, the method is the action.

**Example**

```ts
if (provider.can('threads.merge')) {
  await provider.threads.merge(ref)
}
```

```ts
can(verb: ForgeVerb, kind?: ThreadKind | SecurityAlertKind): boolean
```

| Parameter | Type | Description |
| --- | --- | --- |
| `verb` | [`ForgeVerb`](https://forges.link/reference/provider#forgeverb) | The operation, named by its path on the provider, such as `threads.createComment`. |
| `kind?` | `ThreadKind \| SecurityAlertKind` | The thread kind, for an operation whose support differs by kind. |

**Returns:** `boolean`

### `support()`

How well `verb` is supported: `true`, `'emulated'`, `'not_applicable'`
or `false`, for `kind` where support differs by kind. `can()` is `true`
for every level but `false` and `'not_applicable'`. Without `kind`, a
per-kind verb reports its strongest level across kinds.

```ts
support(verb: ForgeVerb, kind?: ThreadKind | SecurityAlertKind): Support
```

| Parameter | Type | Description |
| --- | --- | --- |
| `verb` | [`ForgeVerb`](https://forges.link/reference/provider#forgeverb) | The operation, named by its path on the provider, such as `threads.createComment`. |
| `kind?` | `ThreadKind \| SecurityAlertKind` | The thread kind, for an operation whose support differs by kind. |

**Returns:** [`Support`](https://forges.link/reference/provider#support-2)

### `urlFor()`

The web page for `target`, built without a request; `undefined` when the forge has no such page.
A file target's `at` defaults to the repository's default branch.

**Overload 1 of 2**

```ts
urlFor(target: { repo: RepoRef, section?: undefined }): HasWeb extends true ? string : string | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `target` | [`{ repo: RepoRef, section?: undefined }`](https://forges.link/reference/data-model#reporef) | What to link to: a repository or one of its sections (`issues`, `pullRequests`, `compare`, `releases`, `stargazers`, `forks` or `watchers`), thread, comment, release, file, raw file, commit or comparison. |

**Returns:** `HasWeb extends true ? string : string | undefined`

**Overload 2 of 2**

```ts
urlFor(target: UrlTarget): string | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `target` | [`UrlTarget`](https://forges.link/reference/providers#urltarget) | What to link to: a repository or one of its sections (`issues`, `pullRequests`, `compare`, `releases`, `stargazers`, `forks` or `watchers`), thread, comment, release, file, raw file, commit or comparison. |

**Returns:** `string | undefined`

### `scopesFor()`

Token scopes or app permissions `verb` needs on this forge, as data for a
consent screen or a 403 explanation. Nothing in the library reads it, and
an unmapped verb returns `{}`.

```ts
scopesFor(verb: ForgeVerb): VerbScopes
```

| Parameter | Type | Description |
| --- | --- | --- |
| `verb` | [`ForgeVerb`](https://forges.link/reference/provider#forgeverb) | The operation, named by its path on the provider. |

**Returns:** [`VerbScopes`](https://forges.link/reference/provider#verbscopes)

### `parseUrl()`

Reads a web URL, clone URL or npm `repository` value (`git+https://`, `github:owner/name`) on this provider's instance into refs; `undefined` for anything else.

```ts
parseUrl(url: string | URL): ParsedForgeUrl | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `url` | `string \| URL` | The URL to read. |

**Returns:** [`ParsedForgeUrl | undefined`](https://forges.link/reference/providers#parsedforgeurl)

### `referenceFor()`

How to mention `ref` in Markdown on this forge (`#42`, `!42`,
`acme/widgets#42`, `acme/widgets@abc1234`), short when written in `from`;
the page URL where the forge has no reference syntax.

```ts
referenceFor(ref: ThreadRef | CommitRef, options?: ReferenceOptions): string | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `ref` | `ThreadRef \| CommitRef` | The thread or commit to mention. |
| `options?` | [`ReferenceOptions`](https://forges.link/reference/providers#referenceoptions) | The repository the reference is written in, so that a reference within it is short. |

**Returns:** `string | undefined`

### `parseReferences()`

The references to threads and commits in `text`, as `referenceFor()` writes them and people type them
(`#42`, `!42`, `GH-42`, `acme/widgets#42`, `acme/widgets@abc1234` or a bare sha), with their offsets,
in order. `#42` reads as an issue where issues and pull requests share numbers; `threads.get()`
returns the thread with its kind. A bare sha has 7 to 40 hex characters, with a letter and a digit.
Text inside a URL is skipped, but code spans are not, so leave them out of `text`. Empty when `from`
is on another instance, or the forge has no reference syntax.

```ts
parseReferences(text: string, options: ParseReferencesOptions): ParsedReference[]
```

| Parameter | Type | Description |
| --- | --- | --- |
| `text` | `string` | The text to read, such as a Markdown text node. |
| `options` | [`ParseReferencesOptions`](https://forges.link/reference/providers#parsereferencesoptions) | The repository the text is written in, which a short reference points into. |

**Returns:** [`ParsedReference[]`](https://forges.link/reference/providers#parsedreference)

## Unsupported operations

A method for an operation that the forge lacks rejects with [`UnsupportedOperationError`](https://forges.link/reference/errors#unsupportedoperationerror), or with [`ReadOnlyError`](https://forges.link/reference/errors#readonlyerror) on a read-only provider. Call `provider.can(verb)` first, or `provider.support(verb)` for the level of support.

## Check support

### `can()`

Whether `verb` is supported according to `capabilities`, for `kind` where
support differs by thread kind (or by alert kind for `securityAlerts`).
Without `kind`, a per-kind verb counts as supported when any kind is.

**Example**

```ts
if (can(provider.capabilities, 'threads.merge')) {
  await provider.threads.merge(ref)
}
```

```ts
function can(capabilities: ForgeCapabilities, verb: ForgeVerb, kind?: ThreadKind | SecurityAlertKind): boolean
```

| Parameter | Type | Description |
| --- | --- | --- |
| `capabilities` | [`ForgeCapabilities`](https://forges.link/reference/provider#forgecapabilities) | The capabilities of a provider, such as `provider.capabilities`. |
| `verb` | [`ForgeVerb`](https://forges.link/reference/provider#forgeverb) | The operation, named by its path on the provider, such as `threads.createComment`. |
| `kind?` | `ThreadKind \| SecurityAlertKind` | The thread or alert kind, for an operation whose support differs by kind. |

**Returns:** `boolean`

### `support()`

How well `verb` is supported according to `capabilities`: `true`,
`'emulated'`, `'not_applicable'` or `false`, for `kind` where support differs
by thread kind (or by alert kind for `securityAlerts`). Without `kind`, a
per-kind verb reports its strongest available level, or `'not_applicable'`
when no kind is available and any kind is, else `false`.

```ts
function support(capabilities: ForgeCapabilities, verb: ForgeVerb, kind?: ThreadKind | SecurityAlertKind): Support
```

| Parameter | Type | Description |
| --- | --- | --- |
| `capabilities` | [`ForgeCapabilities`](https://forges.link/reference/provider#forgecapabilities) | The capabilities of a provider, such as `provider.capabilities`. |
| `verb` | [`ForgeVerb`](https://forges.link/reference/provider#forgeverb) | The operation, named by its path on the provider, such as `threads.createComment`. |
| `kind?` | `ThreadKind \| SecurityAlertKind` | The thread or alert kind, for an operation whose support differs by kind. |

**Returns:** [`Support`](https://forges.link/reference/provider#support-2)

### `isUnsupported()`

Whether `support` means the operation cannot be called. Test this rather than `support === false`: `'not_applicable'` is a non-empty string. Accepts the declaration-only levels too, so a declared level can be tested before it resolves.

```ts
function isUnsupported(support: Support | 'experimental' | 'unverified'): boolean
```

| Parameter | Type |
| --- | --- |
| `support` | [`Support \| 'experimental' \| 'unverified'`](https://forges.link/reference/provider#support-2) |

**Returns:** `boolean`

## Capability types

### `ForgeVerb`

A provider verb, named by its path on `ForgeProvider`.

**type:** `VerbsOf<(typeof TABLE)[number]>`

### `ForgeCapabilities`

What a provider supports, operation by operation. It is computed without a request, and
`refreshCapabilities()` refines it with the instance version. Each verb has an entry at its
path on the provider, and the [capability matrix](https://forges.link/reference/capability-matrix) lists them
for every forge.

| Member | Type | Description |
| --- | --- | --- |
| `version?` | `string` | Instance version the capabilities were computed for, when known. |
| `experimental?` | `true` | The forge's API as a whole is unstable, so the provider can change with it. |
| `orgs` |  | An organisation's teams and their members, where the forge has teams, and the accounts it blocks. |
| `webhooks` |  | Receiving deliveries and managing registered webhooks. |
| `eventKinds` | `'native' \| 'heuristic'` | `'heuristic'` when event kinds are inferred from free text (GitLab system notes) rather than reported by the forge, so `kind` may be `'other'` or wrong for unrecognised wording; `kindRaw` and `payload` stay exact. |
| `authKinds` | [`readonly AuthKind[]`](https://forges.link/reference/providers#authkind) | Auth types the provider accepts. The type this provider was created with is `ForgeProvider.authKind`. |
| `limits?` | [`TextLimits`](https://forges.link/reference/data-model#textlimits) | Maximum text lengths the forge accepts. |

### `Support`

Capability flag. Every value other than `false` and `'not_applicable'` means the
operation is available:

- `true`: native.
- `'emulated'`: composed from other calls, so it costs more requests or the
result is approximate.
- `false`: not available, for any reason.
- `'not_applicable'`: the forge has no such operation, so there is nothing to
implement.

**one of:**

- `boolean`
- `'emulated'`
- `'not_applicable'`

### `PerKind`

Per-thread-kind support.

**type:** `Record<ThreadKind, Support>`

### `AlertSupport`

Support per security alert kind.

**type:** [`Record<'dependency' | 'code_scanning' | 'secret' | 'advisory', Support>`](https://forges.link/reference/provider#support-2)

### `VerbScopes`

What a credential needs for a verb, as data. Nothing in the library reads
it; it is there so a consumer can build a consent screen or explain a 403.

| Member | Type | Description |
| --- | --- | --- |
| `token?` | `string[]` | OAuth or personal access token scopes. |
| `permissions?` | `Record<string, 'read' \| 'write' \| 'admin'>` | Fine-grained token or app permissions, by permission name. |
| `note?` | `string` | How the forge expresses access where scopes do not apply. |


## Sitemap

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