> ## 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 /programmatic/login/でヘッドレス認証を実行し、2FAなしでアクセストークンを直接返します。エージェントネイティブでMCPに対応し、料金は従量課金制です。



プログラムによるログインのプロンプト
        プロンプトをクリップボードにコピー



      
      

\<pre>

\`Exchange a verified Didit account's email + password for a fresh JWT access token (headless, no browser).

Endpoint:
POST https://apx.didit.me/auth/v2/programmatic/login/

Authentication:
None. Email + password is the credential.

Request body:
\- email (string, required) — Same email used at /programmatic/register/.
\- password (string, required) — Plain password (HTTPS only).

Account requirements:
The account must have a verified email and password. Accounts created through POST /programmatic/register/ work immediately after email verification. Console-created email/password accounts can also use this endpoint. OAuth-only console accounts must set a password first.

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

Response (200 OK):
\- access_token (string) — RS256 JWT. Pass as "Authorization: Bearer <access_token>" on every Account Management endpoint at apx.didit.me/auth/v2. DO NOT use against verification.didit.me — that host uses x-api-key.
\- refresh_token (string) — RS256 JWT for refresh flows.
\- expires_in (integer) — Default 86400 (24 hours).

Token shape:
\- 24-hour default lifetime.
\- RS256-signed.
\- No browser session is required.

Brute-force protection:
\- Progressive account lockout per email: 5 consecutive failures = 15 min lockout, 10 = 1 hour, 20 = 24 hours.
\- Per-IP rate limit: 20 attempts/minute and 100 attempts/hour.

Failure modes:
\- 400 — { "email": ["..."] } / { "password": ["..."] } field-level errors.
\- 401 — { "detail": "Invalid email or password." }
\- 403 — { "detail": "..." } when SSO policy blocks password login for the account.
\- 429 — { "detail": "Too many login attempts.", "wait": <seconds> } on lockout or per-IP limit. Honour the wait value before retrying.

Recovering your api_key:
After a successful login, call GET /organizations/me/ to enumerate organizations and applications, then GET /organizations/me/{org_id}/applications/{app_id}/ to read the api_key — see /auth-api/get-credentials.

Where to use access_token vs api_key:
\- access_token (Bearer) → https://apx.didit.me/auth/v2/... (org / app management).
\- api_key (x-api-key) → https://verification.didit.me/v3/... (sessions, workflows, billing).

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

\</pre>



      
      

貼り付け先



## OpenAPI

````yaml ja/openapi-auth.json POST /programmatic/login/
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/login/:
    post:
      tags:
        - Programmatic Auth
      summary: プログラムによるログイン
      description: >-
        認証済みのメールアドレス/パスワード方式のDiditアカウントを認証し、RS256のJWTペア（デフォルトの有効期間は86400秒）を受け取ります。コンソールで作成したメールアドレス/パスワード方式のアカウントはこのエンドポイントを利用できます。OAuthのみのコンソールアカウントは、先にパスワードを設定する必要があります。
      operationId: programmatic_login
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
            examples:
              Default:
                summary: プログラムによるログイン
                value:
                  email: you@yourdomain.com
                  password: MyStr0ng!Pass
      responses:
        '200':
          description: >-
            ログインに成功しました。新しいJWTペアを返します。`access_token`を`Authorization: Bearer
            <token>`として`/organizations/me/...`に対して使用し、`org_id`、`app_id`、`api_key`を取得します。アカウントに認証アプリまたはパスキーが設定されている場合、レスポンスにはトークンの代わりに`2fa_required:
            true`と`temp_token`が含まれます。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoginResponse'
              examples:
                Success:
                  value:
                    access_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                    refresh_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                    expires_in: 86400
                    message: Login successful
        '400':
          description: バリデーションエラー。リクエストボディにフィールド単位の問題があります。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                MissingFields:
                  summary: 空のボディ
                  value:
                    email:
                      - This field is required.
                    password:
                      - This field is required.
                InvalidEmail:
                  summary: メールの形式が不正です
                  value:
                    email:
                      - Enter a valid email address.
        '401':
          description: 認証が拒否されました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
              examples:
                InvalidCredentials:
                  summary: メールアドレスとパスワードが一致しませんでした（ユーザー列挙を防ぐため、アカウントが存在しない場合にも返されます）
                  value:
                    detail: Invalid email or password.
                NotVerified:
                  summary: アカウントは存在しますが、メールアドレスがまだ認証されていません
                  value:
                    detail: Please verify your email address before logging in.
                SSORequired:
                  summary: アカウントがSSOを必須とする組織に属しています
                  value:
                    detail:
                      error: sso_required
                      message: Your organization 'Acme Corp' requires SSO login.
                      organization_name: Acme Corp
                      organization_slug: acme-corp
                      sso_url: /sso/acme-corp
        '403':
          description: >-
            アカウントは復旧されました。ログインする前に新しいサインイン方法を設定する必要があります。設定用のリンクがアカウントのメールアドレスに送信されました。組織がSSOを強制しているアカウントには、`error:
            sso_required`、`organization_name`、`organization_slug`、`sso_url`を含む`403`が返されます。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecoverySetupRequiredError'
              examples:
                RecoverySetupRequired:
                  summary: サインイン方法がまだ設定されていない復旧済みアカウント
                  value:
                    recovery_setup_required: true
                    setup_link_sent: true
                    message: >-
                      You recovered your account. Open the link we emailed you
                      to set up a new sign-in method.
                    code: recovery_setup_required
        '429':
          description: >-
            アカウントがロックされている（このメールアドレスで最近の失敗が多すぎる）か、IPがレート制限されている（このアドレスからの試行が多すぎる）場合です。サービスが同時に確認できる上限までパスワードやコードを確認している間も、`Retry-After:
            5`ヘッダーとともに返されます。示された秒数が経過してから再試行してください。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
              examples:
                AccountLocked:
                  summary: 段階的ロックアウトが発動
                  value:
                    detail: >-
                      Account temporarily locked due to too many failed login
                      attempts. Please try again later.
                IPRateLimited:
                  summary: このIPから1分あたり20件または1時間あたり100件を超えるリクエスト
                  value:
                    detail: >-
                      Too many login attempts from this IP address. Please wait
                      before trying again.
                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/login/ \
              -H "Content-Type: application/json" \
              -d '{
                "email": "you@yourdomain.com",
                "password": "MyStr0ng!Pass"
              }'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

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

            result = client.account.login(
                email="you@yourdomain.com",
                password="MyStr0ng!Pass",
            )
            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.login({
              email: "you@yourdomain.com",
              password: "MyStr0ng!Pass",
            });
            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.Login(ctx, didit.LoginRequest{\n\tEmail:    \"you@yourdomain.com\",\n\tPassword: \"MyStr0ng!Pass\",\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.LoginRequest;

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

            var result = client.account().login(LoginRequest.builder()
                    .email("you@yourdomain.com")
                    .password("MyStr0ng!Pass")
                    .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->login([
                'email' => 'you@yourdomain.com',
                'password' => 'MyStr0ng!Pass',
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

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

            result = didit.account.login(
              email: "you@yourdomain.com",
              password: "MyStr0ng!Pass"
            )
            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.LoginAsync(new LoginRequest
            {
                Email = "you@yourdomain.com",
                Password = "MyStr0ng!Pass",
            });
            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    LoginRequest:
      type: object
      required:
        - email
        - password
      properties:
        email:
          type: string
          format: email
          example: you@yourdomain.com
        password:
          type: string
          example: MyStr0ng!Pass
    LoginResponse:
      type: object
      properties:
        access_token:
          type: string
          description: >-
            RS256で署名されたJWT。アカウント管理エンドポイントでは`Authorization: Bearer
            <token>`として使用します。
        refresh_token:
          type: string
        expires_in:
          type: integer
          description: アクセストークンの有効期間（秒）。デフォルトは86400です。
          example: 86400
        message:
          type: string
          example: Login successful
    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.
    AuthError:
      type: object
      description: 認証/認可/未検出エラーのエンベロープ。
      properties:
        detail:
          type: string
          example: Invalid access token
    RecoverySetupRequiredError:
      type: object
      description: >-
        アカウントは復旧されましたが、サインイン方法がまだ設定されていません。トークンは発行されません。新しい方法を設定するためのワンタイムリンクがアカウントのメールアドレスに送信されました。リンクを開いて方法を設定してから、再度ログインしてください。
      required:
        - recovery_setup_required
        - setup_link_sent
        - message
        - code
      properties:
        recovery_setup_required:
          type: boolean
          example: true
        setup_link_sent:
          type: boolean
          example: true
        message:
          type: string
          example: >-
            You recovered your account. Open the link we emailed you to set up a
            new sign-in method.
        code:
          type: string
          enum:
            - recovery_setup_required
          example: recovery_setup_required
    RateLimitError:
      type: object
      description: レート制限または段階的ロックアウトのレスポンスです。`wait`はクールダウン時間（秒）です。
      properties:
        detail:
          type: string
          example: >-
            Too many login attempts from this IP address. Please wait before
            trying again.

````

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