> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiperai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 감사 로그

> SMLTP 감사 로그 검색

# 감사 로그

보안 모니터링 및 규정 준수를 위한 SMLTP(Secure Model Language Transfer Protocol) 감사 로그를 검색합니다.

## 엔드포인트

```
GET /audit-logs
```

## 설명

이 끝점은 보안 이벤트, 정책 위반 및 규정 준수 활동을 추적하는 SMLTP 감사 로그를 반환합니다. 이는 보안 모니터링, 규정 준수 감사 및 보안 사고 조사에 유용합니다.

## 인증

**필수**: 관리자 권한이 있는 API 키

```
Authorization: Bearer sk-your-api-key-here
```

## 쿼리 매개변수

| 매개변수        | 유형  | 필수  | 설명 |                           |
| ----------- | --- | --- | -- | ------------------------- |
| `page`      | 정수  | 아니요 | 1  | 페이지 매김을 위한 페이지 번호(기본값: 1) |
| `limit`     | 정수  | 아니요 | 50 | 페이지당 로그 수(기본값: 50)        |
| `startDate` | 문자열 | 아니요 | -  | 필터링 시작 날짜(ISO 8601 형식)    |
| `endDate`   | 문자열 | 아니요 | -  | 필터링 종료 날짜(ISO 8601 형식)    |
| `type`      | 문자열 | 아니요 | -  | 로그 유형별로 필터링               |
| `severity`  | 문자열 | 아니요 | -  | 심각도 수준으로 필터링              |
| `userId`    | 문자열 | 아니요 | -  | 사용자 ID로 필터링               |
| `search`    | 문자열 | 아니요 | -  | 설명 또는 메타데이터에 대한 검색어       |

## 요청 예시

```bash theme={null}
GET /audit-logs?startDate=2024-01-01T00:00:00Z&endDate=2024-01-20T23:59:59Z&severity=info&limit=20
```

## 성공 응답

**상태 코드**: `200 OK`

```json theme={null}
{
  "success": true,
  "data": {
    "logs": [
      {
        "id": "60a7c8f5e8b4f5001f7a8c23",
        "timestamp": "2024-01-15T10:30:00.000Z",
        "type": "smltp_policy_management",
        "severity": "info",
        "description": "External API: Created new SMLTP policy Custom Policy",
        "user": {
          "id": "60a7c8f5e8b4f5001f7a8c24",
          "name": "John Doe",
          "email": "john@example.com"
        },
        "metadata": {
          "endpoint": "/api/external/smltp-policies",
          "policyId": "custom-policy",
          "policyName": "Custom Policy",
          "setAsActive": false,
          "apiKeyId": "60a7c8f5e8b4f5001f7a8c25"
        },
        "complianceCategory": "data_protection",
        "outcome": "success"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 50,
      "total": 150,
      "pages": 3
    },
    "dateRange": {
      "startDate": "2024-01-08T10:30:00.000Z",
      "endDate": "2024-01-15T10:30:00.000Z"
    }
  }
}
```

### 응답 필드

| 필드                               | 유형  | 설명                  |
| -------------------------------- | --- | ------------------- |
| `success`                        | 부울  | 작업이 성공했는지 여부를 나타냅니다 |
| `data`                           | 개체  | 응답 데이터 개체           |
| `data.logs`                      | 배열  | 감사 로그 객체 배열         |
| `data.logs[].id`                 | 문자열 | 고유한 감사 로그 식별자       |
| `data.logs[].timestamp`          | 문자열 | 로그 타임스탬프(ISO 8601)  |
| `data.logs[].type`               | 문자열 | 감사 이벤트 유형           |
| `data.logs[].severity`           | 문자열 | 심각도 수준              |
| `data.logs[].description`        | 문자열 | 이벤트 설명              |
| `data.logs[].user`               | 개체  | 사용자 정보(사용 가능한 경우)   |
| `data.logs[].user.id`            | 문자열 | 사용자 ID              |
| `data.logs[].user.name`          | 문자열 | 사용자 이름              |
| `data.logs[].user.email`         | 문자열 | 사용자 이메일             |
| `data.logs[].metadata`           | 개체  | 추가 메타데이터            |
| `data.logs[].complianceCategory` | 문자열 | 컴플라이언스 카테고리         |
| `data.logs[].outcome`            | 문자열 | 이벤트 결과              |
| `data.pagination`                | 개체  | 페이지 매김 정보           |
| `data.pagination.page`           | 정수  | 현재 페이지 번호           |
| `data.pagination.limit`          | 정수  | 페이지당 항목             |
| `data.pagination.total`          | 정수  | 총 로그 수              |
| `data.pagination.pages`          | 정수  | 총 페이지 수             |
| `data.dateRange`                 | 개체  | 기간 정보               |

## 사용 예

### 자바스크립트

