# Tail function logs

> Fetch invocation logs for a function. Logs are paginated via nextToken. Pass startTime / endTime (Unix epoch milliseconds) to bound the window, or filterPattern to filter messages.

`GET https://api.zavu.dev/v1/functions/{functionId}/logs`

Fetch invocation logs for a function. Logs are paginated via `nextToken`. Pass `startTime` / `endTime` (Unix epoch milliseconds) to bound the window, or `filterPattern` to filter messages.

## Parameters

- `functionId` (path, string, required): Zavu Function ID.
- `limit` (query, integer)
- `nextToken` (query, string)
- `startTime` (query, integer<int64>): Start of the log window in Unix epoch milliseconds.
- `endTime` (query, integer<int64>): End of the log window in Unix epoch milliseconds.
- `filterPattern` (query, string)

## Responses

### 200

Log events.

- `events` (object[], required)
  - `timestamp` (string<date-time>, required)
  - `message` (string, required)
- `nextToken` (string, nullable): Pass to the next request to fetch the following page of logs.

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 404

Function not found.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X GET "https://api.zavu.dev/v1/functions/function_abc123/logs" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.functions.tailLogs("function_abc123");

console.log(result);
```
