> ## 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認証情報を取得

> DiditのPOST /programmatic/verify-email/ でメールアドレスを確認し、アクセストークンとclient_id、api_keyを取得します。エージェントネイティブなオンボーディング、従量課金制。



メールアドレス認証と認証情報取得のプロンプト
        プロンプトをクリップボードにコピー



      
      

\<pre>

\`Exchange the email verification code for usable Didit credentials — step 2 of programmatic onboarding.

Endpoint:
POST https://apx.didit.me/auth/v2/programmatic/verify-email/

Authentication:
None. The email + code pair is the credential.

Request body:
\- email (string, required) — Same email used in /programmatic/register/.
\- code (string, required) — 6-character alphanumeric code from the registration email (e.g. "A3K9F2"). Valid for 15 minutes.

curl example:
curl -X POST https://apx.didit.me/auth/v2/programmatic/verify-email/ \
-H "Content-Type: application/json" \
-d '{
"email": "you@yourdomain.com",
"code": "A3K9F2"
}'

Response (200 OK):
\{
"access_token": "eyJ...RS256 JWT",
"refresh_token": "eyJ...RS256 JWT",
"expires_in": 86400,
"organization": {
"uuid": "a1b2c3d4-5678-...",
"name": "you"
},
"application": {
"uuid": "b2c3d4e5-6789-...",
"name": "you",
"client_id": "S9LIYGSoWNuGMLHsvEt9dQ",
"api_key": "sk_live_example_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}

What happens server-side:
1\. The pending account is marked email-verified.
2\. A default organization is created (named after the local part of the email, e.g. "you" from "you@yourdomain.com").
3\. A default application is created inside the organization with a fresh client_id and api_key.
4\. JWTs are issued (RS256, default 24h / 86400 seconds lifetime).

How to use the response:
\- application.api_key → set as the x-api-key header on EVERY call to https://verification.didit.me/v3/... (sessions, workflows, questionnaires, billing, etc.). PERSIST IT SECURELY. You can read it again later with GET /organizations/me/{org_id}/applications/{app_id}/.
\- access_token → use as "Authorization: Bearer <access_token>" against Account Management endpoints on https://apx.didit.me/auth/v2 (e.g. to create more applications).
\- refresh_token → exchange for a new access_token after expiry.

Save the api_key, the organization.uuid (org_id), and the application.uuid (app_id) — you will need all three to manage applications later.

Failure modes (400 unless noted):
\- Field-level: { "email": ["Enter a valid email address."] } or { "code": ["Ensure this field has at least 6 characters."] }.
\- Wrong or expired code CURRENTLY returns a BARE ARRAY ["Invalid or expired verification code."] — known server-side inconsistency; treat as { "code": [...] } client-side.
\- Unknown email: { "detail": "User not found." }

Recovery if you lose the api_key later:
Call POST /programmatic/login/ with email + password to get a fresh access_token, then GET /organizations/me/{org_id}/applications/{app_id}/ to read the api_key back. See /auth-api/login and /auth-api/get-credentials.

For end-to-end Didit integration, paste in the full prompt at /integration/integration-prompt.`

\</pre>



      
      

貼り付け先



## OpenAPI

