> ## 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

> أنشئ رمز جهاز قصير الأجل مرتبطاً بمستخدم واحد ليتمكن تطبيقك من إرسال أحداث المراقبة دون كشف مفتاح API الخاص بك في Didit.



موجّه API لإصدار رمز SDK للمراقبة
        نسخ الموجّه إلى الحافظة



      
      

\<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/ar/transaction-monitoring/sdk-event-submission.md). كما يسرد أيضًا ما يفرضه الخادم على كل طلب من الجهاز، والأحداث التي يمكن إسقاطها بأمان عند الضغط العكسي.


## OpenAPI

````yaml ar/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: إصدار token لمراقبة SDK
      description: >-
        إصدار بيانات اعتماد جهاز قصيرة الأجل مرتبطة بموضوع واحد، حتى يتمكن تطبيق
        الويب أو الجوال لديك من إرسال أحداث ذلك المستخدم مباشرة إلى Didit دون
        مفتاح API. يُرسل التطبيق `monitoring_token` المُعاد في الرأس
        `X-Monitoring-Token` إلى مسار الجهاز (`POST /v1/events/` و`POST
        /v1/events/batch/`)، حيث يتم دائمًا استبدال الموضوع بـ `vendor_data`
        هذا، وتُرفض الأحداث الخارجة عن `allowed_event_categories`، وتستهلك كل
        عملية إرسال حدث استخدامًا واحدًا، ويُرفض أي طلب لا تتطابق فيه قيمة
        `Origin` مع `bind_to_origin`. استدعه من واجهتك الخلفية فقط؛ لا يُنشئ
        الإصدار سوى بيانات الاعتماد ولا شيء غير ذلك (لا يتم إنشاء أي مستخدم).
        يجب تفعيل استيعاب الأحداث للتطبيق، وإلا فإن هذا الـ endpoint يُرجع `403`
        مع `code: event_monitoring_disabled` بدلاً من إصدار بيانات اعتماد لا
        يمكنها الكتابة أبدًا. يحتاج مفتاح API ذو النطاق المحدد إلى
        `transactions: write`. راجع [إرسال أحداث
        SDK](https://docs.didit.me/ar/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: >-
                    المعرّف الخاص بك للكيان الذي ينتمي إليه كل حدث يتم إرساله
                    باستخدام بيانات الاعتماد هذه.
                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: >-
                    عدد الأحداث التي يجوز لبيانات الاعتماد إرسالها (تستهلك
                    الدفعة استخداماً واحداً لكل حدث). أرسل `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: >-
                      بيانات اعتماد الجهاز (token آمن لعناوين URL مكوّن من 43
                      حرفاً). أرسله في الرأس `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`، أو
            مفتاح مقتصر على بعض مسارات سير العمل أو على الجلسات المقبولة (مثل
            هذا المفتاح لا يصل أبداً إلى بيانات مراقبة المعاملات)، أو طلب من
            خارج قائمة العناوين المسموح بها للمفتاح. يُرجع أيضاً مع `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`)
            رصيداً قدره 300 طلب في الدقيقة لكل مفتاح API. انتظر لعدد الثواني
            المحدد في `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 الخاص بتطبيقك، من Developers -> API keys في Business Console.
        يمتلك المفتاح الأساسي وصولاً كاملاً. يمكن تحديد نطاق المفتاح المسمى: لا
        شيء، أو قراءة، أو كتابة لكل مورد، ومحدوداً ببعض مسارات العمل أو بالجلسات
        المقبولة، وبقائمة من عناوين IP، وبتاريخ انتهاء الصلاحية. يشير 401 إلى أن
        المفتاح غير صحيح أو ملغى أو منتهي الصلاحية؛ ويشير 403 إلى أنه لم يتم
        إرسال أي مفتاح، أو أن المفتاح ليس لديه حق الوصول إلى هذا المورد أو
        الإجراء، أو أن الطلب جاء من عنوان خارج قائمة عناوين IP الخاصة به؛ ويشير
        404 في مسار جلسة إلى أن الجلسة خارج مسارات العمل أو الحالات الخاصة
        بالمفتاح. يتلقى المفتاح الذي لا يمتلك حق الوصول إلى الوسائط عناوين URL
        للصور ومقاطع الفيديو وملفات PDF كـ null، ويتلقى المفتاح الذي لا يمتلك
        إذن كتابة للجلسات روابط الجلسة وtoken كـ null. راجع
        https://docs.didit.me/console/api-keys.

````

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