# get_site_logs

Source: https://modulify.ai/docs/api/code/get-site-logs

Reads the recent server logs of a site, the same stream the Logs panel shows.

- Title: Read the site server logs
- Scope: `logs:read`
- Access: Read only
- Endpoint: `POST /v1/get_site_logs`

Pass `preview` for the development machine that runs while someone is building, or `production` for the published site. Up to 300 lines come back newest last, each prefixed with its timestamp where the line carries one. A site with no machine running answers with a single line saying so rather than an error, so open the preview or publish first.

Nothing is stored between calls. The first call after a quiet spell returns only what is in flight at that moment, and the buffer fills toward its cap only while you keep reading, so poll across a few calls rather than expecting one to hold the history.

It answers why a site is erroring, whether an API route ran and what the server printed, so read it after a change rather than guessing from the code. Logs carry whatever the site prints, which can include values read from environment variables, and the tool tells the client never to repeat a log line anywhere it would be published. See [Logs](https://modulify.ai/docs/editor/logs).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/get_site_logs`, sending the inputs below as a JSON object. The token needs the `logs:read` scope.

It only reads and changes nothing, so retrying it is safe.

```bash
curl -X POST https://api.modulify.ai/v1/get_site_logs \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID"}'
```

Over MCP, the same method is the [get_site_logs tool](https://modulify.ai/docs/mcp/code/get-site-logs).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `environment` | string | No | `preview` for the machine behind the live preview, or `production` for the published site. Defaults to `preview`, and any other value is refused before the tool runs. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.