````yaml ja/openapi-auth.json POST /programmatic/verify-email/
openapi: 3.0.0
info:
  version: 1.0.0
  title: Didit Auth API
  description: >-
    開発者とAIエージェント向けの、プログラムによる登録・認証APIです。2回のAPI呼び出しで登録でき、ブラウザは不要です。最もエージェントに適した本人確認プラットフォームです。


    ## ベースURL


    この仕様のすべてのエンドポイントは`https://apx.didit.me/auth/v2`でホストされています。これは検証API（`https://verification.didit.me/v3`）とは別のホストです。両者を混同しないでください。この認証ホストは**JWTアクセストークン**を発行し、**組織**と**アプリケーション**の一覧表示と管理を行えます。検証ホストはセッション、ワークフロー、AMLなどを呼び出す先であり、このAPIが返す**`api_key`**で認証します。


    ## 認証フローの仕組み


    1. `POST /programmatic/register/`：メールアドレスとパスワードを送信します。

    2. 6文字の英数字のコードをメールで受け取ります。

    3. `POST
    /programmatic/verify-email/`：コードを送信します。JWTの`access_token`、`refresh_token`、組織、および`client_id`と`api_key`を持つデフォルトのアプリケーションが返されます。

    4.
    `api_key`を保存します。`https://verification.didit.me/v3/...`へのすべての呼び出しで`x-api-key`として使用します。

    5. 今後は任意のマシンから、`POST /programmatic/login/`でメールアドレスとパスワードを新しいJWTと交換し、続けて`GET
    /organizations/me/`とアプリケーションのエンドポイントを呼び出して、認証情報を復元またはローテーションできます。


    JWTが必要なのは、この仕様の**アカウント管理**エンドポイントだけです。検証APIのトラフィックにはJWTではなく、長期間有効な`api_key`を使用します。


    ## 規約


    - すべてのリクエストボディとレスポンスボディはJSON（`Content-Type: application/json`）です。

    - **`POST /programmatic/register/`をテストする際は、実在する配信可能なメールアドレスを使用してください。**
    このエンドポイントは認証コードを同期的に送信するため、予約済みのテスト用ドメイン（`@example.com`、`@example.org`、`@*.test`、`@*.example`、`@*.invalid`）のアドレスはメール配信で拒否され、リクエストは`500`を返します。サンプル内のプレースホルダー`you@yourdomain.com`は、実際に読める受信箱に置き換えてください。

    - バリデーションエラーはHTTP `400`で、2種類のエンベロープのいずれかを返します。フィールド単位の問題には`{"field":
    ["message", ...]}`、ビジネスルールのエラーには`{"detail":
    "message"}`です。一部のバリデーター（登録時のパスワード強度、verify-emailでのコードの有効期限）は現在、フィールドをキーとする形式ではなく、単純な配列`["message"]`で応答します。これはサーバー側の既知の不整合のため、クライアントコードは両方の形式を受け入れる必要があります。

    - 認証エラーは、HTTP
    `401`（無効なBearerトークン）または`403`（Bearerトークンがない、または権限不足）とともに`{"detail":
    "..."}`として返されます。

    - レート制限のレスポンスには、クールダウン時間を秒単位で示す`wait`フィールドが含まれます。
servers:
  - url: https://apx.didit.me/auth/v2
    description: 本番環境の認証サーバー
security: []
tags:
  - name: Programmatic Auth
    description: >-
      メールアドレスとパスワードによるアカウントのライフサイクル：登録、認証、ログイン。Account
      Managementエンドポイントで使用するJWTの`access_token`を返します。また、認証時には最初のアプリケーションの`client_id`と`api_key`も返します。
  - name: Account Management
    description: >-
      組織の一覧取得と、アプリケーションの作成・取得・更新を行う認証付きエンドポイント（JWT
      Bearer）です。検証API呼び出しの認証に使用する`api_key`の再取得やローテーションに利用します。
