# Making Requests

## Request Format

All requests use standard HTTP methods. Currently the API supports **GET** for reading data. Write operations will be added in future versions.

Include the following headers with every request:

```
Authorization: Bearer YOUR_API_KEY
Accept: application/json
```

For endpoints that accept a request body (future POST/PUT/PATCH), also include:

```
Content-Type: application/json
```

## Response Format

All responses return JSON with a consistent structure.

**Successful responses** wrap data in a `data` field:

```json
{
  "data": {
    "id": "abc123",
    "name": "my-server",
    "status": "RUNNING"
  }
}
```

**List responses** return an array inside `data`:

```json
{
  "data": [
    { "id": "abc123", "name": "server-1" },
    { "id": "def456", "name": "server-2" }
  ]
}
```

The **ping** endpoint is an exception — it returns a flat object without the `data` wrapper.

## Error Responses

Errors return a JSON object with `error`, `code`, and `status` fields:

```json
{
  "error": "VPS not found",
  "code": "NOT_FOUND",
  "status": 404
}
```

### Common Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | `BAD_REQUEST` | Invalid request parameters |
| 400 | `INVALID_ID` | The resource ID in the URL path is not a valid format |
| 401 | `UNAUTHORIZED` | Missing or invalid API key |
| 403 | `INSUFFICIENT_SCOPE` | API key lacks required permissions |
| 404 | `NOT_FOUND` | Resource does not exist or is not accessible |
| 429 | `RATE_LIMITED` | Rate limit exceeded |
| 500 | `INTERNAL_ERROR` | Unexpected server error |

## Request ID

Every response includes an `X-Request-Id` header. You can also send your own via the request header:

```
X-Request-Id: my-custom-id-123
```

If not provided, the server generates one automatically. Include request IDs when contacting support to help trace issues.

## Rate Limit Headers

Every response includes rate limit information:

```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1711540800
```

See the [Authorization](/en/docs/api/authorization/) page for details.

## HTTPS Only

All API requests must use HTTPS. HTTP requests will be redirected.

## Base URL

```
https://site.quest/api/v1
```
