> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 获取工作区审计日志

GET https://api.elevenlabs.io/v1/workspace/audit-logs

返回工作区的审计日志。需要企业版及 audit_log_read 权限。

Reference: https://elevenlabs.io/docs/api-reference/workspace/audit-logs/list

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Query parameters

- `limit` (integer, optional, default: 50) — 每页最大条目数
- `cursor` (string, optional, nullable) — 下一页游标（来自上一次响应）
- `time_from_unix_ms` (integer, optional, nullable) — 仅包含此时间及之后的条目（自纪元起的毫秒数）
- `time_to_unix_ms` (integer, optional, nullable) — 仅包含此时间及之前的条目（自纪元起的毫秒数）
- `actor_uid` (string, optional, nullable) — 按执行者用户 ID 筛选
- `class_name` (string, optional, nullable) — 按 OCSF 事件类别名称筛选（例如 Account Change）
- `activity_name` (string, optional, nullable) — 按审计活动名称筛选（例如 Subscription Creation）

## Response

### 200

成功响应

- `entries` (list of WorkspaceAuditLogEntryResponse, required)
- `has_more` (boolean, required)
- `next_cursor` (string, required, nullable)

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### WorkspaceAuditLogEntryResponse

Audit log entry with Firestore document ID for API responses.

- `activity_id` (WorkspaceAuditLogEntryResponseActivityId, required) — 活动 ID
- `activity_name` (string, required) — 活动名称
- `status_id` (enum, required) — 操作状态
  - Allowed values: `0`, `1`, `2`, `99`
- `actor` (ActorModel, required) — 执行操作的主体
- `message` (string, required) — 人类可读的事件说明
- `id` (string, required) — Firestore 文档 ID
- `time_dt` (string, required) — 根据 'time' 派生的、采用易读 RFC 3339 格式的事件时间。
- `type_uid` (integer, required) — OCSF type_uid 为 class_uid * 100 + activity_id。
- `type_name` (string, required) — OCSF type_name 由 class_name 和 activity_name 组合而成。
- `metadata` (map from string to any, optional) — 事件元数据
- `time` (integer, optional) — 自纪元以来的事件时间，单位为毫秒
- `category_name` (string, optional, default: Identity & Access Management) — 事件类别
- `category_uid` (integer, optional, default: 3) — Category UID for IAM
- `class_name` (string, optional, default: ) — 事件类名称
- `class_uid` (integer, optional, default: 0) — 事件类 UID
- `severity_id` (enum, optional) — 严重程度
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `99`
- `device` (DeviceModel, optional, nullable) — 设备信息
- `http_request` (HttpRequestModel, optional, nullable) — HTTP 请求详情
- `unmapped` (map from string to any, optional) — Attributes not mapped to OCSF

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### WorkspaceAuditLogEntryResponseActivityId

活动 ID

- AccountChangeActivityId: enum
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `99`
- AuthenticationActivityId: enum
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `99`
- EntityManagementActivityId: enum
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `13`, `99`
- UserAccessManagementActivityId: enum
  - Allowed values: `0`, `1`, `2`, `99`
- GroupManagementActivityId: enum
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `99`

### ActorModel

OCSF Actor 对象——描述执行操作的实体。 规范：https://schema.ocsf.io/1.6.0/objects/actor

- `user` (UserModel, required) — 执行操作的用户。
- `app_name` (string, optional, nullable) — Client application or service name
- `app_uid` (string, optional, nullable) — Client application unique identifier
- `session` (map from string to any, optional, nullable) — 会话信息

### DeviceModel

设备信息。 规范：https://schema.ocsf.io/1.6.0/objects/device

- `ip` (string, optional, nullable) — IP 地址
- `hostname` (string, optional, nullable) — 设备主机名
- `type_id` (integer, optional, default: 99) — 设备类型 ID（99 = 未知）

### HttpRequestModel

HTTP 请求详情。 规范：https://schema.ocsf.io/1.6.0/objects/http_request

- `http_method` (string, required) — HTTP 方法（GET、POST 等）
- `url` (UrlModel, required) — 请求 URL 对象。
- `user_agent` (string, optional, nullable) — 用户代理字符串。
- `x_forwarded_for` (list of string, optional, nullable) — 以列表形式表示的 X-Forwarded-For 标头

### ValidationErrorLocItems

- string
- integer

### UserModel

OCSF User 对象。 规范：https://schema.ocsf.io/1.6.0/objects/user

- `name` (string, optional, nullable) — Username
- `uid` (string, optional, nullable) — 用户唯一标识符。
- `type_id` (enum, optional) — 账户类型标识符
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `99`
- `type` (string, optional, nullable) — 账户类型说明
- `email_addr` (string, optional, nullable) — 用户邮箱地址。
- `full_name` (string, optional, nullable) — 用户全名
- `domain` (string, optional, nullable) — 用户域名。

### UrlModel

OCSF URL 对象。 规范：https://schema.ocsf.io/1.6.0/objects/url

- `url_string` (string, optional, nullable) — 完整 URL 字符串
- `scheme` (string, optional, nullable) — URL 协议（例如 https）。
- `hostname` (string, optional, nullable) — URL 主机名。
- `port` (integer, optional, nullable) — URL 端口。
- `path` (string, optional, nullable) — URL 路径。
- `query_string` (string, optional, nullable) — URL 查询字符串。

## Examples

**Response**

```json
{
  "entries": [
    {
      "activity_id": 0,
      "activity_name": "string",
      "status_id": 0,
      "actor": {
        "user": {
          "name": "string",
          "uid": "string",
          "type_id": 0,
          "type": "string",
          "email_addr": "string",
          "full_name": "string",
          "domain": "string"
        },
        "app_name": "string",
        "app_uid": "string",
        "session": {}
      },
      "message": "string",
      "id": "string",
      "time_dt": "string",
      "type_uid": 1,
      "type_name": "string",
      "metadata": {},
      "time": 1,
      "category_name": "Identity & Access Management",
      "category_uid": 3,
      "class_name": "",
      "class_uid": 0,
      "severity_id": 0,
      "device": {
        "ip": "string",
        "hostname": "string",
        "type_id": 99
      },
      "http_request": {
        "http_method": "string",
        "url": {
          "url_string": "string",
          "scheme": "string",
          "hostname": "string",
          "port": 1,
          "path": "string",
          "query_string": "string"
        },
        "user_agent": "string",
        "x_forwarded_for": [
          "string"
        ]
      },
      "unmapped": {}
    }
  ],
  "has_more": true,
  "next_cursor": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/workspace/audit-logs"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/workspace/audit-logs';
const options = {method: 'GET'};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/workspace/audit-logs"

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

	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://api.elevenlabs.io/v1/workspace/audit-logs")

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

request = Net::HTTP::Get.new(url)

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://api.elevenlabs.io/v1/workspace/audit-logs")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/workspace/audit-logs');

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/workspace/audit-logs");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/workspace/audit-logs")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

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()
```