paths:
  /programmatic/verify-email/:
    post:
      tags:
        - Programmatic Auth
      summary: メールアドレスを認証して認証情報を発行する
      description: >-
        オンボーディングのステップ2。6文字のコードを、認証済みアカウント、デフォルトの組織とアプリケーション、JWTペアと交換します。返された`api_key`は保存してください。
      operationId: programmatic_verify_email
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VerifyEmailRequest'
            examples:
              Default:
                summary: 登録メールに記載されたコードを送信する
                value:
                  email: you@yourdomain.com
                  code: A3K9F2
      responses:
        '200':
          description: >-
            メールアドレスが認証されました。レスポンスには、この認証APIのトークンと、新しく作成されたアプリケーションの`client_id`および`api_key`が含まれます。`api_key`は安全に保存してください。これはすべての検証API呼び出しで使用される長期的な認証情報です。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerifyEmailResponse'
              examples:
                Success:
                  value:
                    access_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                    refresh_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                    expires_in: 86400
                    organization:
                      uuid: a1b2c3d4-5678-90ab-cdef-111111111111
                      name: developer
                    application:
                      uuid: b2c3d4e5-6789-01bc-defg-222222222222
                      name: developer
                      client_id: S9LIYGSoWNuGMLHsvEt9dQ
                      api_key: sk_live_example_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        '400':
          description: >-
            バリデーションエラー。想定されるエンベロープは、フィールド単位の問題では`{"field":
            ["..."]}`、ビジネスルールのエラー（例: ユーザーが見つからない）では`{"detail":
            "..."}`です。コードが誤っている、または期限切れの場合のエラーは現在、素の配列`["Invalid or expired
            verification code."]`で返されます。これはサーバー側の既知の不整合です。修正されるまでは`{"code":
            ["..."]}`として扱ってください。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                MissingFields:
                  summary: 空のボディ
                  value:
                    email:
                      - This field is required.
                    code:
                      - This field is required.
                CodeTooShort:
                  summary: 6文字未満のコード
                  value:
                    code:
                      - Ensure this field has at least 6 characters.
                InvalidEmail:
                  summary: メールの形式が不正です
                  value:
                    email:
                      - Enter a valid email address.
                InvalidCode:
                  summary: コードが正しくないか、期限切れです
                  value:
                    - Invalid or expired verification code.
                UserNotFound:
                  summary: そのメールアドレスの保留中のアカウントはありません
                  value:
                    detail: User not found.
        '429':
          description: >-
            サービスは一時的に、同時に確認できる上限までパスワードまたはコードを確認しています。`Retry-After:
            5`ヘッダー付きで返されます。指定された秒数が経過してから再試行してください。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
              examples:
                PasswordChecksBusy:
                  summary: 進行中のパスワードチェックが多すぎます
                  value:
                    detail: >-
                      Too many sign-in attempts are being processed right now.
                      Please try again in a few seconds.
      security:
        - {}
      x-codeSamples:
        - lang: curl
          label: cURL
          source: >-
            curl -X POST https://apx.didit.me/auth/v2/programmatic/verify-email/
            \
              -H "Content-Type: application/json" \
              -d '{
                "email": "you@yourdomain.com",
                "code": "A3K9F2"
              }'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # This call needs no API key.
            client = Didit()

            result = client.account.verify_email(
                email="you@yourdomain.com",
                code="A3K9F2",
            )
            print(result)
        - lang: javascript
          label: Node.js
          source: |-
            import Didit from "@didit-protocol/sdk-node";

            // This call needs no API key.
            const didit = new Didit();

            const result = await didit.account.verifyEmail({
              email: "you@yourdomain.com",
              code: "A3K9F2",
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// This call needs no API key.\nclient := didit.NewClient()\n\nresult, err := client.Account.VerifyEmail(ctx, didit.VerifyEmailRequest{\n\tEmail: \"you@yourdomain.com\",\n\tCode:  \"A3K9F2\",\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.VerifyEmailRequest;


            // This call needs no API key.

            Didit client = new Didit();


            var result =
            client.account().verifyEmail(VerifyEmailRequest.builder()
                    .email("you@yourdomain.com")
                    .code("A3K9F2")
                    .build());
            System.out.println(result);
        - lang: php
          label: PHP
          source: |-
            <?php

            require 'vendor/autoload.php';

            use Didit\DiditClient;

            // This call needs no API key.
            $didit = new DiditClient();

            $result = $didit->account->verifyEmail([
                'email' => 'you@yourdomain.com',
                'code' => 'A3K9F2',
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

            # This call needs no API key.
            didit = Didit::Client.new

            result = didit.account.verify_email(
              email: "you@yourdomain.com",
              code: "A3K9F2"
            )
            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Text.Json;

            using Didit;


            // This call needs no API key.

            using var client = new DiditClient();


            var result = await client.Account.VerifyEmailAsync(new
            VerifyEmailRequest

            {
                Email = "you@yourdomain.com",
                Code = "A3K9F2",
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    VerifyEmailRequest:
      type: object
      required:
        - email
        - code
      properties:
        email:
          type: string
          format: email
          description: '`POST /programmatic/register/`で使用したメールアドレス。'
          example: you@yourdomain.com
        code:
          type: string
          minLength: 6
          maxLength: 6
          description: 認証メールに記載された6文字の英数字コード。コードは、最後にコードが送信されてから10分後に期限切れになります。
          example: A3K9F2
    VerifyEmailResponse:
      type: object
      properties:
        access_token:
          type: string
          description: >-
            RS256で署名されたJWT。`apx.didit.me/auth/v2`のアカウント管理エンドポイントでは`Authorization:
            Bearer <token>`として使用します。
        refresh_token:
          type: string
          description: アクセストークンと対になるリフレッシュトークン。
        expires_in:
          type: integer
          description: アクセストークンの有効期間（秒）。デフォルトは86400です。
          example: 86400
        organization:
          $ref: '#/components/schemas/OrganizationSummary'
        application:
          $ref: '#/components/schemas/ApplicationCredentialsSummary'
    ValidationError:
      description: >-
        検証エラーのボディ。想定されるエンベロープは、フィールドレベルのエラーには`{field: ["message",
        ...]}`マップ、ビジネスルールのエラーには単一キーの`{detail:
        "..."}`エンベロープです。一部のバリデーター（登録時のパスワード強度、verify-emailでのコードの有効性）は現在、素の配列`["message"]`で応答します。これはサーバー側の既知の不整合です。以下のスキーマでは、この仕様から生成されたクライアントコードが現在のレスポンスをデシリアライズできるよう、この素の配列の分岐を残していますが、新しいクライアントコードでは該当するフィールドキー形式（`{password:
        [...]}`または`{code: [...]}`）として扱ってください。サーバーの仕様は最終的にその形式に統一されます。
      oneOf:
        - type: object
          additionalProperties:
            type: array
            items:
              type: string
          example:
            email:
              - Enter a valid email address.
        - type: object
          properties:
            detail:
              type: string
          example:
            detail: An account with this email already exists.
        - type: array
          items:
            type: string
          example:
            - Invalid or expired verification code.
    RateLimitError:
      type: object
      description: レート制限または段階的ロックアウトのレスポンスです。`wait`はクールダウン時間（秒）です。
      properties:
        detail:
          type: string
          example: >-
            Too many login attempts from this IP address. Please wait before
            trying again.
    OrganizationSummary:
      type: object
      description: '`POST /programmatic/verify-email/`がインラインで返す、最小限の組織形式です。'
      properties:
        uuid:
          type: string
          format: uuid
          example: a1b2c3d4-5678-90ab-cdef-111111111111
        name:
          type: string
          example: developer
    ApplicationCredentialsSummary:
      type: object
      description: >-
        `POST
        /programmatic/verify-email/`がインラインで返す、最小限のアプリケーション形式です。`api_key`はすぐに保存してください。
      properties:
        uuid:
          type: string
          format: uuid
          example: b2c3d4e5-6789-01bc-defg-222222222222
        name:
          type: string
          example: developer
        client_id:
          type: string
          example: S9LIYGSoWNuGMLHsvEt9dQ
        api_key:
          type: string
          description: >-
            すべての検証API呼び出しで`x-api-key`として使用します。新しいキーは`sk_live_`（本番環境のアプリケーション）または`sk_test_`（サンドボックスのアプリケーション）で始まり、その後にURLセーフな43文字（英字、数字、`-`、`_`）が続きます。この形式より前に作成されたキーにはプレフィックスがなく、引き続きそのまま使用できます。
          example: sk_live_example_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

````

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