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

# 取引モニタリングルール更新API

> DiditのAPIでKYTルールを調整できます。しきい値・条件・アクションの変更や、TEST・ACTIVE・DISABLEDのモード切り替えに対応。ライブラリのプリセットはモードのみ変更可能です。



ルール更新APIのプロンプト
        プロンプトをクリップボードにコピー



      
      

\<pre>

\`Update a transaction-monitoring rule.

Endpoint:
PATCH https://verification.didit.me/v3/transactions/rules/{rule_uuid}/

Authentication:
Use the x-api-key header with my Didit API key.

Request body (application/json, partial - send only what changes):
\{ "mode": "ACTIVE" }
or any of: title, description, category, mode, evaluation_mode, scope, conditions, aggregation, actions, metadata.

Behavior:
\- CUSTOM rules accept every field, with the same validation as create.
\- Library (PRESET) rules accept ONLY "mode" - use it to activate, disable, or switch a preset to TEST. Any other field returns 400 naming the offending keys.
\- Changes take effect immediately for new transactions.
\- The typical activation call after a successful backtest is exactly {"mode": "ACTIVE"}.

Failure modes:
\- 400 - validation error, or a non-mode field on a library rule.
\- 404 - unknown rule uuid for this application.`

\</pre>



      
      

貼り付け先



## OpenAPI

