# List Genie logs

> A Genie's logs by conversation: per message, what it was asked, what it answered, the tools it called and the tokens and cost used.

Source: https://docs.stacksync.com/api-reference/genies/list_genie_logs

`GET https://api.stacksync.com/v1/workspaces/{workspace_id}/genies/{genie_id}/logs`

- Operation: `list_genie_logs`
- Resource: Genies
- Access: read-only

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace. List the ones your key can reach with GET /v1/workspaces. |
| `genie_id` | string (uuid) | Yes | The Genie. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) | Yes | Data region of the resources: besg (Europe) or usnv (United States), as GET /v1/regions lists them. |
| `time_range_start` | string (date-time) \| null | No | Only logs at or after this time, ISO 8601 UTC |
| `time_range_end` | string (date-time) \| null | No | Only logs at or before this time, ISO 8601 UTC |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | array of object (GenieLogConversation) | Yes |  |
| `data[].conversation_id` | string | Yes |  |
| `data[].name` | string \| null | No |  |
| `data[].status` | string \| null | No |  |
| `data[].created_at` | string \| null | No |  |
| `data[].updated_at` | string \| null | No |  |
| `data[].tool_costs` | number, default 0 | No |  |
| `data[].token_costs` | object (GenieTokenCosts) \| null | No |  |
| `data[].token_costs.tokens_in` | integer, default 0 | No |  |
| `data[].token_costs.tokens_in_cached` | integer, default 0 | No |  |
| `data[].token_costs.tokens_out` | integer, default 0 | No |  |
| `data[].token_costs.tokens_thoughts` | integer, default 0 | No |  |
| `data[].token_costs.cost` | number, default 0 | No |  |
| `data[].messages` | array of object (GenieLogMessage) | Yes |  |
| `data[].messages[].message_id` | string | Yes |  |
| `data[].messages[].prompt` | string \| null | No | What the genie was asked |
| `data[].messages[].response` | string \| null | No | What it answered |
| `data[].messages[].started_at` | string \| null | No |  |
| `data[].messages[].finished_at` | string \| null | No |  |
| `data[].messages[].llm_call_count` | integer, default 0 | No |  |
| `data[].messages[].tool_calls` | integer, default 0 | No |  |
| `data[].messages[].tools_called` | array of string \| null | No |  |
| `data[].messages[].tool_costs` | number, default 0 | No |  |
| `data[].messages[].token_costs` | object (GenieTokenCosts) \| null | No |  |
| `data[].messages[].token_costs.tokens_in` | integer, default 0 | No |  |
| `data[].messages[].token_costs.tokens_in_cached` | integer, default 0 | No |  |
| `data[].messages[].token_costs.tokens_out` | integer, default 0 | No |  |
| `data[].messages[].token_costs.tokens_thoughts` | integer, default 0 | No |  |
| `data[].messages[].token_costs.cost` | number, default 0 | No |  |

## Example request

```bash
curl -X GET "https://api.stacksync.com/v1/workspaces/{workspace_id}/genies/{genie_id}/logs?region=besg" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY"
```

## Example response (200)

```json
{
  "data": [
    {
      "conversation_id": "<conversation_id>",
      "name": "<name>",
      "status": "<status>",
      "created_at": "<created_at>",
      "updated_at": "<updated_at>",
      "tool_costs": 0,
      "token_costs": {
        "tokens_in": 0,
        "tokens_in_cached": 0,
        "tokens_out": 0,
        "tokens_thoughts": 0,
        "cost": 0
      },
      "messages": [
        {
          "message_id": "<message_id>",
          "prompt": "<prompt>",
          "response": "<response>",
          "started_at": "<started_at>",
          "finished_at": "<finished_at>",
          "llm_call_count": 0,
          "tool_calls": 0,
          "tools_called": [
            "<tools_called>"
          ],
          "tool_costs": 0,
          "token_costs": {
            "tokens_in": 0,
            "tokens_in_cached": 0,
            "tokens_out": 0,
            "tokens_thoughts": 0,
            "cost": 0
          }
        }
      ]
    }
  ]
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string, "msg": string, "field": string \| null }` |
| 403 | Forbidden | `{ "error": string, "msg": string, "field": string \| null }` |
| 404 | Not Found | `{ "error": string, "msg": string, "field": string \| null }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List Genies](https://docs.stacksync.com/api-reference/genies/list_genies)
- [Get a Genie](https://docs.stacksync.com/api-reference/genies/get_genie)
- [Create a genie](https://docs.stacksync.com/api-reference/genies/create_genie)
- [Update a Genie](https://docs.stacksync.com/api-reference/genies/update_genie)
- [Delete a Genie](https://docs.stacksync.com/api-reference/genies/delete_genie)
- [Check a Genie email alias](https://docs.stacksync.com/api-reference/genies/check_genie_email_alias)