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

# モニタリングSDKトークン発行API

> DiditのManagement APIで、1人の対象者に紐づく短期間有効なデバイス用認証情報を発行します。APIキーを公開せずに、アプリからモニタリングイベントを送信できます。



モニタリングSDKトークン発行APIのプロンプト
        プロンプトをクリップボードにコピー



      
      

\<pre>

\`Mint a short-lived device credential so my web or mobile app can send monitoring events for one user straight to Didit.

Endpoint:
POST https://verification.didit.me/v3/events/sdk-token/

Authentication:
Use the x-api-key header with my Didit API key. This call runs on MY BACKEND only - the API key must never ship in an app. Only the returned monitoring_token travels to the device. A scoped key needs transactions: write.

Goal:
\- Get a monitoring_token for the signed-in user. The app sends it in the X-Monitoring-Token header to the device lane (POST /v1/events/ and POST /v1/events/batch/).

Request body (application/json):
\{
"vendor_data": "user-42",                                  // required - the subject every event belongs to
"entity_type": "individual",                               // optional - company binds a company; any other value an individual (default)
"allowed_event_categories": ["auth", "session", "gameplay"], // optional - omit or [] for every category
"ttl_seconds": 900,                                        // optional - 60 to 86400, default 900
"max_uses": 1000,                                          // optional - events it may submit, default 1000, null for no cap
"bind_to_origin": "https://app.example.com"                // optional - browser Origin must match exactly
}
camelCase aliases (vendorData, entityType, allowedEventCategories, ttlSeconds, maxUses, bindToOrigin) are also accepted.

Behavior:
\- The subject is bound server-side: whatever subject the app sends is overwritten with vendor_data.
\- One use per submitted event, also inside a batch: a 500-event flush spends 500 uses, and events the device lane rejects spend uses too.
\- An event outside allowed_event_categories is rejected by the device lane with 400.
\- With bind_to_origin set, a device request with a different Origin, or none, is refused.
\- Minting does not create a user.
\- Event ingestion must be switched on for the application, otherwise this call returns 403 with code event_monitoring_disabled.

Example call:
curl -X POST "https://verification.didit.me/v3/events/sdk-token/" \
-H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" \
-d '{"vendor_data":"user-42","allowed_event_categories":["auth","session","gameplay"],"ttl_seconds":900,"max_uses":1000}'

What to read from the response:
\- monitoring_token - hand it to the app; treat it as a secret for its lifetime.
\- expires_at - mint a fresh credential per user session before it expires.
\- allowed_event_categories ([] means every category), max_uses (null means no cap), bind_to_origin.

Failure modes:
\- 400 - missing vendor_data, ttl_seconds outside 60-86400, max_uses below 1, or an unknown category.
\- 401 - the API key has expired.
\- 403 - missing API key (a wrong, revoked or expired key gets 401), a scoped key without transactions: write, or code event_monitoring_disabled.

Side effects: creates one credential. Nothing else changes.

For the full client-side submission guide, see /transaction-monitoring/sdk-event-submission.`

\</pre>



      
      

貼り付け先

