> ## 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のPOST /v3/biometric-templates/delete/で、保持中の顔の生体認証テンプレートをIDリスト指定、またはフィルターに一致する全件を一括削除できます。テンプレート単位で冪等です。

1回の呼び出しで複数のテンプレートを削除します。明示的なIDのリストまたは`delete_all: true`のいずれかを指定します。必要に応じて、[生体認証テンプレートの一覧取得](https://docs.didit.me/ja/management-api/biometric-templates/list.md)と同じフィルターで対象を絞り込めます。

## リクエストボディ

| フィールド | 型 | 説明 |
| - | - | - |
| `template_uuids` | UUID\[] | 削除するテンプレート。`delete_all`が`true`でない限り必須です。すでに削除済みのIDは`already_purged`として報告されます。 |
| `delete_all` | boolean | `true`の場合、以下のフィルターに一致するすべてのテンプレートを削除します(フィルターを指定しない場合はアプリケーションのすべてのテンプレート)。`template_uuids`は無視されます。 |
| `vendor_data` | string | `delete_all`使用時のみ：所有するユーザーの`vendor_data`に対する、大文字と小文字を区別しない部分一致 |
| `vendor_user_uuid` | UUID | `delete_all`使用時のみ：所有するユーザーとの完全一致 |
| `status` | enum | `delete_all`使用時のみ：`pending`、`active`、`expired`、`held_out_of_use`、`purge_pending`、`purge_failed` |
| `source_type` | enum | `delete_all`使用時のみ：`session_delete`、`automatic_retention`、`backfill` |
| `retained_from`, `retained_to` | datetime | `delete_all`使用時のみ：保持日の範囲 |

> [!WARNING]
>
> フィルターなしで`delete_all: true`を指定すると、アプリケーション内のすべての生体認証テンプレートが削除され、元に戻すことはできません。先に同じフィルターで[生体認証テンプレートの件数取得](https://docs.didit.me/ja/management-api/biometric-templates/count.md)を実行し、削除対象を確認してください。

## 例

> [tab] IDで指定
>
> ```bash theme={null}
> curl -X POST https://verification.didit.me/v3/biometric-templates/delete/ \
>   -H "x-api-key: YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{"template_uuids": ["9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"]}'
> ```

> [tab] 1人のユーザーのすべてのテンプレート
>
> ```bash theme={null}
> curl -X POST https://verification.didit.me/v3/biometric-templates/delete/ \
>   -H "x-api-key: YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{"delete_all": true, "vendor_user_uuid": "2f7c1a9e-8b4d-4c6a-9e1f-3d5b7a9c1e2f"}'
> ```

> [tab] アプリケーション内のすべてのテンプレート
>
> ```bash theme={null}
> curl -X POST https://verification.didit.me/v3/biometric-templates/delete/ \
>   -H "x-api-key: YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{"delete_all": true}'
> ```

```json theme={null}
{
  "results": [
    { "uuid": "9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b", "outcome": "purged" },
    { "uuid": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d", "outcome": "already_purged" }
  ]
}
```

テンプレートは1件ずつ削除され、各結果では`purged`または`already_purged`が返されます。生体認証ストアが利用できない場合、最初に失敗したテンプレートの時点でリクエストは`503`を返します。同じリクエスト内でそれより前に削除されたテンプレートは削除されたままとなり、失敗したテンプレートは`purge_failed`に移行します(照合の対象からはすでに除外されています)。リクエストを再度実行すると処理が完了します。

## エラー

| ステータス | 発生条件 | ボディ |
| - | - | - |
| `400` | `template_uuids`と`delete_all: true`のどちらも指定されていない | `{"template_uuids": ["This field is required unless delete_all is true."]}` |
| `400` | フィルターの値が無効、または`retained_to`が`retained_from`より前 | フィールドごとのバリデーションエラー |
| `403` | コンソールユーザートークンが使用されている、またはAPIキーが許可されていない | `{"detail": "You do not have permission to perform this action."}` |
| `503` | 生体認証ストアが利用できなかった。リクエストを再試行してください | `{"detail": "The biometric-template operation could not finish because an external store is unavailable. The operation is retryable."}` |


## OpenAPI

````yaml ja/openapi-25.json POST /v3/biometric-templates/delete/
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/biometric-templates/delete/:
    post:
      tags:
        - Biometric Templates
      summary: 保持されている生体認証テンプレートを一括削除
      description: >-
        オプトインしたアプリケーションは、セッションが削除されたとき（`DELETE
        /v3/session/{sessionId}/delete/`を参照）、ユーザーに紐づけて、個別に管理される画像を含まない顔の生体認証テンプレートを1つ保持します。テンプレートは有限の`expires_at`を持つ生体データです。画像、セッションデータ、本人情報のフィールドは一切含まず、ユーザーの削除、プライバシー消去、有効期限切れ、または明示的なパージによって完全に削除されます。これらのエンドポイントはアプリケーションのAPIキー（`x-api-key`）のみを受け付け、Business
        Consoleのユーザートークンは`403`で拒否されます。


        1回の呼び出しで複数のテンプレートをパージします。IDのリストを明示的に指定するか、`delete_all:
        true`を指定します（後者は一覧エンドポイントと同じフィルターで任意に絞り込めます）。テンプレートは1件ずつパージされ、各結果は`purged`または`already_purged`を報告します。生体データストアが利用できない場合、最初に失敗したテンプレートの時点で`503`が返されます。このリクエストで先にパージされたテンプレートはパージされたままとなり、失敗したテンプレートは`purge_failed`に移行し（照合対象からは既に除外済み）、同じリクエストを繰り返すと処理が完了します。


        **フィルターなしの`delete_all:
        true`はアプリケーション内のすべての生体認証テンプレートをパージし、元に戻すことはできません。**先に同じフィルターでカウントエンドポイントを実行してください。
      operationId: bulk_purge_biometric_templates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_uuids:
                  type: array
                  items:
                    type: string
                    format: uuid
                  minItems: 1
                  description: >-
                    完全に削除するテンプレート。`delete_all`が`true`でない限り必須です。すでに削除済みのIDは`already_purged`として報告されます。
                delete_all:
                  type: boolean
                  default: false
                  description: >-
                    `true`の場合、以下のフィルターに一致するすべてのテンプレートを完全に削除します（フィルターを指定しない場合は、アプリケーションのすべてのテンプレートが対象です）。`template_uuids`は無視されます。元に戻すことはできません。
                vendor_data:
                  type: string
                  description: >-
                    `delete_all`の場合のみ:
                    所有ユーザーの`vendor_data`に対する、大文字と小文字を区別しない部分文字列一致です。
                vendor_user_uuid:
                  type: string
                  format: uuid
                  description: '`delete_all`を指定した場合のみ: 所有者であるユーザーとの完全一致。'
                status:
                  type: string
                  enum:
                    - pending
                    - active
                    - expired
                    - held_out_of_use
                    - purge_pending
                    - purge_failed
                  description: '`delete_all`の場合のみ。'
                source_type:
                  type: string
                  enum:
                    - session_delete
                    - automatic_retention
                    - backfill
                  description: '`delete_all`の場合のみ。'
                retained_from:
                  type: string
                  format: date-time
                  description: '`delete_all`の場合のみ。'
                retained_to:
                  type: string
                  format: date-time
                  description: '`delete_all`の場合のみ。`retained_from`より前の値は指定できません。'
            examples:
              By id:
                value:
                  template_uuids:
                    - 9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b
                    - 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
              Every template of one User:
                value:
                  delete_all: true
                  vendor_user_uuid: 2f7c1a9e-8b4d-4c6a-9e1f-3d5b7a9c1e2f
              Every template in the application:
                value:
                  delete_all: true
      responses:
        '200':
          description: テンプレートごとのパージ結果です。
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        uuid:
                          type: string
                          format: uuid
                        outcome:
                          type: string
                          enum:
                            - purged
                            - already_purged
              examples:
                Mixed:
                  value:
                    results:
                      - uuid: 9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b
                        outcome: purged
                      - uuid: 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
                        outcome: already_purged
        '400':
          description: 検証エラー：何もパージされません。
          content:
            application/json:
              examples:
                Missing selector:
                  value:
                    template_uuids:
                      - This field is required unless delete_all is true.
                Bad range:
                  value:
                    retained_to:
                      - Must be on or after retained_from.
        '403':
          description: >-
            コンソールユーザートークンが使用されたか、APIキーが許可されていません。これらのエンドポイントはアプリケーションのAPIキーのみを受け付けます。
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    detail: You do not have permission to perform this action.
        '503':
          description: >-
            生体認証テンプレートの保持または消去中に、生体認証ストアが利用できませんでした。何も削除されていません。同じリクエストを再度送信してください。再試行は冪等で、単一のテンプレートに収束します。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              examples:
                Retryable:
                  value:
                    detail: >-
                      The biometric-template operation could not finish because
                      an external store is unavailable. The operation is
                      retryable.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X POST
            https://verification.didit.me/v3/biometric-templates/delete/ \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{"delete_all": true, "vendor_user_uuid": "2f7c1a9e-8b4d-4c6a-9e1f-3d5b7a9c1e2f"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.biometric_templates.batch_delete(
                template_uuids=["9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"],
            )
            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.biometricTemplates.batchDelete({
              template_uuids: ["9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"],
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.BiometricTemplates.BatchDelete(ctx, didit.BiometricTemplatesBatchDeleteParams{\n\tTemplateUUIDs: didit.Some([]string{\"9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b\", \"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d\"}),\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.BiometricTemplatesBatchDeleteParams;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.biometricTemplates().batchDelete(BiometricTemplatesBatchDeleteParams.builder()
                    .templateUuids(List.of("9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"))
                    .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->biometricTemplates->batchDelete([
                'template_uuids' => ['9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b', '1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d'],
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: >-
            require "didit"


            # Reads DIDIT_API_KEY.

            didit = Didit::Client.new


            result = didit.biometric_templates.batch_delete(template_uuids:
            ["9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b",
            "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"])

            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.BiometricTemplates.BatchDeleteAsync(new
            BiometricTemplatesBatchDeleteParams

            {
                TemplateUuids = new string[] { "9d2f4b6e-1c3a-4e8f-b7d5-0a1c2e3f4a5b", "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d" },
            });

            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.