# Retrieve a log line (/docs/api-reference/logs/get-log)

One line of the API key's environment log.

`GET https://api.coss.com/v1/logs/{id}`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Path parameters

- `id` (string, required): The log line's id.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.logs.get("log_01k7c8m4q2f3e9v6t5r1n0p8yz");
```

HTTP:

```sh
curl -X GET "https://api.coss.com/v1/logs/log_01k7c8m4q2f3e9v6t5r1n0p8yz" \
  -H "Authorization: Bearer $COSS_API_KEY"
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.logs.get(
    id="log_01k7c8m4q2f3e9v6t5r1n0p8yz",
)
```

Go:

```go
import (
	"context"

	coss "github.com/cosscom/coss-go"
	cossclient "github.com/cosscom/coss-go/client"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &coss.GetLogsRequest{
    ID: "log_01k7c8m4q2f3e9v6t5r1n0p8yz",
}
client.Logs.Get(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.logs.get(id: "log_01k7c8m4q2f3e9v6t5r1n0p8yz")
```

PHP:

```php
<?php

use Coss\Coss;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->logs->get(
    'log_01k7c8m4q2f3e9v6t5r1n0p8yz',
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.logs.requests.GetLogsRequest;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.logs().get(
    "log_01k7c8m4q2f3e9v6t5r1n0p8yz",
    GetLogsRequest
        .builder()
        .build()
);
```

.NET:

```csharp
using Coss;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Logs.GetAsync(new GetLogsRequest { Id = "log_01k7c8m4q2f3e9v6t5r1n0p8yz" });
```

## Response 200

The log line.

- `object` ("log", required)
- `id` (string, required)
- `occurred_at` (string, required, date-time): When it happened.
- `source` ("api" | "email" | "webhook" | "risk" | "smtp" | "sms" | "sign" | "verify" | "forms" | "scheduling", required): `api`: a request to the API. `email`: an email event. `webhook`: a delivery attempt. `risk`: a risk assessment or its feedback. `smtp`: a message submitted to the SMTP relay. `sms`: an SMS event.
- `level` ("info" | "warning" | "error", required): `error`: 5xx responses, bounces, complaints, failures. `warning`: 4xx responses, delays, suppressions, failed webhook attempts that will be retried. `info`: everything else.
- `type` (string, required): `api.request`, `webhook.attempt`, `webhook.forward` (an event `coss listen` forwarded), or an email event type such as `email.delivered`.
- `message` (string, required): A one-line summary.
- `request_id` (string | null, required): The `X-Request-Id` of the API request this line belongs to.
- `api_key_id` (string | null, required): The API key that made the request. `null`: not an API request.
- `method` (string | null, required): The HTTP method. `null`: not an HTTP line.
- `path` (string | null, required): The request's path. `null`: not an API request.
- `route` (string | null, required): The matched route, e.g. `/v1/emails/:id`.
- `status_code` (integer | null, required): The API response status, or the webhook endpoint's response status.
- `duration_ms` (integer | null, required): How long it took, in milliseconds. `null`: not timed.
- `client_ip` (string | null, required): The caller's address. `null`: not an API request.
- `user_agent` (string | null, required): The caller's `User-Agent`. `null`: not sent.
- `error_code` (string | null, required): The error's `code`. `null`: no error.
- `resource_type` (string | null, required): What the line is about: `email`, `domain`, `webhook_endpoint`…
- `resource_id` (string | null, required): The id of what it's about. `null`: nothing in particular.
- `recipient` (string | null, required): The recipient an email event is about. `null`: none.
- `attributes` (map of any, required): Details: redacted request and response bodies for API requests (secrets, attachment contents and long strings are never stored), event data for emails and webhooks.

Example:

```json
{
  "object": "log",
  "id": "log_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "occurred_at": "2026-01-15T09:30:00.000Z",
  "source": "api",
  "level": "info",
  "type": "api.request",
  "message": "POST /v1/emails 202",
  "request_id": "req_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "api_key_id": "key_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "method": "POST",
  "path": "/v1/emails",
  "route": "/v1/emails",
  "status_code": 202,
  "duration_ms": 48,
  "client_ip": "203.0.113.7",
  "user_agent": "coss-node/0.1.0",
  "error_code": null,
  "resource_type": "email",
  "resource_id": "email_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "recipient": null,
  "attributes": {
    "request": {
      "body": {
        "from": "hello@example.com",
        "to": [
          "user@example.com"
        ],
        "subject": "Hi"
      }
    },
    "response": {
      "body": {
        "object": "email",
        "id": "email_01k7c8m4q2f3e9v6t5r1n0p8yz"
      }
    }
  }
}
```

## Errors

- `400`: The `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `404`: No log line with this id exists in the API key's environment (`not_found`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).