---
title: "Read server code"
method: GET
path: "/api/{ns}/{id}/lambda"
tags: ["Brew Lambda"]
---

# Read server code

`GET /api/{ns}/{id}/lambda`

## Request

- Base URL: `https://brewpage.app`
- URL: `https://brewpage.app/api/{ns}/{id}/lambda`
- Auth: one of:
  - API key in header `X-Owner-Token`
  - API key in header `X-Manage-Key`

The code (lambda.js), its version, handlers and endpoints, the owner switch, "Reads your other pages", counters, usage against its caps and the newest 20 runs with their log lines. Logs hold what visitors sent: treat them as untrusted text.

## Path parameters

- `ns` string, required
- `id` string, required

## Headers

- `X-Owner-Token` unknown
- `X-Manage-Key` unknown

## Response `200`

Server code view

- LambdaView: Server code of an HTML page or site: switches, code, counters, usage and the newest runs (owner only).
  - `enabled` boolean, required: Owner switch. Off: your code does not run; saves follow the page's list rules.
  - `pausedByBrewPage` boolean, required: Paused by BrewPage: the code does not run; while enabled, saves of a page with beforeWrite are refused until lifted. With enabled false, saves follow the page's list rules.
  - `running` boolean, required: The code runs now: on, not paused and server code available.
  - `accountRead` boolean, required: "Reads your other pages" (bp.account): off by default, off again after any code, token or profile change.
  - `accountReadAllowed` boolean, required: This request may change accountRead: it carries the profile that published the code.
  - `version` integer, required: Code version: +1 for each changed lambda.js
  - `file` string, required: Always lambda.js
  - `source` string, required: The text of lambda.js
  - `handlers` string[], required: Exported handlers: onEntry, onComment, beforeWrite
  - `endpoints` string[], required: Own endpoint names (at most 2), called by the page with bp.lambda(name, body)
  - `counters` unknown, required
  - `usage` LambdaUsage, required: Usage windows: this page's UTC hour (runs), the profile's UTC day (runs, run time, fetches)
    - `hour` LambdaWindow, required: Runs, run time in milliseconds (server clock) and fetch requests of one window; absent = not counted there
      - `runs` integer, required
      - `wallMs` integer
      - `fetches` integer
    - `accountDay` LambdaWindow: Runs, run time in milliseconds (server clock) and fetch requests of one window; absent = not counted there
      - `runs` integer, required
      - `wallMs` integer
      - `fetches` integer
  - `limits` LambdaUsage, required: Caps of the same windows as usage, as they apply to this page now
    - `hour` LambdaWindow, required: Runs, run time in milliseconds (server clock) and fetch requests of one window; absent = not counted there
      - `runs` integer, required
      - `wallMs` integer
      - `fetches` integer
    - `accountDay` LambdaWindow: Runs, run time in milliseconds (server clock) and fetch requests of one window; absent = not counted there
      - `runs` integer, required
      - `wallMs` integer
      - `fetches` integer
  - `runs` LambdaRunView[], required: Newest finished runs, newest first
    - `id` integer, required: Run id
    - `trigger` string, required: entry, comment, before_write or endpoint
    - `handler` string, required: Handler or endpoint name
    - `outcome` string, required: ok, threw, cpu, wall, memory, stack, host_calls, output, crash, busy, unavailable, quota, off, lost or gone
    - `startedAt` string, date-time
    - `wallMs` integer
    - `calls` integer
    - `fetches` integer
    - `version` integer: Code version that ran
    - `error` string: Error name, message and stack, at most 2 KB
    - `log` string: console lines of the run, at most 16 KB
  - `nextOffset` integer: offset for GET .../lambda/runs to read older runs; absent when none
  - `updatedAt` string, date-time, required

## Other responses

- `403`: Owner token revoked or expired; or OWNER_AUTHORIZATION_FAILED: a public publication you do not own
- `404`: PUBLICATION_UNAVAILABLE: no such HTML page or site, not yours, hidden or expired; or LAMBDA_NOT_FOUND: the page has no server code
- `429`: STATE_RATE_LIMITED: too much at once; wait Retry-After
- `503`: LAMBDA_UNAVAILABLE: server code is switched off for now; wait Retry-After

## Changes

- **2026-12-02** `04a8f351c1aa`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/brewpage/apis/brewpage-api/changes/api/:ns/:id/lambda/get.md)

---

[API](https://skmtc.dev/brewpage/apis/brewpage-api.md) - [All operations](https://skmtc.dev/brewpage/apis/brewpage-api/llms.txt) - [OpenAPI document](https://skmtc.dev/brewpage/apis/brewpage-api/revisions/78d2720a18a9?raw)
