> ## 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/address-validation/ 可确认地址是否存在，并返回标准化地址及坐标。支持结构化或单行输入，每个地址 $0.10。

Didit 的地址验证 API 用于确认邮寄地址是否存在，并返回标准化后的地址，包括投递行、地址组成部分和坐标。当您的后端拥有一个地址，并需要确认它是否存在以及以何种标准化形式存在时，请使用 `POST /v3/address-validation/`。

地址验证仅确认地址本身。它从不将地址与某个人关联：`verified` 结果表示该地点存在，但不代表有人居住在那里。

## 发送地址

请在 `address` 中以单行形式发送地址，或以结构化字段发送：`address_line_1`，并在有这些信息时提供 `address_line_2`、`city`、`region` 和 `postal_code`。切勿在同一请求中同时发送两种格式。`country` 始终为必填项，须为 ISO 3166-1 alpha-2 或 alpha-3 代码。

## 解读响应

* `address_validation.status` 是您应当依据的结果：
  * `verified`：地址已确认到楼栋（或套房、邮政信箱）。
  * `partially_verified`：地址仅确认到街道，或确认到邮政参考数据对该地点保存的最精确级别。
  * `not_verified`：仅匹配到地区或城市，或完全未匹配。
  * `unavailable`：无法执行验证。请稍后重试。
* `address_validation.verification_level` 是匹配到的最精确级别：`administrative_area`、`locality`、`thoroughfare`、`premise` 或 `delivery_point`。
* `address_validation.address` 和 `address_validation.formatted_address` 包含标准化后的地址，并按该国的书写习惯呈现。
* `address_validation.latitude` 和 `address_validation.longitude` 标示匹配地址的位置。
* `request_id` 用于标识该请求。不会创建会话，结果仅在本次响应中返回，因此请自行保存所需内容。

对于每个已完成的请求，HTTP 状态码均为 `200`，包括 `unavailable` 的情况。

## 工作流中的地址验证

同一验证功能也是身份证件验证和地址证明工作流步骤的附加功能。在该步骤的设置中开启 `address_validation_enabled` 后，系统会在读取人员上传的文件后，对其提供的地址（印在身份证件上的地址，或地址证明上的地址）进行一次验证。结果即为会话决策中该步骤对应条目（`id_verifications[]` 或 `poa_verifications[]`）里的 `address_validation` 对象。状态为 `partially_verified` 或 `not_verified` 的地址会触发 `ADDRESS_NOT_VERIFIED` 警告，其操作由该步骤的 `address_not_verified_action` 决定（默认为 `NO_ACTION`，仅记录该警告）。`unavailable` 的验证从不触发该警告，也从不改变验证结果。

## 沙盒行为

沙盒密钥会验证请求，并始终返回确定性的 `verified` 结果，该结果会回显您发送的地址。沙盒调用不消耗额度。

## 计费

每次地址验证 API 调用，按每个已验证地址收取 $0.10。`unavailable` 结果不收费。在工作流中，该附加功能按步骤验证的每个地址收取 $0.10。


## OpenAPI

