# List logs

`GET /v1/logs`

Every request an API key has made, newest first, by method, outcome and time.

Needs the scope: `logs:read`

## Query parameters

- `q` (string): Text to search for. Only items that contain it are returned. Up to 40 characters.
- `limit` (integer): How many items to return, from 1 to 100. Without it you get 25.
- `offset` (integer): How many items to skip. Use it with `limit` to read the next page. Default: `0`.
- `after` (string): The id of the last item you have. The answer starts with the item that follows it, which reads a long list without skipping or repeating when it changes meanwhile. Up to 64 characters.
- `before` (string): The id of the first item you have. The answer ends with the item just before it. Give this or `after`, not both. Up to 64 characters.
- `range` (string): The period to look at: `today`, `week`, `month`, `year`, `all` or `custom`. Without it there is no limit in time. One of: `today`, `week`, `month`, `year`, `all`, `custom`.
- `from` (string): The first day of a `custom` period, as a date such as `2026-11-01`.
- `to` (string): The last day of a `custom` period, as a date such as `2026-11-30`.
- `method` (string): Only requests with this HTTP verb. One of: `GET`, `POST`, `PATCH`, `DELETE`.
- `outcome` (string): Only requests that ended this way: `success`, `client_error` or `server_error`. One of: `success`, `client_error`, `server_error`.
- `keyId` (string): Only requests made with this API key.
- `resourceId` (string): Only requests that made or changed the thing with this id, such as an email.
- `tool` (string): Only MCP requests that called this tool.

## Returns

- `object` ("list"): Always `list`.
- `data` (object[]): The items on this page.
- `data[].object` ("log"): Always `log`.
- `data[].id` (string): The id of the log entry.
- `data[].method` (string): The HTTP verb of the request. One of: `GET`, `POST`, `PATCH`, `DELETE`.
- `data[].path` (string): The path that was asked for.
- `data[].status` (integer): The HTTP status of the answer.
- `data[].outcome` (string): `success` for a 2xx answer, `client_error` for 4xx, `server_error` for 5xx. One of: `success`, `client_error`, `server_error`.
- `data[].durationMs` (number): How long the request took, in milliseconds.
- `data[].keyId` (string | null): The id of the API key that made it, or `null`.
- `data[].userAgent` (string): What the client called itself.
- `data[].requestId` (string): The id the answer carried in its request id header. Empty on an older entry.
- `data[].error` (object | null): Why the request failed, or `null` when it did not.
- `data[].error.type` (string): The kind of error, as in the answer.
- `data[].error.code` (string): The code of the error, as in the answer.
- `data[].error.message` (string): What the answer said was wrong.
- `data[].resource` (object | null): What a request that changed something made or changed, or `null`.
- `data[].resource.object` (string): The kind of thing, such as `email` or `domain`.
- `data[].resource.id` (string): Its id.
- `data[].tool` (string | null): The tool an MCP request called, such as `emails_send`, or `null`.
- `data[].createdAt` (string): When the request was made.
- `total` (integer): How many items match in all, on every page together.
- `hasMore` (boolean): Whether more items follow this page.

## Example

cURL:

```bash
curl "$OPENSEND_API_URL/v1/logs?outcome=client_error" \
  -H "Authorization: Bearer $OPENSEND_API_KEY"
```

TypeScript:

```ts
await opensend.logs.list({
  outcome: 'client_error',
})
```

CLI:

```bash
opensend logs list --outcome client_error
```

MCP:

```json
{
  "name": "logs_list",
  "arguments": {
    "outcome": "client_error"
  }
}
```

Answer:

```json
{
  "object": "list",
  "data": [
    {
      "object": "log",
      "id": "log_07",
      "method": "POST",
      "path": "/emails",
      "status": 422,
      "outcome": "client_error",
      "durationMs": 9,
      "keyId": "key_01",
      "userAgent": "curl/8.7.1",
      "requestId": "req_07",
      "error": {
        "type": "validation_error",
        "code": "email_domain_missing",
        "message": "The from address must be on a domain this workspace has added and verified."
      },
      "resource": null,
      "tool": null,
      "createdAt": "2026-11-27T09:28:00.000Z"
    },
    {
      "object": "log",
      "id": "log_05",
      "method": "POST",
      "path": "/emails",
      "status": 422,
      "outcome": "client_error",
      "durationMs": 17,
      "keyId": "key_01",
      "userAgent": "curl/8.7.1",
      "requestId": "req_05",
      "error": {
        "type": "validation_error",
        "code": "email_domain_missing",
        "message": "The from address must be on a domain this workspace has added and verified."
      },
      "resource": null,
      "tool": null,
      "createdAt": "2026-11-27T09:23:00.000Z"
    },
    {
      "object": "log",
      "id": "log_04",
      "method": "DELETE",
      "path": "/api-keys/key_09",
      "status": 404,
      "outcome": "client_error",
      "durationMs": 21,
      "keyId": "key_01",
      "userAgent": "curl/8.7.1",
      "requestId": "req_04",
      "error": {
        "type": "not_found_error",
        "code": "not_found",
        "message": "There is no api_key with the id key_09."
      },
      "resource": null,
      "tool": null,
      "createdAt": "2026-11-27T09:21:00.000Z"
    }
  ],
  "total": 3,
  "hasMore": false
}
```
