# getHealth

> Check whether an SWQoS edge can currently reach upcoming leaders; readiness does not guarantee that a transaction will land.

<Note>
Supanode issues keys through [Telegram](https://telegram.me/supanode_tgs). Default minimum tip: 0.001 SOL; default rate: 15 sends/s per key per metro. Your key settings can differ. Declared tips are off by default and require enablement and a payment arrangement with Supanode. If your key returns `partner_declared_tips`, use an on-chain transfer instead.
</Note>

`POST https://fra.tpu.supanode.xyz/`

Authentication: API key, one of: `x-api-key` header, `api-key` query, `Authorization: Bearer` header.

## Request body (`application/json`)

One JSON object using the [shared request conventions](https://supanode.xyz/docs/solana/sender/reference/json-rpc#request). The method takes no params.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `jsonrpc` | `"2.0"` | yes |  |
| `id` | string or number or null | no | Optional request id, echoed exactly in the response. Null when absent or refused before the id could be read. |
| `method` | `"getHealth"` | yes |  |
| `params` | any | no | Ignored when present. |

```json title="Request"
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getHealth"
}
```

## Responses

### 200

Returns `ok` when an SWQoS edge can currently reach upcoming leaders; readiness does not guarantee that a transaction will land. A send can still be refused, for example with `not_ready`.

Refusals with HTTP 200, by `error.data.reason`:

- [`invalid_request`](https://supanode.xyz/docs/solana/sender/reference/errors#invalid_request): invalid JSON-RPC body, unreadable body or request body timeout.
- [`too_large`](https://supanode.xyz/docs/solana/sender/reference/errors#too_large): request body exceeds 65,536 bytes.

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `jsonrpc` | `"2.0"` | yes |  |
| `result` | `"ok"` | yes |  |
| `id` | string or number or null | yes | Optional request id, echoed exactly in the response. Null when absent or refused before the id could be read. |
| `jsonrpc` | `"2.0"` | yes |  |
| `error` | object | yes |  |
| `error.code` | `-32700` or `-32600` or `-32601` or `-32602` or `-32603` or `-32000` or `-32001` or `-32002` or `-32003` | yes | [Status codes](https://supanode.xyz/docs/solana/sender/reference/json-rpc#status-codes) maps reasons and problems to codes. Match on `data.reason`. |
| `error.message` | string | yes | The same sentence as data.message. |
| `error.data` | object | yes | Reason-specific fields are included alongside these members, such as minimum, found, declared, available, unpaid_lamports, index, per_second and retry_after_ms. Failed preflight also includes Solana simulation fields such as err, logs and unitsConsumed. |
| `error.data.reason` | string | yes | Stable snake_case reason. Match on this; `message` wording can change, and the numeric codes are shared with Solana's RPC. |
| `error.data.message` | string | yes | What happened and what to change. Wording can change. |
| `error.data.retryable` | boolean | yes | Whether the unchanged request can succeed later. Wait before retrying, and check that the transaction has not expired. |
| `error.data.docs` | string (uri) | no | Optional error documentation URL followed by the reason anchor. Supanode endpoints omit this field. |
| `id` | string or number or null | yes | Optional request id, echoed exactly in the response. Null when absent or refused before the id could be read. |

```json title="Success"
{
  "jsonrpc": "2.0",
  "result": "ok",
  "id": 1
}
```

```json title="Invalid JSON"
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32700,
    "message": "the body is not valid JSON",
    "data": {
      "reason": "invalid_request",
      "problem": "parse_error",
      "message": "the body is not valid JSON",
      "retryable": false
    }
  },
  "id": null
}
```

### 401

[`unauthorized`](https://supanode.xyz/docs/solana/sender/reference/errors#unauthorized): missing, unknown or revoked API key.

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `jsonrpc` | `"2.0"` | yes |  |
| `error` | object | yes |  |
| `error.code` | `-32700` or `-32600` or `-32601` or `-32602` or `-32603` or `-32000` or `-32001` or `-32002` or `-32003` | yes | [Status codes](https://supanode.xyz/docs/solana/sender/reference/json-rpc#status-codes) maps reasons and problems to codes. Match on `data.reason`. |
| `error.message` | string | yes | The same sentence as data.message. |
| `error.data` | object | yes | Reason-specific fields are included alongside these members, such as minimum, found, declared, available, unpaid_lamports, index, per_second and retry_after_ms. Failed preflight also includes Solana simulation fields such as err, logs and unitsConsumed. |
| `error.data.reason` | string | yes | Stable snake_case reason. Match on this; `message` wording can change, and the numeric codes are shared with Solana's RPC. |
| `error.data.message` | string | yes | What happened and what to change. Wording can change. |
| `error.data.retryable` | boolean | yes | Whether the unchanged request can succeed later. Wait before retrying, and check that the transaction has not expired. |
| `error.data.docs` | string (uri) | no | Optional error documentation URL followed by the reason anchor. Supanode endpoints omit this field. |
| `id` | string or number or null | yes | Optional request id, echoed exactly in the response. Null when absent or refused before the id could be read. |

```json title="unauthorized"
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32000,
    "message": "API key missing or not recognized; pass it as the api-key query parameter, an x-api-key header or Authorization: Bearer",
    "data": {
      "reason": "unauthorized",
      "message": "API key missing or not recognized; pass it as the api-key query parameter, an x-api-key header or Authorization: Bearer",
      "retryable": false
    }
  },
  "id": null
}
```

### 421

Unknown or removed TLS SNI or HTTP Host/:authority. Returns plain text without a JSON-RPC envelope or rejection object. The current hostname policy also applies to existing connections and resumed TLS sessions.

Content type: `text/plain`

```text title="UnknownHost"
This hostname is not served here. Check the endpoint address
```

### 503

The edge is not ready. Returns JSON-RPC code `-32005` and message `Node is unhealthy`, without a `data` member.

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `jsonrpc` | `"2.0"` | yes |  |
| `error` | object | yes |  |
| `error.code` | `-32005` | yes |  |
| `error.message` | `"Node is unhealthy"` | yes |  |
| `id` | string or number or null | yes | Optional request id, echoed exactly in the response. Null when absent or refused before the id could be read. |

```json title="Unhealthy"
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32005,
    "message": "Node is unhealthy"
  },
  "id": 1
}
```

## Code samples

```rust title="Rust"
// Builds on the example project (/reference/json-rpc#example-project).
use swqos_examples::swqos::{Result, SwqosError, call};

#[tokio::main]
async fn main() -> Result<()> {
    match call::<String>("getHealth", None).await {
        Ok(health) => println!("health {health}"),
        Err(error) => {
            if error
                .downcast_ref::<SwqosError>()
                .is_some_and(|error| error.code == -32005)
            {
                println!("edge not ready");
            } else {
                return Err(error);
            }
        }
    }
    let slot: u64 = call("getSlot", None).await?;
    println!("slot {slot}");
    Ok(())
}
```

```go title="Go"
// Builds on the example project (/reference/json-rpc#example-project).
package swqos

import (
	"context"
	"errors"
	"fmt"
)

func PrintHealth(ctx context.Context) error {
	health, err := Call[string](ctx, "getHealth")
	if err != nil {
		var refusal *SwqosError
		if !errors.As(err, &refusal) || refusal.Code != -32005 {
			return err
		}
		fmt.Println("edge not ready")
	} else {
		fmt.Println("health", health)
	}
	slot, err := Call[uint64](ctx, "getSlot")
	if err != nil {
		return err
	}
	fmt.Println("slot", slot)
	return nil
}
```

```ts title="TypeScript"
// Builds on the example project (/reference/json-rpc#example-project).
import { call, SwqosError } from './swqos.ts'

try {
  console.log('health', await call<string>('getHealth'))
} catch (error) {
  if (error instanceof SwqosError && error.code === -32005) console.log('edge not ready')
  else throw error
}
console.log('slot', await call<number>('getSlot'))
```