この認証情報はデバイスレーンで使用されます。デバイスレーンについては[SDKイベント送信](https://docs.didit.me/ja/transaction-monitoring/sdk-event-submission.md)で説明しています。このページでは、サーバーがすべてのデバイスリクエストに対して適用する制約と、バックプレッシャー発生時に破棄しても問題のないイベントが記載されています。


## OpenAPI

````yaml ja/openapi-25.json POST /v3/events/sdk-token/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: 本人確認API。x-api-keyヘッダーで認証します。
servers:
  - url: https://verification.didit.me
security: []
tags: []
paths:
  /v3/events/sdk-token/:
    post:
      tags:
        - Monitoring Events
      summary: モニタリングSDKトークンの発行
      description: >-
        1つのサブジェクトに紐づく短期間有効なデバイス認証情報を発行し、WebアプリやモバイルアプリがAPIキーなしでそのユーザーのイベントをDiditへ直接送信できるようにします。アプリは返された`monitoring_token`を`X-Monitoring-Token`ヘッダーに設定してデバイス用レーン（`POST
        /v1/events/`および`POST
        /v1/events/batch/`）へ送信します。このレーンでは、サブジェクトは常にこの`vendor_data`で上書きされ、`allowed_event_categories`に含まれないイベントは拒否され、送信されたイベントごとに使用回数が1回消費され、`Origin`が`bind_to_origin`と一致しないリクエストは拒否されます。このエンドポイントは必ずバックエンドからのみ呼び出してください。発行によって作成されるのは認証情報のみで、それ以外は何も作成されません（ユーザーは作成されません）。アプリケーションでイベントの取り込みが有効になっている必要があります。有効でない場合、このエンドポイントは書き込みに使えない認証情報を発行する代わりに、`code:
        event_monitoring_disabled`を含む`403`を返します。スコープ付きAPIキーには`transactions:
        write`が必要です。[SDKからのイベント送信](https://docs.didit.me/ja/transaction-monitoring/sdk-event-submission)を参照してください。
      operationId: create_monitoring_event_sdk_token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: >-
                camelCaseのエイリアスも使用できます：`vendorData`、`entityType`、`allowedEventCategories`、`ttlSeconds`、`maxUses`、`bindToOrigin`。
              required:
                - vendor_data
              properties:
                vendor_data:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: この認証情報で送信されるすべてのイベントが属するサブジェクトに対するお客様のIDです。
                entity_type:
                  type: string
                  maxLength: 32
                  default: individual
                  description: >-
                    `company`は企業のサブジェクトを紐付けます。それ以外の値（デフォルトは`individual`）は個人を紐付けます。
                allowed_event_categories:
                  type: array
                  items:
                    type: string
                    enum:
                      - auth
                      - session
                      - gameplay
                      - bonus
                      - affiliate
                      - payment
                      - dispute
                      - security
                      - responsible_gambling
                      - custom
                  description: この認証情報で送信できるカテゴリ。すべてのカテゴリを許可するには、省略するか`[]`を送信します。
                ttl_seconds:
                  type: integer
                  minimum: 60
                  maximum: 86400
                  default: 900
                  description: 認証情報の有効期間（秒）。
                max_uses:
                  type: integer
                  minimum: 1
                  nullable: true
                  default: 1000
                  description: >-
                    この認証情報で送信できるイベントの数（バッチではイベントごとに1回分を消費します）。有効期間内で上限を設けない場合は`null`を送信します。
                bind_to_origin:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: >-
                    設定すると、すべてのデバイスリクエストのブラウザの`Origin`ヘッダーがこの値と完全に一致する必要があります。`Origin`のないリクエストは拒否されます。
            example:
              vendor_data: user-42
              allowed_event_categories:
                - auth
                - session
                - gameplay
              ttl_seconds: 900
              max_uses: 1000
              bind_to_origin: https://app.example.com
      responses:
        '201':
          description: >-
            認証情報が発行されました。`monitoring_token`をアプリに渡し、`expires_at`までシークレットとして扱ってください。
          content:
            application/json:
              schema:
                type: object
                required:
                  - monitoring_token
                  - expires_at
                  - allowed_event_categories
                  - max_uses
                  - bind_to_origin
                properties:
                  monitoring_token:
                    type: string
                    description: >-
                      デバイスの認証情報（43文字のURLセーフなトークン）です。`X-Monitoring-Token`ヘッダーで送信してください。
                  expires_at:
                    type: string
                    format: date-time
                    description: 認証情報が受け付けられなくなる日時。
                  allowed_event_categories:
                    type: array
                    items:
                      type: string
                      enum:
                        - auth
                        - session
                        - gameplay
                        - bonus
                        - affiliate
                        - payment
                        - dispute
                        - security
                        - responsible_gambling
                        - custom
                    description: この認証情報で送信できるカテゴリ。`[]`はすべてのカテゴリを意味します。
                  max_uses:
                    type: integer
                    nullable: true
                    description: 認証情報のイベント上限。nullは上限なしを意味します。
                  bind_to_origin:
                    type: string
                    nullable: true
                    description: 認証情報が紐づけられたオリジン、またはnullです。
              example:
                monitoring_token: q7ZtR2xKp9VbN4mWc8LdH1sYfJ3gT6uEaQ0oPiXzBkC
                expires_at: '2026-10-17T09:30:02.481000Z'
                allowed_event_categories:
                  - auth
                  - session
                  - gameplay
                max_uses: 1000
                bind_to_origin: https://app.example.com
        '400':
          description: >-
            バリデーションに失敗しました。`vendor_data`がない、`ttl_seconds`が60〜86400の範囲外、`max_uses`が1未満、または不明なカテゴリー(配列内の位置をキーとして示されます)のいずれかです。
          content:
            application/json:
              examples:
                Missing vendor_data:
                  value:
                    vendor_data:
                      - This field is required.
                ttl_seconds too short:
                  value:
                    ttl_seconds:
                      - Ensure this value is greater than or equal to 60.
                Unknown category:
                  value:
                    allowed_event_categories:
                      '1':
                        - '"login" is not a valid choice.'
        '401':
          description: >-
            スコープ付きAPIキーの有効期限が切れています。`401`が返されるのは期限切れのキーのみで、キーが指定されていない場合や無効な場合は`403`が返されます。
          content:
            application/json:
              examples:
                Expired key:
                  value:
                    detail: This API key has expired.
        '403':
          description: >-
            `x-api-key`がない（誤った、取り消された、または期限切れのキーには`401`が返されます）、`transactions:
            write`を持たないスコープ付きキー、一部のワークフローまたは承認済みセッションに限定されたキー（このようなキーはトランザクションモニタリングのデータに一切アクセスできません）、またはキーのIP許可リスト外からのリクエスト。アプリケーションでイベントの取り込みが無効になっている間も`code:
            event_monitoring_disabled`とともに返されます。その場合は何も保存されず、このチェックはリクエストボディの検証前に実行されます。
          content:
            application/json:
              examples:
                Event monitoring disabled:
                  value:
                    detail: >-
                      Event monitoring is not enabled for this application. Turn
                      on event ingestion in the transaction monitoring settings
                      before submitting events.
                    code: event_monitoring_disabled
                Missing or invalid API key:
                  value:
                    detail: You do not have permission to perform this action.
                Scoped key without access:
                  value:
                    detail: This API key has no write access to transactions.
                Key limited to workflows or approved sessions:
                  value:
                    detail: >-
                      This API key only reaches sessions inside its workflow or
                      status limits, so it can't use this endpoint.
                IP not allowed:
                  value:
                    detail: This API key can't be used from this IP address.
        '429':
          description: >-
            レート制限を超過しました。書き込みリクエスト（`POST`、`PATCH`、`DELETE`）は、APIキーごとに1分あたり300リクエストの上限を共有します。`Retry-After`秒待ってから再試行してください。
          headers:
            Retry-After:
              description: 再試行までに待機する秒数。
              schema:
                type: integer
                minimum: 1
                example: 30
          content:
            application/json:
              examples:
                Throttled:
                  value:
                    detail: >-
                      Write request rate limit exceeded. You can make up to 300
                      requests per minute.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl -X POST 'https://verification.didit.me/v3/events/sdk-token/' \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "vendor_data": "user-42",
                "allowed_event_categories": ["auth", "session", "gameplay"],
                "ttl_seconds": 900,
                "max_uses": 1000,
                "bind_to_origin": "https://app.example.com"
              }'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.monitoring_events.create_sdk_token(
                vendor_data="user-42",
                allowed_event_categories=["auth", "session", "gameplay"],
                ttl_seconds=900,
                max_uses=1000,
                bind_to_origin="https://app.example.com",
            )
            print(result)
        - lang: javascript
          label: Node.js
          source: |-
            import Didit from "@didit-protocol/sdk-node";

            // Reads DIDIT_API_KEY.
            const didit = new Didit();

            const result = await didit.monitoringEvents.createSdkToken({
              vendor_data: "user-42",
              allowed_event_categories: ["auth", "session", "gameplay"],
              ttl_seconds: 900,
              max_uses: 1000,
              bind_to_origin: "https://app.example.com",
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.MonitoringEvents.CreateSDKToken(ctx, didit.MonitoringEventsCreateSDKTokenParams{\n\tVendorData:             \"user-42\",\n\tAllowedEventCategories: didit.Some([]didit.MonitoringEventsCreateSDKTokenParamsAllowedEventCategories{\"auth\", \"session\", \"gameplay\"}),\n\tTTLSeconds:             didit.Int(900),\n\tMaxUses:                didit.Int(1000),\n\tBindToOrigin:           didit.String(\"https://app.example.com\"),\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import java.util.List;

            import me.didit.Didit;

            import me.didit.types.MonitoringEventsCreateSdkTokenParams;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.monitoringEvents().createSdkToken(MonitoringEventsCreateSdkTokenParams.builder()
                    .vendorData("user-42")
                    .allowedEventCategories(List.of(MonitoringEventsCreateSdkTokenParams.AllowedEventCategories.of("auth"), MonitoringEventsCreateSdkTokenParams.AllowedEventCategories.of("session"), MonitoringEventsCreateSdkTokenParams.AllowedEventCategories.of("gameplay")))
                    .ttlSeconds(900L)
                    .maxUses(1000L)
                    .bindToOrigin("https://app.example.com")
                    .build());
            System.out.println(result);
        - lang: php
          label: PHP
          source: |-
            <?php

            require 'vendor/autoload.php';

            use Didit\DiditClient;

            // Reads DIDIT_API_KEY.
            $didit = new DiditClient();

            $result = $didit->monitoringEvents->createSdkToken([
                'vendor_data' => 'user-42',
                'allowed_event_categories' => ['auth', 'session', 'gameplay'],
                'ttl_seconds' => 900,
                'max_uses' => 1000,
                'bind_to_origin' => 'https://app.example.com',
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

            # Reads DIDIT_API_KEY.
            didit = Didit::Client.new

            result = didit.monitoring_events.create_sdk_token(
              vendor_data: "user-42",
              allowed_event_categories: ["auth", "session", "gameplay"],
              ttl_seconds: 900,
              max_uses: 1000,
              bind_to_origin: "https://app.example.com"
            )
            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Text.Json;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var result = await client.MonitoringEvents.CreateSdkTokenAsync(new
            MonitoringEventsCreateSdkTokenParams

            {
                VendorData = "user-42",
                AllowedEventCategories = new MonitoringEventsCreateSdkTokenParamsAllowedEventCategories[] { "auth", "session", "gameplay" },
                TtlSeconds = 900,
                MaxUses = 1000,
                BindToOrigin = "https://app.example.com",
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        お客様のアプリケーションのAPIキーです。Business ConsoleのDevelopers -> API
        keysで取得できます。プライマリキーはフルアクセス権を持ちます。名前付きキーにはスコープを設定できます。リソースごとのアクセス権（なし、読み取り、書き込み）、一部のワークフローまたは承認済みセッションへの限定、IPアドレスのリストへの限定、有効期限の設定です。401は、キーが誤っている、失効している、または期限切れであることを意味します。403は、キーが送信されていない、キーにこのリソースやアクションへのアクセス権がない、またはIPリスト外のアドレスからリクエストが送信されたことを意味します。セッションのルートでの404は、セッションがキーのワークフローまたはステータスの対象外であることを意味します。メディアへのアクセス権がないキーでは、画像、動画、PDFのURLがnullで返されます。セッションの書き込み権限がないキーでは、セッションのリンクとトークンがnullで返されます。詳細は次を参照してください:
        https://docs.didit.me/console/api-keys

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.