# List audit logs

GET //localhost:8080/api/v1/audit-logs

Cursor-paginated audit logs. Team/Enterprise/Contact tier. owner/admin/viewer.

Reference: https://api.alephant.io/api-reference/saa-s-api/audit-logs/list-audit-logs

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: saas-openapi
  version: 1.0.0
paths:
  /api/v1/audit-logs:
    get:
      operationId: list-audit-logs
      summary: List audit logs
      description: >-
        Cursor-paginated audit logs. Team/Enterprise/Contact tier.
        owner/admin/viewer.
      tags:
        - subpackage_auditLogs
      parameters:
        - name: cursor
          in: query
          description: Cursor
          required: false
          schema:
            type: string
        - name: limit
          in: query
          description: Limit (default 20, max 200)
          required: false
          schema:
            type: integer
        - name: Authorization
          in: header
          description: Bearer {access_token}
          required: true
          schema:
            type: string
        - name: X-Workspace-Id
          in: header
          description: Workspace UUID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'data: AuditLogEntry[], meta: CursorMeta'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/audit-logs_listAuditLogs_Response_200'
        '403':
          description: TIER_FEATURE_DISABLED or FORBIDDEN
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListAuditLogsRequestForbiddenError'
servers:
  - url: //localhost:8080
components:
  schemas:
    audit-logs_listAuditLogs_Response_200:
      type: object
      properties: {}
      title: audit-logs_listAuditLogs_Response_200
    ListAuditLogsRequestForbiddenError:
      type: object
      properties: {}
      title: ListAuditLogsRequestForbiddenError

```

## SDK Code Examples

```python
import requests

url = "https://localhost:8080/api/v1/audit-logs"

querystring = {"cursor":"eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0=","limit":"50"}

payload = {}
headers = {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890",
    "X-Workspace-Id": "a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c",
    "Content-Type": "application/json"
}

response = requests.get(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50';
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890',
    'X-Workspace-Id': 'a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c',
    'Content-Type': 'application/json'
  },
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", url, payload)

	req.Header.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890")
	req.Header.Add("X-Workspace-Id", "a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890'
request["X-Workspace-Id"] = 'a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50")
  .header("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890")
  .header("X-Workspace-Id", "a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890',
    'Content-Type' => 'application/json',
    'X-Workspace-Id' => 'a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890");
request.AddHeader("X-Workspace-Id", "a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.exampletoken1234567890",
  "X-Workspace-Id": "a3f1c9d2-4b7e-4f8a-9c3d-2e5f7b1a9d6c",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:8080/api/v1/audit-logs?cursor=eyJjdXJzb3IiOiIxMjM0NTY3ODkwIn0%3D&limit=50")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```