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

# 创建或发送 Travel Rule 终端用户链接

> 在 Didit 中创建新的 Travel Rule 终端用户链接，或发送至用户记录的邮箱，并查看链接到期、撤销和投递结果字段。

Didit 的 Travel Rule 终端用户链接 API 会签发一个链接，供用户完成钱包或交易对手的选择，并可将该链接发送到其记录的邮箱地址。

发送 `{"channel": "link"}` 可复制链接，发送 `{"channel": "email"}` 则还会尝试发送邮件。省略 `channel` 时默认为 `link`。邮件会使用终端用户在 Didit 中记录的邮箱地址，并在可用时使用其验证会话的语言。您不能指定任意收件人。

该 API 要求对交易具有写入权限，且出站转账的状态为 `AWAITING_COUNTERPARTY`、`COUNTERPARTY_VASP_NOT_FOUND`、`COUNTERPARTY_VASP_NOT_REACHABLE`、`UNCONFIRMED_OWNERSHIP` 或 `ON_HOLD`。其他状态返回 `409`；未知交易或缺少转账返回 `404`。

响应包含 `end_user_link`、`expires_at`、`emailed_to` 和 `email_available`。创建新链接后，该转账之前尚未失效的终端用户链接都会被撤销。请仅将链接分享给目标终端用户。

若没有记录的邮箱地址，`channel: email` 会返回 `409`，并附带 `code: end_user_email_missing`；此时请改用 `channel: link`。如果邮件发送失败，API 仍会返回可用的链接，但 `emailed_to` 为空。`email_available` 表示存在邮箱地址，并不表示邮件已成功发送。

关于创建时用户的明确选择，请参阅[创建交易](https://docs.didit.me/zh/management-api/transactions/create.md)和 [Travel Rule 指南](https://docs.didit.me/zh/transaction-monitoring/travel-rule.md#交易对手发现)。关于转账操作，请参阅[更新转账](https://docs.didit.me/zh/management-api/travel-rule/update-transfer.md)。


## OpenAPI

````yaml zh/openapi-25.json POST /v3/transactions/{transaction_id}/travel-rule/user-link/
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/{transaction_id}/travel-rule/user-link/:
    post:
      tags:
        - Travel Rule
      summary: 创建或通过邮件发送 Travel Rule 终端用户链接
      description: >-
        为此转账签发新链接，并撤销之前所有未结束的链接。需要对交易的写入权限，且出站转账状态须为
        AWAITING_COUNTERPARTY、COUNTERPARTY_VASP_NOT_FOUND、COUNTERPARTY_VASP_NOT_REACHABLE、UNCONFIRMED_OWNERSHIP
        或 ON_HOLD。channel=email 在可用时会使用终端用户在 Didit 记录中的邮箱以及验证会话语言。发送失败时仍会返回链接，但
        emailed_to 为空；email_available 表示邮箱地址是否可用，而不表示是否已送达。参见
        [用户链接](/zh/management-api/travel-rule/create-user-link)。
      operationId: createTravelRuleUserLink
      parameters:
        - name: transaction_id
          in: path
          required: true
          description: 拥有该转账的 Didit 稳定交易 UUID。
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TravelRuleUserLinkRequest'
            example:
              channel: link
      responses:
        '200':
          description: 成功响应。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TravelRuleUserLinkResponse'
        '400':
          description: 请求字段无效。
        '403':
          description: 缺少写入交易的权限。
        '404':
          description: 未知交易，或没有 Travel Rule 转账。
        '409':
          description: >-
            转账方向或状态不允许关联，或 channel=email
            时没有终端用户邮箱地址。对于后者，code=end_user_email_missing；请改用 channel=link 重试。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: 冲突说明。
                  code:
                    type: string
                    description: 邮箱不可用时存在。
                    enum:
                      - end_user_email_missing
                required:
                  - detail
              example:
                detail: >-
                  This end user has no email on their Didit record. Copy the
                  link instead.
                code: end_user_email_missing
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X POST
            'https://verification.didit.me/v3/transactions/{transaction_id}/travel-rule/user-link/'
            \
              -H 'x-api-key: YOUR_API_KEY' -H 'Content-Type: application/json' \
              -d '{"channel": "link"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.transactions.travel_rule.create_user_link(
                "11111111-2222-3333-4444-555555555555",
                channel="link",
            )
            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.travelRule.createUserLink("11111111-2222-3333-4444-555555555555",
            {
              channel: "link",
            });

            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Transactions.TravelRule.CreateUserLink(ctx, \"11111111-2222-3333-4444-555555555555\", didit.TravelRuleUserLinkRequest{\n\tChannel: didit.Some(didit.TravelRuleUserLinkRequestChannel(\"link\")),\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.TravelRuleUserLinkRequest;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.transactions().travelRule().createUserLink("11111111-2222-3333-4444-555555555555",
            TravelRuleUserLinkRequest.builder()
                    .channel(TravelRuleUserLinkRequest.Channel.of("link"))
                    .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->travelRule->createUserLink('11111111-2222-3333-4444-555555555555',
            [
                'channel' => 'link',
            ]);

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

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

            result = didit.transactions.travel_rule.create_user_link(
              "11111111-2222-3333-4444-555555555555",
              channel: "link"
            )
            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.TravelRule.CreateUserLinkAsync("11111111-2222-3333-4444-555555555555",
            new TravelRuleUserLinkRequest

            {
                Channel = new TravelRuleUserLinkRequestChannel("link"),
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    TravelRuleUserLinkRequest:
      type: object
      properties:
        channel:
          type: string
          description: link 会返回一个新链接；email 还会尝试将其发送至终端用户在 Didit 记录中的邮箱。
          enum:
            - link
            - email
          default: link
    TravelRuleUserLinkResponse:
      type: object
      properties:
        end_user_link:
          type: string
          description: 新的终端用户链接。该转账之前处于开放状态的链接将被撤销。
          format: uri
        expires_at:
          type: string
          description: 链接的过期时间。
          format: date-time
        emailed_to:
          type: string
          description: 邮件发送成功时返回的收件人，否则为空字符串。邮件发送失败时仍会返回可用的链接。
        email_available:
          type: boolean
          description: 终端用户的 Didit 记录中是否有邮箱。
      required:
        - end_user_link
        - expires_at
        - emailed_to
        - email_available
  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.