## Get agent deployment logs

`client.Deploy.Logs(ctx, deploymentID, query) (*DeployLogsResponse, error)`

**get** `/v5/agentex/deployments/{deployment_id}/logs`

Get structured deployment log lines, with cursor-based pagination.

Returns the deployment's log lines in time order together with a `next_cursor`
and a `has_more` flag. Poll to stream logs incrementally: make the first call
without a cursor, then pass the previous response's `next_cursor` as `cursor` on
each subsequent call, stopping once the deployment reaches a terminal status.
Unlike `GET /v5/agentex/deployments/{deployment_id}`, which returns the
deployment's status and Kubernetes events, this returns the raw log output from
the deploy process. Returns 404 if no deployment with this ID exists for the
caller's account.

### Parameters

- `deploymentID string`

- `query DeployLogsParams`

  - `Cursor param.Field[string]`

    Cursor from previous response's next_cursor field

  - `Limit param.Field[int64]`

    Maximum number of log lines to return

### Returns

- `type DeployLogsResponse struct{…}`

  Response containing structured deployment log lines with cursor-based pagination.

  The CLI can poll this endpoint to stream logs incrementally:

  1. First call: no after_id
  1. Subsequent calls: after_id=next_cursor from previous response
  1. Stop polling when has_more is False and the deployment reaches a terminal status

  - `DeploymentID string`

    The deployment ID

  - `HasMore bool`

    True if there may be more lines beyond this page (len(lines) == limit).

  - `Lines []DeployLogsResponseLine`

    Structured log lines

    - `ID string`

      Unique log line identifier (time-ordered)

    - `Message string`

      Log line content after the K8s timestamp

    - `LogLevel string`

      Parsed log level (INFO, ERROR, WARN, DEBUG, FATAL)

    - `Timestamp Time`

      Parsed K8s log timestamp

  - `NextCursor string`

    Cursor for the next page. Pass this as the after_id query parameter to get subsequent logs.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  response, err := client.Deploy.Logs(
    context.TODO(),
    "deployment_id",
    sgpdev.DeployLogsParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.DeploymentID)
}
```

#### Response

```json
{
  "deployment_id": "deployment_id",
  "has_more": true,
  "lines": [
    {
      "id": "id",
      "message": "message",
      "log_level": "log_level",
      "timestamp": "2019-12-27T18:11:19.117Z"
    }
  ],
  "next_cursor": "next_cursor"
}
```