```javascript theme={null}
const getAuditLogs = async (params = {}) => {
  const queryString = new URLSearchParams(params).toString();
  const url = `https://{customer.name}.hiperai.ai/api/external/audit-logs${queryString ? `?${queryString}` : ''}`;
  
  const response = await fetch(url, {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer sk-your-api-key-here'
    }
  });
  
  return await response.json();
};

// Example usage
const result = await getAuditLogs({
  startDate: '2024-01-01T00:00:00Z',
  endDate: '2024-01-20T23:59:59Z',
  severity: 'info',
  limit: 20
});
console.log(result.data.logs);
```

### 파이썬

```python theme={null}
import requests

def get_audit_logs(params=None):
    url = "https://{customer.name}.hiperai.ai/api/external/audit-logs"
    headers = {
        "Authorization": "Bearer sk-your-api-key-here"
    }
    
    response = requests.get(url, headers=headers, params=params)
    return response.json()

# Example usage
params = {
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-01-20T23:59:59Z",
    "severity": "info",
    "limit": 20
}

result = get_audit_logs(params)
print(result["data"]["logs"])
```

### cURL

```bash theme={null}
curl -X GET "https://{customer.name}.hiperai.ai/api/external/audit-logs?startDate=2024-01-01T00:00:00Z&endDate=2024-01-20T23:59:59Z&severity=info&limit=20" \
  -H "Authorization: Bearer sk-your-api-key-here"
```

## 오류 응답

### 401 승인되지 않음

```json theme={null}
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key"
  }
}
```

### 403 금지됨

```json theme={null}
{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "Admin privileges required"
  }
}
```

### 429 요청이 너무 많습니다.

```json theme={null}
{
  "success": false,
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded",
    "retryAfter": 60
  }
}
```

## 필터링 예

### 기간

```bash theme={null}
# Get logs from last 7 days
GET /audit-logs?startDate=2024-01-13T00:00:00Z&endDate=2024-01-20T23:59:59Z

# Get logs from specific date
GET /audit-logs?startDate=2024-01-20T00:00:00Z&endDate=2024-01-20T23:59:59Z
```

### 이벤트 필터링

```bash theme={null}
# Get all SMLTP policy management events
GET /audit-logs?type=smltp_policy_management

# Get info level events
GET /audit-logs?severity=info
```

### 사용자 필터링

```bash theme={null}
# Get logs for specific user
GET /audit-logs?userId=60a7c8f5e8b4f5001f7a8c24

