---
title: "Get lines around a site's log line"
url: https://docs.corefinity.com/api/reference/logs/get-site-log-context
type: endpoint
last_updated: 2026-11-13
feature: logs
related:
  - https://docs.corefinity.com/guides/sites/logs-and-monitoring/logs.md
  - https://docs.corefinity.com/mcp/tools/corestack_logs_context_get.md
---
# Get lines around a site's log line

Answers one line with the lines before and after it in the same stream, each list oldest first. Name the
line as `<stream_id>,<time>`, both taken from a line a search answered.

```http
GET /api/corestack/sites/{site}/logs/context
```

- Scope: `read`
- Two-factor: required on your account (all)
- Rate limit: 150 a minute
- Try it in the console: on

## Path parameters

- `site` (integer, required): The id of a site row. A website's production site and each of its environments has its own id. Digits only.

## Query parameters

- `line` (string, required): The line, as `<stream_id>,<time>`.
- `before` (integer): How many earlier lines to answer.
- `after` (integer): How many later lines to answer.
- `environment_id` (integer): The site row id of another environment of the same website to read instead of `{site}`.
- `scope` (string): `env` reads the one environment. `site` reads every environment of the website that you can see.

## Request

### curl

```bash
curl 'https://manage.corefinity.com/api/corestack/sites/1042/logs/context?line=00000001000000006754af9632a2745e85c293e5aac08633%2C2026-11-03T09%3A53%3A00Z' \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json"
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->get('https://manage.corefinity.com/api/corestack/sites/1042/logs/context?line=00000001000000006754af9632a2745e85c293e5aac08633%2C2026-11-03T09%3A53%3A00Z');

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/logs/context?line=00000001000000006754af9632a2745e85c293e5aac08633%2C2026-11-03T09%3A53%3A00Z', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
  },
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.get(
    "https://manage.corefinity.com/api/corestack/sites/1042/logs/context?line=00000001000000006754af9632a2745e85c293e5aac08633%2C2026-11-03T09%3A53%3A00Z",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
)

data = res.json() if res.content else None
```

## Responses

### 200 The line and its neighbours.

```json
{
  "after": [
    {
      "fields": {
        "level": "info",
        "method": "GET",
        "src": "nginx-access",
        "status": 200
      },
      "msg": "GET /products/4 200",
      "source": "web-access",
      "stream_id": "00000001000000006754af9632a2745e85c293e5aac08633",
      "time": "2026-11-03T09:54:00Z"
    }
  ],
  "before": [
    {
      "fields": {
        "level": "info",
        "method": "GET",
        "src": "nginx-access",
        "status": 200
      },
      "msg": "GET /products/2 200",
      "source": "web-access",
      "stream_id": "00000001000000006754af9632a2745e85c293e5aac08633",
      "time": "2026-11-03T09:52:00Z"
    }
  ],
  "line": {
    "fields": {
      "level": "info",
      "method": "GET",
      "src": "nginx-access",
      "status": 200
    },
    "msg": "GET /products/3 200",
    "source": "web-access",
    "stream_id": "00000001000000006754af9632a2745e85c293e5aac08633",
    "time": "2026-11-03T09:53:00Z"
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the scope (`scope_required`, with the `scope` to use), or your company requires two-factor authentication and you have not set it up. For routes outside Managed Clusters.

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, logs are not on for your company (`feature_off`), or the line is not one of yours or is older than your logs are kept for (`line_not_found`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 The read cannot be made. `reason` says why: `logs_not_collected` (logs are not collected for this environment yet), `logs_unavailable` (this source starts once the environment's next platform update has applied), `logs_range` (`from` is before the time your logs are kept for) or `query_too_wide` (the query reads too much: add a source or narrow the time range).

```json
{
  "code": "logs_not_collected",
  "message": "Logs are not being collected for this environment yet",
  "reason": "logs_not_collected"
}
```

### 422 A field is missing or wrong. `field` names the first one and `errors` lists every one. Beside the request's own fields, `errors` can name `query` (the LogsQL is not valid, is over 4 KB, uses the `stream_context` pipe or the `time_offset` option, or is an aggregating query sent to an export), `filters.<name>` (a filter is not valid), `filters_max` (too many text or field filters), `cursor` (the cursor is not this request's or this token's) and `saved_max` (you already keep 50 saved queries).

```json
{
  "code": "invalid",
  "errors": {
    "query": [
      "Keep the query under 4 KB."
    ]
  },
  "field": "query",
  "message": "Keep the query under 4 KB.",
  "reason": "invalid"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 503 The logs store did not answer (`logs_cluster_unavailable`), or it is serving as many reads as it can (`logs_busy`, with `Retry-After`). The request itself is fine: try again shortly.

```json
{
  "code": "logs_busy",
  "message": "Logs are busy at the moment. Try again in a few seconds",
  "reason": "logs_busy"
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 404 | `line_not_found` | The log line is no longer available. Search again. |
| 409 | `logs_not_collected` | Logs are not being collected for the environment yet. Try again later, or contact support. |
| 409 | `logs_range` | The time range is outside the days logs are kept for. Choose a range inside the days the message names. |
| 409 | `logs_unavailable` | Logs could not be read, or are not collected for the site yet. Read the message; try again shortly. |
| 409 | `query_too_wide` | The search covers too much. Choose a shorter range or a narrower search. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 503 | `logs_busy` | Logs are busy at the moment. Try again in a few seconds. |
| 503 | `logs_cluster_unavailable` | Logs are not available at the moment. Try again shortly. |

## The same task elsewhere

- Guide: [Logs](https://docs.corefinity.com/guides/sites/logs-and-monitoring/logs.md)
- MCP tool: [`corestack_logs_context_get`](https://docs.corefinity.com/mcp/tools/corestack_logs_context_get.md)
