# AuditLogs

## Overview

### Available Operations

* [List](#list) - List all Audit Logs
* [Export](#export) - Initiate an asynchronous export of audit logs based on the provided filters. The export file will be generated and available for download. Use 'Get details of Audit Logs export history by ID' API to retrieve the download URL.
* [ListExportHistory](#listexporthistory) - List all Audit Logs export history
* [GetExportHistoryByID](#getexporthistorybyid) - Get details of Audit Logs export history by ID
* [GetByID](#getbyid) - Get audit log by ID

## List

List all Audit Logs Returns array of audit logs for given team and filters

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"github.com/solarwinds/squadcast-sdk-go/types"
	"github.com/solarwinds/squadcast-sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.AuditLogs.List(ctx, operations.AuditLogsListAuditLogsRequest{
        PageSize: 832442,
        PageNumber: 555332,
        StartDate: types.MustDateFromString("2023-03-04"),
        EndDate: types.MustDateFromString("2024-08-07"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.V3AuditLogsListAuditLogsResponse != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}
```

### Parameters

| Parameter | Type                                                                                                        | Required             | Description                                |
| --------- | ----------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------ |
| `ctx`     | [context.Context](https://pkg.go.dev/context#Context)                                                       | :heavy\_check\_mark: | The context to use for the request.        |
| `request` | [operations.AuditLogsListAuditLogsRequest](/go-sdk/docs/models/operations/auditlogslistauditlogsrequest.md) | :heavy\_check\_mark: | The request object to use for the request. |
| `opts`    | \[][operations.Option](/go-sdk/docs/models/operations/option.md)                                            | :heavy\_minus\_sign: | The options for this request.              |

### Response

[**\*operations.AuditLogsListAuditLogsResponse**](/go-sdk/docs/models/operations/auditlogslistauditlogsresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## Export

Export Audit logs Initiates export of audit logs based on provided filters

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"github.com/solarwinds/squadcast-sdk-go/types"
	"github.com/solarwinds/squadcast-sdk-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.AuditLogs.Export(ctx, components.V3AuditLogsExportAuditLogsRequest{
        Filters: components.Filters{
            StartDate: types.MustDateFromString("2025-07-29"),
            EndDate: types.MustDateFromString("2023-09-09"),
        },
        Name: "<value>",
        ExportType: components.ExportTypeJSON,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.V3AuditLogsExportAuditLogsResponse != nil {
        // handle response
    }
}
```

### Parameters

| Parameter | Type                                                                                                                | Required             | Description                                |
| --------- | ------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------ |
| `ctx`     | [context.Context](https://pkg.go.dev/context#Context)                                                               | :heavy\_check\_mark: | The context to use for the request.        |
| `request` | [components.V3AuditLogsExportAuditLogsRequest](/go-sdk/docs/models/components/v3auditlogsexportauditlogsrequest.md) | :heavy\_check\_mark: | The request object to use for the request. |
| `opts`    | \[][operations.Option](/go-sdk/docs/models/operations/option.md)                                                    | :heavy\_minus\_sign: | The options for this request.              |

### Response

[**\*operations.AuditLogsExportAuditLogsResponse**](/go-sdk/docs/models/operations/auditlogsexportauditlogsresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## ListExportHistory

List all Audit Logs export history Returns array of audit logs export history

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.AuditLogs.ListExportHistory(ctx, 159672, 351281)
    if err != nil {
        log.Fatal(err)
    }
    if res.V3AuditLogsListAuditLogsExportHistoryResponse != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}
```

### Parameters

| Parameter    | Type                                                             | Required             | Description                         |
| ------------ | ---------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`        | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request. |
| `pageSize`   | `int64`                                                          | :heavy\_check\_mark: | N/A                                 |
| `pageNumber` | `int64`                                                          | :heavy\_check\_mark: | N/A                                 |
| `opts`       | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.AuditLogsListAuditLogsExportHistoryResponse**](/go-sdk/docs/models/operations/auditlogslistauditlogsexporthistoryresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## GetExportHistoryByID

Get details of Audit Logs export history by ID Returns audit log export history details for the specified ID

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.AuditLogs.GetExportHistoryByID(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.V3AuditLogsGetAuditLogExportHistoryByIDResponse != nil {
        // handle response
    }
}
```

### Parameters

| Parameter | Type                                                             | Required             | Description                         |
| --------- | ---------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`     | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request. |
| `id`      | `string`                                                         | :heavy\_check\_mark: | N/A                                 |
| `opts`    | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.AuditLogsGetAuditLogsExportHistoryByIDResponse**](/go-sdk/docs/models/operations/auditlogsgetauditlogsexporthistorybyidresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## GetByID

Get audit log by ID Returns audit log details for the specified ID

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.AuditLogs.GetByID(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.V3AuditLogsGetAuditLogByIDResponse != nil {
        // handle response
    }
}
```

### Parameters

| Parameter | Type                                                             | Required             | Description                         |
| --------- | ---------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`     | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request. |
| `id`      | `string`                                                         | :heavy\_check\_mark: | N/A                                 |
| `opts`    | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.AuditLogsGetAuditLogByIDResponse**](/go-sdk/docs/models/operations/auditlogsgetauditlogbyidresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/sdks/auditlogs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
