---
search:
  tags:
    - Environments
    - POST
seo:
  description: >-
    Returns the environment's log entries that match… Reference for the POST
    /project/{project_id}/environment/{environment_id}/logs endpoint in the
    Platform API.
sidebar:
  label: Query environment logs
  badge: POST
title: Query environment logs
type: openapi-operation
---
Returns the environment's log entries that match the query, read through Kapten's agent on its cluster.

`POST /project/{project_id}/environment/{environment_id}/logs`

**Request body** (`application/json`, required)

- `query` (string, required) — The user-provided LogsQL query fragment.
- `limit` (integer<int32>) — Maximum number of most recent log entries to return.

Request body example:

```json
{
  "query": "string",
  "limit": 200
}
```

**Responses**

- `200` — Environment logs retrieved successfully
- `default` — Error

Response example, 200:

```json
{
  "records": [
    {
      "msg": {},
      "time": "string",
      "level": "string",
      "project_id": "string",
      "environment_id": "string",
      "component_id": "string",
      "component_type": "string",
      "component_run_id": "string",
      "component_kind": "string",
      "source": "control_plane",
      "step": "string",
      "phase": "string",
      "backend": "string",
      "backend_step": "string",
      "run_status": "string",
      "duration_ms": 0,
      "error_kind": "string",
      "metadata": {},
      "event": "kapten.build.phase",
      "event_version": 0,
      "platform": "linux/amd64",
      "publication": "child_manifest"
    }
  ]
}
```