# Search in descriptions
GET /audit-logs?search=policy
```

## 사용 사례

* **보안 모니터링**: 보안 이벤트 및 정책 위반을 모니터링합니다.
* **규정 준수 감사**: 규정 준수 활동 및 위반 추적
* **사고 조사**: 보안 사고 및 위반 사항을 조사합니다.
* **정책 분석**: 정책 효과 및 집행 분석
* **사용자 활동**: 사용자 작업 및 API 사용 추적

## 속도 제한

* **기본값**: 분당 요청 100개
* **일일**: 일일 요청 10,000건
* **월간**: 월간 요청 300,000건

## 메모

* 이 엔드포인트에는 관리자 권한이 필요합니다.
* 페이지네이션: 오프셋이 아닌 페이지 매개변수 사용
* 날짜 범위: 날짜가 제공되지 않은 경우 기본값은 최근 7일입니다.
* 검색: 설명 및 메타데이터.작업 필드에서 검색합니다.
* 중첩된 응답: 응답이 데이터 개체 아래에 중첩되어 있습니다.
* 사용자 정보: 사용자 정보가 있는 경우 입력됩니다.
* 로그는 규정 준수 목적으로 보관됩니다.


## OpenAPI

````yaml GET /audit-logs
openapi: 3.0.3
info:
  title: SecureAI External API
  description: >
    SecureAI External API provides AI chat completion and image generation
    capabilities with knowledge base retrieval, 

    security policies, and comprehensive usage tracking. This API is designed
    for external developers 

    and integrations using API key authentication.


    ## Key Features

    - **RAG (Retrieval-Augmented Generation)**: Automatically search knowledge
    bases for relevant context

    - **Multi-Model Support**: OpenAI, Anthropic, Google, Meta, and other AI
    models

    - **Model Redundancy & Failover**: Caller-defined failover chains (primary +
    fallbacks) with per-attempt timeouts

    - **OpenAI-Compatible Endpoint**: Point any OpenAI SDK at `/api/external/v1`
    — no code changes

    - **Image Generation**: Generate and edit images using Google Gemini 2.5
    Flash Image

    - **Speech-to-Speech (S2S)**: Real-time voice conversations using OpenAI
    Realtime API with WebRTC

    - **Security Policies**: SMLTP policy enforcement, per-call Prompt Shield,
    and signed compliance receipts

    - **Usage Tracking**: Comprehensive usage monitoring, self-service quota,
    and rate limiting

    - **Knowledge Base Integration**: Access to personal and shared knowledge
    bases

    - **User Management**: Complete user, group, and role management
    capabilities

    - **Audit Logging**: Comprehensive activity and security audit logs


    ## Authentication

    All endpoints (except health check) require API key authentication using
    Bearer token:

    ```

    Authorization: Bearer sk-your-api-key-here

    ```


    ## Billing and Usage

    By default, API requests are billed to the user account that owns the API
    key. You can specify 

    a different user to bill by including the `user_id` parameter in your
    request. This allows for:

    - Multi-tenant applications with per-user billing

    - Flexible completion limit management

    - Per-user "Usage by Model" settings


    ## Rate Limits

    - Default: 60 requests per minute, 1000 requests per hour

    - Daily limits: 100 requests (configurable)

    - Monthly limits: 10,000 requests (configurable)


    ## Base URL

    ```

    https://secureai.hiperai.ai/api/external

    ```
  version: 1.1.0
  contact:
    name: SecureAI Support
    email: support@secureai.hiperai.ai
  license:
    name: Proprietary
    url: https://secureai.hiperai.ai/terms
servers:
  - url: https://secureai.hiperai.ai/api/external
    description: Production server
  - url: http://localhost:3010/api/external
    description: Development server
security:
  - ApiKeyAuth: []
tags:
  - name: System
    description: System health and status endpoints
  - name: Discovery
    description: Endpoints to discover available models, indexes, and policies
  - name: Chat
    description: AI chat completion endpoints
  - name: User Management
    description: Endpoints for managing user accounts and roles
  - name: Index Management
    description: Endpoints for managing knowledge base indexes
  - name: Group Management
    description: Endpoints for managing user groups
  - name: SMLTP Security
    description: Endpoints for managing SMLTP security policies and audit logs
  - name: Role Management
    description: Endpoints for managing user roles
  - name: Activity Logs
    description: Endpoints for retrieving activity logs
externalDocs:
  description: SecureAI Documentation
  url: https://secureai.hiperai.ai/docs
paths:
  /audit-logs:
    get:
      tags:
        - SMLTP Security
      summary: Get SMLTP Audit Logs
      description: >
        Retrieve SMLTP audit logs with filtering. Only accessible by
        administrators.
      parameters:
        - name: page
          in: query
          description: Page number for pagination
          required: false
          schema:
            type: integer
            default: 1
            minimum: 1
        - name: limit
          in: query
          description: Number of logs per page
          required: false
          schema:
            type: integer
            default: 50
            minimum: 1
            maximum: 100
        - name: startDate
          in: query
          description: Start date for filtering (ISO 8601 format)
          required: false
          schema:
            type: string
            format: date-time
        - name: endDate
          in: query
          description: End date for filtering (ISO 8601 format)
          required: false
          schema:
            type: string
            format: date-time
        - name: type
          in: query
          description: Filter by log type
          required: false
          schema:
            type: string
        - name: severity
          in: query
          description: Filter by severity level
          required: false
          schema:
            type: string
            enum:
              - info
              - warning
              - error
              - critical
        - name: userId
          in: query
          description: Filter by user ID
          required: false
          schema:
            type: string
        - name: search
          in: query
          description: Search term for description or metadata
          required: false
          schema:
            type: string
      responses:
        '200':
          description: SMLTP audit logs
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      logs:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              example: 60a7c8f5e8b4f5001f7a8c23
                            timestamp:
                              type: string
                              format: date-time
                              example: '2024-01-15T10:30:00.000Z'
                            type:
                              type: string
                              example: smltp_policy_management
                            severity:
                              type: string
                              example: info
                            description:
                              type: string
                              example: >-
                                External API: Created new SMLTP policy Custom
                                Policy
                            user:
                              type: object
                              nullable: true
                              properties:
                                id:
                                  type: string
                                  example: 60a7c8f5e8b4f5001f7a8c24
                                name:
                                  type: string
                                  example: John Doe
                                email:
                                  type: string
                                  example: john@example.com
                            metadata:
                              type: object
                              description: Additional metadata
                            complianceCategory:
                              type: string
                              example: data_protection
                            outcome:
                              type: string
                              example: success
                      pagination:
                        type: object
                        properties:
                          page:
                            type: integer
                            example: 1
                          limit:
                            type: integer
                            example: 50
                          total:
                            type: integer
                            example: 150
                          pages:
                            type: integer
                            example: 3
                      dateRange:
                        type: object
                        properties:
                          startDate:
                            type: string
                            format: date-time
                            example: '2024-01-08T10:30:00.000Z'
                          endDate:
                            type: string
                            format: date-time
                            example: '2024-01-15T10:30:00.000Z'
        '401':
          description: Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Access denied - admin only
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          example: Invalid API key
        message:
          type: string
          example: The provided API key is invalid or has been revoked
        request_id:
          type: string
          example: req-abc123
          description: Request ID for tracking (if available)
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: |
        API key authentication using Bearer token format.
        Example: `Authorization: Bearer sk-your-api-key-here`

````