````yaml ja/openapi-25.json PATCH /v3/transactions/rules/{rule_uuid}/
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/transactions/rules/{rule_uuid}/:
    parameters:
      - name: rule_uuid
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: 一覧取得または作成で返されたルールのuuidです。
    patch:
      tags:
        - Transactions
      summary: ルールを更新
      description: >-
        ルールを部分的に更新します。カスタムルールはすべての設定フィールドを受け付けます。ライブラリ（PRESET）ルールは`mode`のみを受け付けます。プリセットの有効化、無効化、またはTESTへの切り替えに使用してください。それ以外のフィールドを送信すると400が返ります。公開が保留されているライブラリルールのインストール済みコピーはオフになっています。その`mode`を`DISABLED`以外に設定すると400（"This
        library rule cannot run yet: its conditions read data the rules engine
        cannot evaluate."）が返ります。
      operationId: updateTransactionRule
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TransactionRuleUpdateRequest'
            example:
              mode: ACTIVE
      responses:
        '200':
          description: 更新されたルール。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionRuleDetail'
        '400':
          description: >-
            バリデーションエラー。ライブラリルールでmode以外のフィールドを指定した場合、または保留中のライブラリルールでDISABLED以外のmodeを指定した場合に返されます。
          content:
            application/json:
              schema:
                type: object
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X PATCH
            'https://verification.didit.me/v3/transactions/rules/RULE_UUID/' \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{"mode": "ACTIVE"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.transactions.rules.update(
                "11111111-2222-3333-4444-555555555555",
                mode="ACTIVE",
            )
            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.transactions.rules.update("11111111-2222-3333-4444-555555555555",
            {
              mode: "ACTIVE",
            });

            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Transactions.Rules.Update(ctx, \"11111111-2222-3333-4444-555555555555\", didit.TransactionRuleUpdateRequest{\n\tMode: didit.Some(didit.TransactionRuleUpdateRequestMode(\"ACTIVE\")),\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import me.didit.Didit;

            import me.didit.types.TransactionRuleUpdateRequest;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.transactions().rules().update("11111111-2222-3333-4444-555555555555",
            TransactionRuleUpdateRequest.builder()
                    .mode(TransactionRuleUpdateRequest.Mode.of("ACTIVE"))
                    .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->transactions->rules->update('11111111-2222-3333-4444-555555555555',
            [
                'mode' => 'ACTIVE',
            ]);

            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

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

            result = didit.transactions.rules.update(
              "11111111-2222-3333-4444-555555555555",
              mode: "ACTIVE"
            )
            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.Transactions.Rules.UpdateAsync("11111111-2222-3333-4444-555555555555",
            new TransactionRuleUpdateRequest

            {
                Mode = new TransactionRuleUpdateRequestMode("ACTIVE"),
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    TransactionRuleUpdateRequest:
      type: object
      properties:
        title:
          type: string
          description: ルール名。アプリケーション内の削除されていないルールの間で一意である必要があり、重複する場合は400が返されます。
        description:
          type: string
          nullable: true
        category:
          type: string
          description: >-
            グループ化とレポートに使用されるリスクテーマです。例:
            finance、aml_ctf、anomaly_detection、fatf、device_intelligence、crypto_monitoring、travel_rule、responsible_gaming、e_commerce。
        mode:
          type: string
          enum:
            - ACTIVE
            - DISABLED
            - TEST
          description: >-
            ACTIVEは本番で評価します。TESTは評価してルールの実行を記録しますが、スコアやステータスには一切影響しません。最初に推奨されるモードです。DISABLEDはスキップされます。
        evaluation_mode:
          type: string
          enum:
            - ALL
            - ANY
          default: ALL
          description: >-
            すべての条件に一致する必要がある（ALL）か、少なくとも1つに一致すればよい（ANY）かです。条件でgroup_indexを使用する場合は無視されます。
        scope:
          $ref: '#/components/schemas/TransactionRuleScope'
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/TransactionRuleCondition'
        aggregation:
          type: array
          items:
            $ref: '#/components/schemas/TransactionRuleAggregation'
        actions:
          type: array
          items:
            $ref: '#/components/schemas/TransactionRuleAction'
        metadata:
          type: object
          description: ルールに保存される自由形式のメタデータ。
      description: >-
        部分更新。カスタムルールはすべてのフィールドを受け付けますが、ライブラリ(PRESET)ルールはmodeのみを受け付け、それ以外を指定すると400が返されます。
    TransactionRuleDetail:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
        title:
          type: string
          description: ルール名。アプリケーション内の削除されていないルールの間で一意である必要があり、重複する場合は400が返されます。
        description:
          type: string
          nullable: true
        category:
          type: string
          description: >-
            グループ化とレポートに使用されるリスクテーマです。例:
            finance、aml_ctf、anomaly_detection、fatf、device_intelligence、crypto_monitoring、travel_rule、responsible_gaming、e_commerce。
        mode:
          type: string
          enum:
            - ACTIVE
            - DISABLED
            - TEST
          description: >-
            ACTIVEは本番で評価します。TESTは評価してルールの実行を記録しますが、スコアやステータスには一切影響しません。最初に推奨されるモードです。DISABLEDはスキップされます。
        evaluation_mode:
          type: string
          enum:
            - ALL
            - ANY
          default: ALL
          description: >-
            すべての条件に一致する必要がある（ALL）か、少なくとも1つに一致すればよい（ANY）かです。条件でgroup_indexを使用する場合は無視されます。
        scope:
          $ref: '#/components/schemas/TransactionRuleScope'
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/TransactionRuleCondition'
        aggregation:
          type: array
          items:
            $ref: '#/components/schemas/TransactionRuleAggregation'
        actions:
          type: array
          items:
            $ref: '#/components/schemas/TransactionRuleAction'
        metadata:
          type: object
          description: ルールに保存される自由形式のメタデータ。
        severity:
          type: string
          enum:
            - UNKNOWN
            - LOW
            - MEDIUM
            - HIGH
            - CRITICAL
          nullable: true
          description: ライブラリルールが持つ情報レベルの重大度。カスタムルールでは設定できません。
        source:
          type: string
          enum:
            - PRESET
            - CUSTOM
          description: >-
            PRESETルールはライブラリから提供されます（インストール/アンインストール、モードのみの編集）。CUSTOMルールは完全にお客様のものです。
        library_key:
          type: string
          nullable: true
          description: 安定したライブラリ識別子。カスタムルールの場合はnullです。
        latest_triggered_at:
          type: string
          format: date-time
          nullable: true
        run_count:
          type: integer
          description: このルールに一致した取引の数。
        approved_count:
          type: integer
        reviewed_count:
          type: integer
        declined_count:
          type: integer
        awaiting_user_count:
          type: integer
        approved_pct:
          type: number
        reviewed_pct:
          type: number
        declined_pct:
          type: number
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    TransactionRuleScope:
      type: object
      properties:
        transaction_types:
          type: array
          items:
            type: string
          description: >-
            取引の種類に限定します（例：finance、kyc、travel_rule、user_event）。空または未指定の場合は制限なしとなります。
        directions:
          type: array
          items:
            type: string
            enum:
              - INBOUND
              - OUTBOUND
          description: 取引の方向に限定します（書き込み時は大文字と小文字を区別しません）。
        action_types:
          type: array
          items:
            type: string
          description: 独自のaction_type値に限定します（例：withdrawal、deposit）。
      description: ルールを適用する取引。受け付けられるキーはこの3つのみです。
    TransactionRuleCondition:
      type: object
      required:
        - field
        - operator
      properties:
        field:
          type: string
          description: >-
            評価する取引フィールドのパス。主要フィールド: amount, currency, direction, action_type,
            score, severity, transaction_type, payment_details,
            preferred_currency_amount（ない場合はamount_in_default_currencyにフォールバック）,
            default_currency_code, subject_country, counterparty_country,
            subject_vendor_data, counterparty_vendor_data,
            subject_device_fingerprint, counterparty_device_fingerprint,
            subject_browser_family, subject_browser_version, subject_platform,
            subject_accept_language, subject_session_age_ms, subject_ip_country,
            counterparty_ip_country, subject_ip_address,
            counterparty_ip_address, subject_payment_method_type,
            subject_payment_method_country, subject_payment_method_fingerprint,
            subject_payment_method_account_id（およびcounterparty_payment_method_*の対応フィールド）,
            travel_rule_status, travel_rule_required,
            travel_rule_obligations_count,
            counterparty_dd_status（トラベルルールの取引相手に対するあなたの判定:
            APPROVED、RESTRICTEDまたはBLOCKED。エンティティはそのブランドの判定に従います）,
            counterparty_risk_level（LOW、MEDIUMまたはHIGH。自社の取引相手スクリーニングでフラグが立っている間はHIGH）,
            counterparty_jurisdiction（取引相手VASPの国）,
            counterparty_responsiveness（RESPONSIVE、UNRESPONSIVEまたはUNKNOWN）,
            subject_days_since_previous_transaction,
            tags、および取引作成時にcustom_propertiesで送信した任意のキーに対するcustom_values.<key>。国コードのフィールドはISO-2またはISO-3を受け付け、比較の前に両側ともISO-3に正規化されます。
        operator:
          type: string
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
            - in
            - not_in
            - contains
            - not_contains
            - contains_any
            - regex
            - fuzzy_match
            - exists
            - is_not_empty
            - is_not_null
            - not_exists
            - is_empty
            - is_null
          description: >-
            比較演算子。in/not_inはメンバーシップを判定します(valueにはリストまたは単一のスカラー値を指定できます)。contains/not_containsは文字列値に対して大文字と小文字を区別しない部分文字列チェックを行います。contains_anyは文字列のリストを受け取り、いずれかがフィールド値の部分文字列(大文字と小文字を区別しない)である場合に一致します。regexはvalueのパターンをフィールドに照合します。fuzzy_matchはvalueの文字列と比較し、必要な`score`しきい値(0-100)を適用します。gt/gte/lt/lteは、どちらか一方が欠落している場合は一致しません。exists/is_not_empty/is_not_null(エイリアス)およびnot_exists/is_empty/is_null(エイリアス)は存在チェックであり、`value`を無視します。
        value:
          description: >-
            比較値。形式は演算子とvalue_typeによって異なります。存在チェックの演算子では省略してください。それ以外のすべての演算子では`null`や空のリストではない値が必要で、そうでない場合ルールは`400`で拒否されます。`contains_any`には文字列のリストが、`contains`、`not_contains`、`regex`には単一の文字列が必要です。
        value_type:
          type: string
          enum:
            - list
            - field
            - relative_date
          description: >-
            任意の値の解釈方法です。`list`：値はリストのUUIDで、リストのエントリーが比較値になります。`field`：値は別のフィールドパスで、フィールド同士で比較されます。`relative_date`：値は相対日付オブジェクトです（例：{"direction":
            "past", "unit": "days", "amount": 30}）。
        score:
          type: number
          minimum: 0
          maximum: 100
          description: operatorがfuzzy_matchの場合は必須：0〜100の類似度しきい値。
        group_index:
          type: integer
          description: >-
            任意のグループ化ロジックです。いずれかの条件にgroup_indexが含まれる場合、同じインデックスを持つ条件がグループを形成し、evaluation_modeの代わりにグループ単位の評価が行われます。
        group_logic:
          type: string
          enum:
            - AND
            - OR
          default: AND
          description: グループ「内」で条件をどのように組み合わせるかを指定します。
        groups_logic:
          type: string
          enum:
            - AND
            - OR
          default: OR
          description: グループ「間」で各グループの結果をどのように組み合わせるかを指定します。最初の条件から読み取られます。
      description: 条件は評価対象の取引のみを読み取ります。集計ウィンドウを絞り込むことはありません。
    TransactionRuleAggregation:
      type: object
      required:
        - value
      properties:
        metric:
          type: string
          enum:
            - count
            - sum
            - max
            - min
            - avg
            - distinct_count
          default: count
          description: 一致する過去の取引の集計方法。unique_countはdistinct_countの別名として受け付けられます。
        field:
          type: string
          default: amount
          description: sum/max/min/avg/distinct_countで集計するフィールド。countでは無視されます。
        operator:
          type: string
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
          default: eq
          description: 算出された指標に適用される比較。
        value:
          type: number
          description: 算出された指標と比較されるしきい値。
        window:
          type: string
          pattern: ^\d+(m|h|d)$
          default: 1d
          description: >-
            取引のtxn_dateを終点とする遡及期間: <N>m（月ではなく分）、<N>h（時間）、または<N>d（日）。例:
            30m、24h、7d、30d。
        filters:
          type: object
          additionalProperties: true
          description: >-
            集計の対象となる過去の取引を絞り込みます。キーは条件フィールドカタログのフィールドパスです。値に"__current__"を指定すると、評価中の取引における同じフィールドの値に解決されます（例:
            {"subject_vendor_data":
            "__current__"}は期間を同一の対象者に限定します）。リスト値は、そのいずれかに含まれることを意味します。フィルターの比較は等価または包含のみです。lt/gteのフィルターはないため、「10,000未満の過去の取引」のような範囲はここでは表現できません。範囲はメトリクス側で指定してください（メトリクスmaxと演算子ltを組み合わせると、期間内のすべての取引がしきい値未満であることを条件にできます）。
      description: >-
        ウィンドウ内のアプリケーションの過去の取引に対するベロシティチェックです。evaluation_modeにかかわらず、ルールが一致するにはすべての集計エントリーが一致する必要があります。集計が制約するのはウィンドウのみです。評価対象の取引はscopeとconditionsによって制約されるため、ルールでdirection、currency、transaction_typeを保証する場合は、その両方に同じ条件を繰り返し指定してください。
    TransactionRuleAction:
      oneOf:
        - $ref: '#/components/schemas/TransactionRuleActionAddScore'
        - $ref: '#/components/schemas/TransactionRuleActionChangeStatus'
        - $ref: '#/components/schemas/TransactionRuleActionAddTags'
        - $ref: '#/components/schemas/TransactionRuleActionAddNote'
        - $ref: '#/components/schemas/TransactionRuleActionAddToList'
        - $ref: '#/components/schemas/TransactionRuleActionOpenCase'
      discriminator:
        propertyName: type
        mapping:
          add_score: '#/components/schemas/TransactionRuleActionAddScore'
          change_status: '#/components/schemas/TransactionRuleActionChangeStatus'
          add_tags: '#/components/schemas/TransactionRuleActionAddTags'
          add_note: '#/components/schemas/TransactionRuleActionAddNote'
          add_to_list: '#/components/schemas/TransactionRuleActionAddToList'
          open_case: '#/components/schemas/TransactionRuleActionOpenCase'
      description: >-
        ルールのアクション1件です。1つのルールに複数のアクションを設定でき、ルールに一致した場合はすべてが同時に適用されます。TESTモードのルールは、アクションを一切適用せずに、実行していたはずの内容を記録します。
    TransactionRuleActionAddScore:
      type: object
      required:
        - type
        - value
      properties:
        type:
          type: string
          enum:
            - add_score
        value:
          type: integer
          description: 取引のリスクスコアに加算されるポイント。負の値になる場合があります。
      description: 取引の累積リスクスコアにポイントを加算します。合計値に応じて、アプリケーションのレビュー/却下のしきい値に基づきステータスが決まります。
    TransactionRuleActionChangeStatus:
      type: object
      required:
        - type
        - value
      properties:
        type:
          type: string
          enum:
            - change_status
        value:
          type: string
          enum:
            - APPROVED
            - IN_REVIEW
            - DECLINED
            - AWAITING_USER
          description: 'スコアに関係なく、即時に設定するステータス。エイリアスキー: status。'
        workflow_id:
          type: string
          format: uuid
          description: >-
            値がAWAITING_USERの場合は必須です。対象者に完了を求める認証ワークフローです。エイリアスキー:
            remediation_workflow_id。ルールが発動すると、Diditは対象者向けにホスト型の是正セッションを作成します。
      description: 取引ステータスを直接設定します。一致した複数のルールの間では、常にDECLINEDが優先されます。
    TransactionRuleActionAddTags:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - add_tags
        tag_uuid:
          type: string
          format: uuid
          description: 付与する既存のアプリケーションタグです。
        tag_name:
          type: string
          description: 付与するタグ名。初回使用時に作成されます(大文字で保存)。tag_uuidまたはtag_nameのいずれかを指定してください。
        tag_color:
          type: string
          description: 'tag_nameで新しいタグを作成する際に使用する16進カラーコードです。例: #007AFE。'
      description: 一致した取引にアプリケーションタグを付けます。
    TransactionRuleActionAddNote:
      type: object
      required:
        - type
        - note
      properties:
        type:
          type: string
          enum:
            - add_note
        note:
          type: string
          description: '取引に添付されたメモのテキスト（作成者: Rule Engine）。エイリアスキー: value。'
      description: 一致した取引に自動アナリストメモを添付します。
    TransactionRuleActionAddToList:
      type: object
      required:
        - type
        - list_id
      properties:
        type:
          type: string
          enum:
            - add_to_list
        list_id:
          type: string
          format: uuid
          description: サブジェクトのvendor_dataを追加するリスト。
      description: 対象者のvendor_dataをブロックリスト、許可リスト、またはカスタムリストに追加します。
    TransactionRuleActionOpenCase:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - open_case
        blueprint:
          type: string
          format: uuid
          description: ケースブループリントのUUID。デフォルトはアプリケーションのデフォルトブループリントです。
        grouping:
          type: string
          enum:
            - by_applicant
            - by_rule_and_applicant
          description: 繰り返しの一致を申請者ごとに1つのケースにまとめるか、ルールと申請者の組み合わせごとに1つのケースにまとめるかです。
        attach_matched_transaction:
          type: boolean
          description: 一致した取引をケースに添付します。
      description: 調査ケースを開きます（または既存のケースに追加します）。1つのルールでは、最初のopen_caseアクションのみが適用されます。
  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.