---
title: "Check what a forge supports"
description: "Ask a provider whether it supports an operation before you call it."
canonical_url: "https://docs-oquac2tli-poetry.vercel.app/guides/capabilities"
---
# Check what a forge supports

> Ask a provider whether it supports an operation before you call it.

`provider.capabilities` describes what a provider supports. The provider computes it without a network request. [Capabilities](https://docs-oquac2tli-poetry.vercel.app/concepts/capabilities) explains the four values.

## Call `can()` before an operation

A verb is the path of the method on the provider, such as `threads.addLabels` or `webhooks.create`. Pass the thread kind as well when support differs by kind:

```ts
if (gh.can('threads.addLabels', thread.ref.kind)) {
  await gh.threads.addLabels(thread.ref, ['triage'])
}
```

`can()` returns `true` for `true`, `'experimental'`, and `'emulated'`. To treat experimental or emulated support differently, read the value from `capabilities`. Its keys follow the [capability matrix](https://docs-oquac2tli-poetry.vercel.app/reference/capability-matrix), so `threads.addLabels` is `capabilities.writes.addLabels`:

```ts
const support = provider.capabilities.writes.addLabels.issue
```

## Provide a fallback

Every method exists on every provider. A method for an unsupported operation rejects with `UnsupportedOperationError`. Check first, and choose what to do instead:

```ts
if (provider.can('threads.upsertComment', thread.ref.kind)) {
  await provider.threads.upsertComment(thread.ref, {
    key: 'ci-report',
    body,
  })
}
else {
  await provider.threads.comment(thread.ref, body)
}
```

## Check a stored capabilities object

`supports(capabilities, verb, kind?)` gives the same answer from a plain capabilities object. Use it with capabilities that you stored or received from another process:

```ts
import { supports } from 'forges'

const canMerge = supports(saved, 'threads.merge')
```

## Handle version-dependent capabilities

Some capabilities depend on the version of the instance. GitHub Enterprise Server supports marking notifications done from version 3.13, for example. Pass `instanceVersion` if you know it. Otherwise, call `refreshCapabilities()`, which reads the version once per provider and updates `capabilities`:

```ts
const capabilities = await forge.refreshCapabilities()
```

## Find the scopes a verb needs

When `can()` is `true` but a call fails with `InsufficientScopeError`, use [`scopesFor()`](https://docs-oquac2tli-poetry.vercel.app/guides/authentication#show-the-scopes-an-operation-needs).


## Sitemap

See the full [sitemap](https://docs-oquac2tli-poetry.vercel.app/sitemap.md) for all pages.
