List a Space's runtime logs - Spacefast Docs

List a Space's runtime logs

Returns the lines the Space’s own code wrote in the requested window, newest first: a Zero capsule’s queries and mutations, a PHP function, or a functions worker’s handler. Requires versions:read, and a static Space writes none. Narrow with requestId or handlerName, and page with cursor; an empty page with hasMore: true means the scan stopped early, not that the window is exhausted. A line is shipped off the box and indexed before it can be read back, so a line a request wrote a moment ago is not here yet.

GET /v1/spaces/{spaceId}/logs/runtime

Authorization

Authorization Bearer token · header required

Authorization: Bearer <key> with the Space key ( sfc_ prefix) of an unclaimed Space. The same key is the fragment of the claim URL and the token in the Space's /__/ <key> sign-in URL.

or

Authorization Bearer token · header required

Authorization: Bearer <token> with an API key (sfa_ prefix), an OAuth access token, a session token, or a Space machine credential (sfm_ prefix).

Path parameters

spaceId string required

Query parameters

limit integer required

min 1 · max 100 · default: 20

cursor string

min length 1 · max length 4096

since string

matches ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:.\d+)?)?(?:Z))$

until string

requestId string

min length 1

handlerName string

min length 1

Responses

200 Response for status 200

$schema string

Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.

data object[] required

Array of object

Stable key for this line, minted by the runtime as it was written.

min length 1

When the line was written.

Level the writer logged at.

Allowed: debug``info``warn``error

Request being served when the line was written, or null.

Version whose code wrote the line, or null.

Zero mutation or functions handler that wrote the line, or null.

The line the handler wrote.

Structured fields the line carried. Empty when it carried none.

default: {}

nextCursor string | any required

Cursor for the next page. Null on the last page.

hasMore boolean required

True when another page exists.

Diagnostics about the list itself. log_retention_clamped gives the since actually used when the requested window reaches back past the plan's log retention.

Error Responses

$schema string

Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.

type string required

URL of the documentation page for this error. Derived from code.

title string required

Human-readable name of the error type. Derived from code.

status integer required

HTTP status of the response, repeated in the body.

min -9007199254740991 · max 9007199254740991

detail string required

What went wrong in this request.

code string required

Stable snake_case error code. Match on this, not on detail.

pointer string

RFC 6901 JSON Pointer to the request field or batch entry that failed, for example /files/37/path. Present on validation failures.

details object

Machine-readable context keyed by the error code.

suggestions string[]

Recovery steps safe to show to a person.

next string[]

Commands or API requests to run next, usable as written.

requestId string required

ID of this request, from the X-Request-Id header or generated. Quote it when contacting support.

Try it

Server

Base URL https://api.spacefast.com

Custom base URL

Overrides the selected server when set.

Parameters

spaceId path* limit query* cursor query since query until query requestId query handlerName query

Send

Request examples

cURL

curl -X GET "https://api.spacefast.com/v1/spaces/string/logs/runtime?limit=20" \
  -H "Authorization: Bearer YOUR_TOKEN"

JavaScript

const response = await fetch("https://api.spacefast.com/v1/spaces/string/logs/runtime?limit=20", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN"
  }
});

Python

import requests

response = requests.get(
    "https://api.spacefast.com/v1/spaces/string/logs/runtime?limit=20",
    headers={
        "Authorization": "Bearer YOUR_TOKEN"
    },
)

Response 200 default

{
  "$schema": "http://example.com",
  "data": [\
    {\
      "id": "string",\
      "timestamp": "2019-08-24T14:15:22Z",\
      "level": "debug",\
      "requestId": "string",\
      "versionId": "string",\
      "handlerName": "string",\
      "message": "string",\
      "metadata": {}\
    }\
  ],
  "pagination": {
    "nextCursor": "string",
    "hasMore": true
  },
  "warnings": [\
    {\
      "code": "string",\
      "severity": "info",\
      "message": "string",\
      "path": "string",\
      "provider": "infra",\
      "details": {\
        "property1": null,\
        "property2": null\
      },\
      "fix": "string",\
      "retryable": true\
    }\
  ]
}
{
  "$schema": "http://example.com",
  "type": "string",
  "title": "string",
  "status": -9007199254740991,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": [\
    "string"\
  ],
  "next": [\
    "string"\
  ],
  "requestId": "string"
}