*Cloud › Logs and shell*

# Stream a service's logs

```http
GET https://devapi.dispralabs.com/v1/cloud/services/:svc/logs/stream
```

Streams what the service's live deployment writes, as Server-Sent Events. It starts with the newest 100 lines (`tail` to choose 0 to 750), then follows.

Each line is `event: line` with `{at, level, message, replica}`; a comment is sent every 15 seconds. If more than 750 lines arrive at once, the newest 750 are sent after `event: gap` with how many were skipped. Reconnect with `since` or `Last-Event-ID` to continue where you left off.

Needs a key with `read` access or more.

- **Authentication:** Secret key (send it as `Authorization: Bearer <key>`)

## Parameters

- `svc` (string, required): The service's id. Example: `svc_01jdk3n2f4g6h8j0k2l4z6x8ca`
- `tail` (number, optional): Start with the newest N lines, 0 to 750 (default 100). Example: `200`
- `since` (timestamp, optional): Continue after this line's time.

## Returns

- **200**: A text/event-stream.

## Errors

| Status | Code | When |
|---|---|---|
| 400 | [invalid_tail](https://docs.dispralabs.com/errors.md#invalid_tail) | tail is 0 to 750. |
| 404 | [not_found](https://docs.dispralabs.com/errors.md#not_found) | No such object in the key's project (or environment). |

## Request samples

### Dispra Cloud CLI

```bash
dcloud logs api -n 200
```

### cURL

```bash
curl "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200" \
  -H "Authorization: Bearer dsp_live_YOUR_KEY"
```

### Node

```javascript
const res = await fetch("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200", {
  method: "GET",
  headers: { Authorization: "Bearer dsp_live_YOUR_KEY" },
});
console.log(await res.json());
```

### Python

```python
import requests
res = requests.request("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream", headers={"Authorization": "Bearer dsp_live_YOUR_KEY"}, params={"tail": "200"})
print(res.json())
```

### Go

```go
req, _ := http.NewRequest("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200", nil)
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
res, _ := http.DefaultClient.Do(req)
```

## Responses

### 200

```json
{}
```

### 400 invalid_tail

```json
{
  "error": {
    "code": "invalid_tail",
    "message": "tail is 0 to 750.",
    "request_id": "req_7f3a9c21d84be056"
  }
}
```

### 404 not_found

```json
{
  "error": {
    "code": "not_found",
    "message": "No such object in the key's project (or environment).",
    "request_id": "req_7f3a9c21d84be056"
  }
}
```

## Related

- [Log search and streaming](https://docs.dispralabs.com/features/log-search-and-streaming.md)
