# Check that the API is up

- Endpoint: `GET /v1/health`
- Production: `https://api.main-team.org/v1/health`
- Sandbox: `https://apisnd.main-team.org/v1/health`
- Operation: `getHealth` (Health)
- Authentication: none, a public operation

## Description

Answers `200` with `data.status` `ok` whenever the service is running. It needs no token and is not counted against your account’s rate limit, so it is the first call to make against an environment.

It says only that the service answers: it checks nothing the other operations depend on, so one of them can still fail while this answers `ok`.

## Response

`200` Success: `message` is "Request completed successfully.".

```json
{
  "success": true,
  "message": "Request completed successfully.",
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 57,
    "totalPages": 3
  },
  "data": {
    "status": "ok"
  }
}
```

## Code samples

### curl

```bash
curl -sS 'https://api.main-team.org/v1/health'
```

### Node.js

```js
const res = await fetch('https://api.main-team.org/v1/health');
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`);
console.log(body.data);
```

### PHP

```php
<?php
$ch = curl_init('https://api.main-team.org/v1/health');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
    throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$body = json_decode($response, true);
if ($status >= 400) {
    $error = $body['error'];
    throw new RuntimeException("$status {$error['code']}: {$error['message']}");
}
print_r($body['data']);
```
