# List logs

URL: https://docs.hanzo.ai/docs/openapi/function/get-function-by-name-logs

> The output of a function's most recent run — its error text when that run failed, else what it printed.

`GET /v1/function/{name}/logs`

> [Function →](https://docs.hanzo.ai/docs/openapi/function) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                |
| ------------- | ---------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/function/{name}/logs` |
| **Method**    | `GET`                                          |
| **Operation** | `get_function_by_name_logs`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`         |

The output of a function's most recent run — its error text when that
run failed, else what it printed.

It is the LAST run only, and it is empty when the function has never run. There
is no log retention behind this beyond the recorded invocation itself.

## Request

1 field.

| Field  | In   | Type   | Required | Description                         |
| ------ | ---- | ------ | -------- | ----------------------------------- |
| `name` | path | string | yes      | Name is the function the URL names. |

## Response

| Status    | Body              | Meaning |
| --------- | ----------------- | ------- |
| `200`     | function.logLines | ok      |
| `default` | problem-details   | refused |

`200` body — 1 field.

| Field  | In   | Type   | Always | Description                                                    |
| ------ | ---- | ------ | ------ | -------------------------------------------------------------- |
| `logs` | body | string | —      | Logs is that run's error text when it failed, else its output. |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo function logs <name>
```

**SDK**

**.ts**

```ts
import { Configuration, FunctionApi } from 'hanzoai';

const api = new FunctionApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getFunctionByNameLogs({ name: 'name' });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import FunctionApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = FunctionApi(client).get_function_by_name_logs(name='name')
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.FunctionAPI.GetFunctionByNameLogs(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, function_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = function_api::get_function_by_name_logs(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.FunctionApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new FunctionApi(client).getFunctionByNameLogs();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/function/<name>/logs \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **function** through the `function` tool, which names its 10 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_functions"
         }
       }
     }'
```

---

[Function API](https://docs.hanzo.ai/docs/openapi/function) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