````yaml zh/openapi-25.json POST /v3/address-validation/
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/address-validation/:
    post:
      tags:
        - Standalone APIs
      summary: 核验地址
      description: >-
        确认地址存在并获取规范化结果：其投递行、组成部分和坐标。该接口仅确认地址；绝不会将地址与个人关联。


        **请求。**将地址作为单行（`address`）或结构化字段（`address_line_1`，以及可选的
        `address_line_2`、`city`、`region`、`postal_code`）发送，不能同时使用两者，且必须提供其
        `country`（ISO 3166-1 alpha-2 或 alpha-3）。


        **结果。**`address_validation.status` 包括
        `verified`（已确认到建筑物）、`partially_verified`（仅确认到街道或更高级别）、`not_verified`（仅匹配到地区或城市，或完全未匹配）或
        `unavailable`（验证无法运行）。每个已完成的请求 HTTP 状态码均为 `200`，包括 `unavailable`；若结果为
        `unavailable`，请稍后重试。


        **计费。**生产环境调用按每条验证地址 $0.10 收费。结果为 `unavailable`
        时不收费。除使用记录外不存储任何内容：不会创建会话，且结果仅在此响应中返回。


        **沙盒。**沙盒密钥会验证请求并始终返回一个反映所发送地址的确定性 `verified` 结果，且不消耗额度。


        **身份验证。**在 `x-api-key` 中发送您应用的 API 密钥。缺失或无效的凭据将返回 `403`：此 API 绝不会返回
        `401`。


        **速率限制。**各 POST/PATCH/DELETE endpoint 间每个 API 密钥共享每分钟 300
        次请求的写入预算（创建交易和事件摄取具有单独的 600 次预算）。
      operationId: post_v3_address_validation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddressValidationRequest'
            examples:
              Structured:
                summary: 结构化地址字段
                value:
                  address_line_1: 1600 Amphitheatre Pkwy
                  city: Mountain View
                  region: CA
                  postal_code: '94043'
                  country: US
              One line:
                summary: 单行完整地址
                value:
                  address: Paseo de la Castellana 259, 28046 Madrid
                  country: ES
      responses:
        '200':
          description: 核验已完成。请读取 `address_validation.status`；已完成的请求其 HTTP 状态码始终为 `200`。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddressValidationResponse'
              examples:
                Verified:
                  summary: 真实地址，已确认至建筑物级别
                  value:
                    request_id: 6f7d2c1e-1c5a-4a1e-9b8f-2a1f0f4b9c3d
                    address_validation:
                      status: verified
                      verification_level: premise
                      address:
                        address_line_1: 1600 Amphitheatre Pkwy
                        address_line_2: null
                        city: Mountain View
                        region: CA
                        postal_code: 94043-1351
                        country: US
                      formatted_address: 1600 Amphitheatre Pkwy, Mountain View CA 94043-1351
                      latitude: 37.422022
                      longitude: -122.08429
                    created_at: '2026-10-27T11:20:00.000000+00:00'
                Not verified:
                  summary: 虚构的街道：仅城市匹配
                  value:
                    request_id: 0b9e3f4a-6c2d-4e8b-a1f7-5d3c2b1a0e9f
                    address_validation:
                      status: not_verified
                      verification_level: locality
                      address:
                        address_line_1: Calle Inventada Que No Existe 99999 28046
                        address_line_2: null
                        city: Madrid
                        region: Madrid
                        postal_code: null
                        country: ES
                      formatted_address: >-
                        Calle Inventada Que No Existe 99999 28046, Madrid,
                        MADRID, SPAIN
                      latitude: 40.42603054
                      longitude: -3.68645331
                    created_at: '2026-10-27T11:21:00.000000+00:00'
                Unavailable:
                  summary: 核验无法运行；未收取费用
                  value:
                    request_id: 3c1b2a0f-9e8d-4c7b-b6a5-1f0e9d8c7b6a
                    address_validation:
                      status: unavailable
                      verification_level: null
                      address: null
                      formatted_address: null
                      latitude: null
                      longitude: null
                    created_at: '2026-10-27T11:22:00.000000+00:00'
        '400':
          $ref: '#/components/responses/AddressValidationValidationError'
        '403':
          $ref: '#/components/responses/AddressValidationPermissionDenied'
        '429':
          $ref: '#/components/responses/RateLimitedWrite'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl -X POST https://verification.didit.me/v3/address-validation/ \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "address_line_1": "1600 Amphitheatre Pkwy",
                "city": "Mountain View",
                "region": "CA",
                "postal_code": "94043",
                "country": "US"
              }'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.address_validation.validate(
                address_line_1="1600 Amphitheatre Pkwy",
                city="Mountain View",
                region="CA",
                postal_code="94043",
                country="US",
            )
            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.addressValidation.validate({
              address_line_1: "1600 Amphitheatre Pkwy",
              city: "Mountain View",
              region: "CA",
              postal_code: "94043",
              country: "US",
            });
            console.log(result);
        - lang: java
          label: Java
          source: >-
            import me.didit.Didit;

            import me.didit.types.AddressValidationRequest;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.addressValidation().validate(AddressValidationRequest.builder()
                    .addressLine1("1600 Amphitheatre Pkwy")
                    .city("Mountain View")
                    .region("CA")
                    .postalCode("94043")
                    .country("US")
                    .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->addressValidation->validate([
                'address_line_1' => '1600 Amphitheatre Pkwy',
                'city' => 'Mountain View',
                'region' => 'CA',
                'postal_code' => '94043',
                'country' => 'US',
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

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

            result = didit.address_validation.validate(
              address_line_1: "1600 Amphitheatre Pkwy",
              city: "Mountain View",
              region: "CA",
              postal_code: "94043",
              country: "US"
            )
            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.AddressValidation.ValidateAsync(new
            AddressValidationRequest

            {
                AddressLine1 = "1600 Amphitheatre Pkwy",
                City = "Mountain View",
                Region = "CA",
                PostalCode = "94043",
                Country = "US",
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    AddressValidationRequest:
      type: object
      required:
        - country
      description: 一个地址：使用单行文本（`address`），或者至少包含 `address_line_1` 的结构化字段，两者不可兼有。
      properties:
        address:
          type: string
          maxLength: 500
          description: 单行完整地址。
          example: Paseo de la Castellana 259, 28046 Madrid
        address_line_1:
          type: string
          maxLength: 255
          description: 街道与门牌号。
          example: 1600 Amphitheatre Pkwy
        address_line_2:
          type: string
          maxLength: 255
          description: 公寓、套房、楼层或楼栋。
        city:
          type: string
          maxLength: 128
          description: 城市或地区。
          example: Mountain View
        region:
          type: string
          maxLength: 128
          description: 州、省或地区。
          example: CA
        postal_code:
          type: string
          maxLength: 32
          example: '94043'
        country:
          type: string
          maxLength: 3
          description: 地址所在国家/地区的 ISO 3166-1 alpha-2 或 alpha-3 代码。
          example: US
    AddressValidationResponse:
      type: object
      required:
        - request_id
        - address_validation
        - created_at
      properties:
        request_id:
          type: string
          format: uuid
          description: 此请求的标识符；联系支持团队时请引用此标识符。不会创建会话。
        address_validation:
          $ref: '#/components/schemas/AddressValidationResult'
        created_at:
          type: string
          format: date-time
    AddressValidationResult:
      type: object
      description: 单次地址验证的结果：地址是否存在，以及其规范化形式。它仅确认地址；绝不会将地址与个人关联。
      required:
        - status
        - verification_level
        - address
        - formatted_address
        - latitude
        - longitude
      properties:
        status:
          type: string
          enum:
            - verified
            - partially_verified
            - not_verified
            - unavailable
          description: >-
            `verified`：地址已确认具体到建筑物（或单元/公寓、邮政信箱）。`partially_verified`：仅确认到街道，或确认到该地点邮政参考数据所能支持的最精确级别。`not_verified`：仅匹配到地区或城市，或完全未匹配。`unavailable`：无法执行核验（例如参考服务未响应）；该状态不计费，且绝不会影响验证。
        verification_level:
          type: string
          nullable: true
          enum:
            - administrative_area
            - locality
            - thoroughfare
            - premise
            - delivery_point
            - null
          description: 地址匹配到的最高精确度级别。未匹配到任何内容或 `status` 为 `unavailable` 时为 `null`。
        address:
          type: object
          nullable: true
          description: 标准化地址。当 `status` 为 `unavailable` 时为 `null`。
          properties:
            address_line_1:
              type: string
              nullable: true
              description: 投递地址第一行，按该国家/地区的书写习惯书写。
              example: 1600 Amphitheatre Pkwy
            address_line_2:
              type: string
              nullable: true
              description: 第二行投递地址（公寓、楼栋或社区，若地址包含）。
            city:
              type: string
              nullable: true
              example: Mountain View
            region:
              type: string
              nullable: true
              description: 州、省或地区。
              example: CA
            postal_code:
              type: string
              nullable: true
              example: 94043-1351
            country:
              type: string
              nullable: true
              description: ISO 3166-1 alpha-2 国家/地区代码。
              example: US
        formatted_address:
          type: string
          nullable: true
          description: 单行格式的标准化地址。
          example: 1600 Amphitheatre Pkwy, Mountain View CA 94043-1351
        latitude:
          type: number
          nullable: true
          example: 37.422022
        longitude:
          type: number
          nullable: true
          example: -122.08429
  responses:
    AddressValidationValidationError:
      description: 请求体无效：缺失或未知的 `country`、未提供地址，或同时提供了 `address` 与结构化字段。
      content:
        application/json:
          examples:
            Unknown country:
              value:
                country:
                  - >-
                    Use an ISO 3166-1 alpha-2 or alpha-3 country code, e.g. 'US'
                    or 'USA'.
            No address:
              value:
                address:
                  - >-
                    Send the address: 'address' on one line, or the structured
                    fields with 'address_line_1'.
            Both shapes:
              value:
                address:
                  - >-
                    Send either 'address' or the structured fields
                    (address_line_1, ...), not both.
    AddressValidationPermissionDenied:
      description: API 密钥缺失或无效、限定作用域的密钥缺少 `sessions` 写入权限，或者组织无法支付核验费用。此 API 从不返回 `401`。
      content:
        application/json:
          examples:
            Missing or invalid API key:
              value:
                detail: You do not have permission to perform this action.
            Not enough credits:
              value:
                detail: >-
                  You don't have enough credits to perform this request. Please
                  top up at https://business.didit.me
                code: insufficient_credits
    RateLimitedWrite:
      description: 已超出每个 API 密钥每分钟 300 次请求的共享写入限制。在重试之前请遵循 `Retry-After`。
      content:
        application/json:
          schema:
            type: object
            required:
              - detail
            properties:
              detail:
                type: string
          example:
            detail: >-
              Write request rate limit exceeded. You can make up to 300 requests
              per minute.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        您的应用 API 密钥，可在 Business Console 的“开发者 -> API
        密钥”中获取。主密钥拥有完整访问权限。指定名称的密钥可设置作用域：针对每个资源设为无权限、只读或读写，限定于特定工作流或已通过的会话、限定于
        IP 地址列表，以及设置到期日期。401 表示密钥错误、已撤销或已过期；403 表示未发送密钥、密钥无权访问该资源或操作，或请求来自其 IP
        列表之外的地址；在会话路由上返回 404 表示该会话不在该密钥允许的工作流或状态范围内。没有媒体访问权限的密钥获取到的图片、视频和 PDF
        URL 将为 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.