> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clinkbill.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取支付凭证

> Issues the signed SD-JWT VC payment approval credential for this authorization. Only available once the instruction is `ACTIVE`, unexpired, has a bound card and was created with `agent_public_key`; otherwise the request fails closed and no credential is produced. `jti` is the instruction id and `exp` is the instruction's `effective_until_time`.

返回该客户某个授权的签名**支付授权凭证**：一个 SD-JWT VC（`typ: dc+sd-jwt`），内含 AP2 open
payment mandate，说明用户批准了什么。签名使用 Clink 的 ES256 私钥，agent 无法访问该私钥。

## 调用前提

授权必须是 `ACTIVE`、未过期、已绑定卡，并且在创建时带上了
[`agent_public_key`](https://docs.clinkbill.com/cn/api-reference/agent-portal/create_instruction)。其他情况一律失败且不产生凭证：

| 状态 | 含义 |
| - | - |
| `409` | 未 `ACTIVE`、已过期、没有绑卡、授权包含多个 mandate（请按 mandate 拆分授权），或金额无法用最小货币单位精确表示 |
| `422` | 授权没有存 `agent_public_key`，无法把凭证绑定到该 agent |

创建授权不等于批准。用户需要在 Clink 页面上用 passkey 完成批准，之后该接口才会返回凭证。

## 凭证结构

线格式：`<issuer-signed JWT>~<mandate>~<instrument 1>~...~`。

* `jti` 就是 instruction id，`exp` 就是 instruction 的 `effective_until_time`，也就是响应里的
  `expires_at`。
* `cnf` 是 agent 公钥；需要 key binding 的验证方要求 agent 用对应私钥另签一个 JWT（Clink 不签发
  这个 JWT）。
* `constraints` 里有 `payment.amount_range`（**单笔**支付上限，最小货币单位）和
  `payment.allowed_payment_instruments`（每张被批准的卡一个摘要）。
* 每张卡都是独立 disclosure，agent 可以只揭示商户接受的那一张。

同一授权每次调用都会重新序列化一份凭证，`jti` 与批准条款不变。

## 验证方式

1. 取 `GET <issuer>/.well-known/jwt-vc-issuer`，用凭证 header 里的 `kid` 选中对应公钥。
2. 验证 issuer JWT 签名。
3. 对每个被揭示的 disclosure 计算哈希，与上一层摘要比对：instrument 对 `allowed`，mandate 对
   `delegate_payload`。
4. `cnf`、`iat`、`exp` 在签名区与 mandate 里两份不一致时拒绝。

## 它不做什么

凭证只记录用户同意，不授予新能力。能否支付仍由 Clink 在支付时按 instruction、mandate 和 usages
判断。撤销授权由用户在 Clink 页面上完成，不通过本接口。


## OpenAPI

````yaml GET /agent/platform/authorizations/{instructionId}/payment-credential
openapi: 3.1.0
info:
  title: Clink Agent Portal API
  description: >-
    Agent Portal APIs let an Agent platform read and manage one user's Clink
    account with a portal user token: payment methods, orders, refunds, purchase
    instructions, payment credentials, payment results, and settings.
  version: 1.0.0
servers:
  - url: https://uat-api.clinkbill.com
    description: Sandbox
security:
  - PortalToken: []
paths:
  /agent/platform/authorizations/{instructionId}/payment-credential:
    get:
      summary: Get payment credential
      description: >-
        Issues the signed SD-JWT VC payment approval credential for this
        authorization. Only available once the instruction is `ACTIVE`,
        unexpired, has a bound card and was created with `agent_public_key`;
        otherwise the request fails closed and no credential is produced. `jti`
        is the instruction id and `exp` is the instruction's
        `effective_until_time`.
      operationId: getPaymentCredential
      parameters:
        - name: instructionId
          in: path
          required: true
          description: Instruction ID.
          schema:
            type: string
            example: inst_...
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    format: int32
                    example: 200
                  msg:
                    type: string
                    example: Success
                  data:
                    $ref: '#/components/schemas/PaymentApprovalCredential'
              example:
                code: 200
                msg: Success
                data:
                  credential: <sd-jwt>
                  jti: inst_...
                  vct: https://clinkbill.com/vct/agent-mandate/1
                  expires_at: '2026-12-31T00:00:00Z'
        '401':
          description: Missing, expired, or invalid portal token.
        '403':
          description: The portal token lacks the `portal:read` scope.
        '404':
          description: No such authorization for this customer.
        '409':
          description: >-
            The authorization cannot produce a credential yet (not active,
            expired, no bound card, or unusable amount).
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  msg:
                    type: string
        '422':
          description: >-
            The authorization was created without `agent_public_key`, so the
            credential cannot be bound to the agent.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  msg:
                    type: string
components:
  schemas:
    PaymentApprovalCredential:
      type: object
      description: >-
        Signed SD-JWT VC recording what the user approved for this
        authorization.
      properties:
        credential:
          type: string
          description: >-
            Compact SD-JWT: `<issuer-signed JWT>~<mandate>~<instrument>...~`.
            Treat it as a bearer artifact while valid.
          example: >-
            eyJhbGciOiJFUzI1NiIsInR5cCI6ImRjK3NkLWp3dCIsImtpZCI6ImtleS0xIn0.eyJpc3MiOi...~WyJzYWx0Iiw...~
        jti:
          type: string
          description: Clink approval id; equals the instruction id.
          example: inst_...
        vct:
          type: string
          description: Credential type identifier.
          example: https://clinkbill.com/vct/agent-mandate/1
        expires_at:
          type: string
          description: >-
            Credential expiry (ISO-8601 UTC); equals the instruction's
            `effective_until_time`.
          format: date-time
          example: '2026-12-31T00:00:00Z'
  securitySchemes:
    PortalToken:
      type: http
      scheme: bearer
      description: >-
        Portal user token from `POST /agent/cwallet/platform/portal/tokens`.
        Reads require `portal:read`; writes require `portal:write`.

````

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