<!-- source: https://secondlayer.tools/docs/sdk-reference/instance -->

# `sl.instance`

The instance's public status report, and a verdict with next steps made from it.

## Methods

### sl.instance.status()

Get the instance's public status report.

Reads `GET /public/status`: the overall status, chain tip, chain integrity, and the state of each service and decoder.

```ts
sl.instance.status(): Promise<PublicStatus>
```

### sl.instance.diagnose()

Turn the status report into a verdict with next steps.

Resolves to a `state` (`healthy`, `empty-index`, or `degraded`), the API's own `overall` status, and a list of issues, each with the commands that resolve it. A fresh instance with no blocks indexed reads as `empty-index`, not broken.

```ts
sl.instance.diagnose(): Promise<InstanceDiagnosis>
```

## Types

- `InstanceDiagnosis`: An instance's state, the API verdict, and the issues found.
  - `state`: `InstanceState`
  - `overall`: `string`. The API's own top-level verdict, passed through unmodified.
  - `issues`: `InstanceIssue[]`
- `InstanceIssue`
  - `title`: `string`. What is wrong, in one line.
  - `detail`?: `string`. Why — assembled only from what the payload actually reports.
  - `nextSteps`: `string[]`. What to run next, most useful first.
- `InstanceState`: `"healthy" \| "empty-index" \| "degraded"`
- `PublicStatus`: The subset of `/status` a diagnosis reads.
  - `status`?: `string`
  - `chainTip`?: `number \| null`
  - `chainIntegrity`?: `{ ok?: boolean; maxHeight?: number; reason?: string \| null }`
  - `streams`?: `{ status?: string; tip?: { lag_seconds?: number; block_height?: number; } \| null }`
  - `index`?: `{ status?: string; decoders?: PublicStatusDecoder[] }`
  - `services`?: `PublicStatusService[]`
  - `timestamp`?: `string`
- `PublicStatusDecoder`
  - `decoder`: `string`
  - `status`: `string`
- `PublicStatusService`
  - `name`: `string`
  - `status`: `string`

## Notes for agents

- Methods live on 'sl.instance' of 'const sl = new SecondLayer()'. Signatures and overloads are generated from the SDK source.
- The Instance API page serves the status report over HTTP.

## Setup

Ensure setup once, skipping any step already done:
- Skill: `bunx skills add ryanwaits/secondlayer --skill secondlayer -y`
- CLI: `bun add -g @secondlayer/cli`
- Instance: `secondlayer init` writes `INSTANCE_TOKEN`. Loopback `/v1` reads need no key.
- Hosted/archive: export `SECONDLAYER_API_KEY` (`sk-sl_*`) or buy credits with `secondlayer credits buy` (`balance`, `refill`), then `secondlayer whoami`
