> ## 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 セキュリティ ポリシーを作成する

# SMLTP ポリシーを作成する

アカウントに新しい SMLTP (Secure Model Language Transfer Protocol) セキュリティ ポリシーを作成します。

## エンドポイント

```
POST /smltp-policies
```

## 説明

新しいカスタム SMLTP ポリシーを作成します。管理者のみのアクセスが必要です。

## 認証

**必須**: 管理者権限を持つ API キー

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

## リクエスト本文

| パラメータ         | タイプ    | 必須  | 説明                                         |
| ------------- | ------ | --- | ------------------------------------------ |
| `name`        | 文字列    | はい  | ポリシー名                                      |
| `description` | 文字列    | はい  | ポリシーの説明                                    |
| `policy`      | オブジェクト | はい  | ポリシー構成オブジェクト                               |
| `setAsActive` | ブール値   | いいえ | このポリシーをすぐにアクティブとして設定するかどうか (デフォルト: false)。 |

## リクエストの例

```json theme={null}
{
  "name": "Custom Privacy Policy",
  "description": "Enhanced privacy protection for sensitive data",
  "policy": {
    // Policy configuration object
  },
  "setAsActive": false
}
```

## 成功の応答

**ステータス コード**: `201 Created`

```json theme={null}
{
  "success": true,
  "message": "SMLTP policy created successfully",
  "policy": {
    "id": "custom-privacy-policy",
    "name": "Custom Privacy Policy",
    "description": "Enhanced privacy protection for sensitive data",
    "type": "custom",
    "isActive": false,
    "createdAt": "2024-01-20T15:30:00.000Z"
  }
}
```

### 応答フィールド

| フィールド                | タイプ    | 説明                |
| -------------------- | ------ | ----------------- |
| `success`            | ブール値   | 操作が成功したかどうかを示します。 |
| `message`            | 文字列    | 成功メッセージ           |
| `policy`             | オブジェクト | 作成されたポリシー オブジェクト  |
| `policy.id`          | 文字列    | ポリシー識別子 (名前から生成)  |
| `policy.name`        | 文字列    | ポリシー名             |
| `policy.description` | 文字列    | ポリシーの説明           |
| `policy.type`        | 文字列    | ポリシーの種類 (「カスタム」)  |
| `policy.isActive`    | ブール値   | ポリシーが現在アクティブかどうか  |
| `policy.createdAt`   | 文字列    | 作成タイムスタンプ         |

## 使用例

### JavaScript

```javascript theme={null}
const createSmltpPolicy = async (policyData) => {
  const response = await fetch('https://{customer.name}.hiperai.ai/api/external/smltp-policies', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk-your-api-key-here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(policyData)
  });
  
  return await response.json();
};

// Example usage
const policyData = {
  name: "Custom Privacy Policy",
  description: "Enhanced privacy protection for sensitive data",
  policy: {
    // Policy configuration object
  },
  setAsActive: false
};

const result = await createSmltpPolicy(policyData);
console.log('Created policy:', result.policy.id);
```

### パイソン

```python theme={null}
import requests

def create_smltp_policy(policy_data):
    url = "https://{customer.name}.hiperai.ai/api/external/smltp-policies"
    headers = {
        "Authorization": "Bearer sk-your-api-key-here",
        "Content-Type": "application/json"
    }
    
    response = requests.post(url, headers=headers, json=policy_data)
    return response.json()

# Example usage
policy_data = {
    "name": "Custom Privacy Policy",
    "description": "Enhanced privacy protection for sensitive data",
    "policy": {
        # Policy configuration object
    },
    "setAsActive": False
}

result = create_smltp_policy(policy_data)
print("Created policy:", result["policy"]["id"])
```

### cURL

```bash theme={null}
curl -X POST "https://{customer.name}.hiperai.ai/api/external/smltp-policies" \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Custom Privacy Policy",
    "description": "Enhanced privacy protection for sensitive data",
    "policy": {
      // Policy configuration object
    },
    "setAsActive": false
  }'
```

## エラー応答

### 400 不正なリクエスト

```json theme={null}
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Policy name is required",
    "details": {
      "field": "name",
      "value": null
    }
  }
}
```

### 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"
  }
}
```

### 409 紛争

```json theme={null}
{
  "success": false,
  "error": {
    "code": "POLICY_NAME_EXISTS",
    "message": "Policy name already exists"
  }
}
```

### 429 リクエストが多すぎます

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

## 使用例

* **カスタム セキュリティ**: ニーズに合わせたポリシーを作成します
* **コンプライアンス**: 特定の規制要件を実装します。
* **リスク管理**: リスクを軽減するためのセキュリティ対策を定義します。
* **データ保護**: プライバシーとデータの取り扱いルールを確立します。
* **ポリシー管理**: カスタム SMLTP ポリシーを作成および管理します。

## レート制限

* **デフォルト**: 1 分あたり 50 リクエスト
* **毎日**: 1 日あたり 5,000 リクエスト
* **毎月**: 毎月 150,000 件のリクエスト

## 注意事項

* このエンドポイントには管理者権限が必要です
* 必須フィールド: 名前、説明、ポリシーは必須です
* ポリシー ID: 名前から生成 (小文字、スペースの場合はハイフン)
* 一意の名前: ポリシー名は一意である必要があります。
* アクティブに設定: オプションですぐにアクティブに設定できます。
* フラットな応答: 応答はデータ オブジェクトの下にネストされていません


## OpenAPI

````yaml POST /smltp-policies/active
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:
  /smltp-policies/active:
    post:
      tags:
        - SMLTP Security
      summary: Create Custom SMLTP Policy
      description: |
        Create a new custom SMLTP policy. Only accessible by administrators.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - description
                - policy
              properties:
                name:
                  type: string
                  description: Policy name
                  example: Custom Policy
                description:
                  type: string
                  description: Policy description
                  example: Custom SMLTP policy for specific requirements
                policy:
                  type: object
                  description: Policy configuration object
                  example: null
                setAsActive:
                  type: boolean
                  default: false
                  description: Whether to set this policy as active immediately
                  example: false
            example:
              name: Custom Policy
              description: Custom SMLTP policy for specific requirements
              policy: null
              setAsActive: false
      responses:
        '201':
          description: Custom policy created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: SMLTP policy created successfully
                  policy:
                    type: object
                    properties:
                      id:
                        type: string
                        example: custom-policy
                      name:
                        type: string
                        example: Custom Policy
                      description:
                        type: string
                        example: Custom SMLTP policy for specific requirements
                      type:
                        type: string
                        example: custom
                      isActive:
                        type: boolean
                        example: false
                      createdAt:
                        type: string
                        format: date-time
                        example: '2024-01-15T10:30:00.000Z'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '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'
        '409':
          description: Policy name already exists
          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`

````