> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codapay/tokenization-api-2.0/ji-cheng-zhi-nan/token.md).

# Token

## Token对象

<table><thead><tr><th width="274">参数名称</th><th width="131">类型</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>Coda生成的 Token ID</td></tr><tr><td>payment_method_id</td><td>String</td><td>Coda 生成的 Payment Method ID</td></tr><tr><td>status_code</td><td>String</td><td>Token的状态码</td></tr><tr><td>shopper_action</td><td>Object</td><td>有关Shopper交互以授权token的详细信息</td></tr><tr><td>shopper_action.id</td><td>String</td><td>Shopper操作实体的 ID</td></tr><tr><td>shopper_action.type</td><td>String</td><td>Shopper操作的类型。可能的值=‘重定向’</td></tr><tr><td>shopper_action.redirection</td><td>Object</td><td>重定向的详细信息</td></tr><tr><td>shopper_action.redirection.id</td><td>String</td><td>重定向ID</td></tr><tr><td>shopper_action.redirection.method</td><td>String</td><td>用于重定向的 HTTP 方法。可能的值包括“GET”、“POST”</td></tr><tr><td>shopper_action.redirection.url</td><td>String</td><td>Shopper重定向的 URL</td></tr></tbody></table>

## 接口

{% tabs %}
{% tab title="接口" %}

```json
POST /v1/tokens
GET  /v1/tokens/{id}
```

{% endtab %}
{% endtabs %}

## Token取消对象

<table><thead><tr><th>参数名称</th><th width="201">类型</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>Coda 生成的token取消 ID</td></tr><tr><td>reason</td><td>String</td><td>Token取消原因</td></tr><tr><td>status_code</td><td>String</td><td>已取消token的状态码</td></tr><tr><td>toekn_id</td><td>Object</td><td>提供用于token取消的token ID</td></tr></tbody></table>

### 接口

{% tabs %}
{% tab title="接口" %}

```
POST /v1/tokens
GET  /v1/tokens/{id}
POST /v1/tokens/{tokenId}/cancellations
```

{% endtab %}
{% endtabs %}

## 创建Token

### POST /tokens

{% tabs %}
{% tab title="Token" %}

```json
curl --location '{baseUrl}/v1/tokens' \
--header 'X-Partner-Id: par_sg1882402279a0000' \
--header 'X-Api-Key: sdirugnvsiguhsirghsekjhgh' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVyX2lkIjoicGFyX3NnMTg4MjQwMjI3OWEwMDAwIiwiaWF0IjoxNzAxMjMzNTM0fQ.o_tcEJUEwEms49J0MXwvRuCGbsBx3rHugfgKsXVgj9I' \
--data '{
    "payment_method_id": "pmt_sg18c19753ad70005"
}'
```

{% endtab %}
{% endtabs %}

### 响应[token对象](#token-dui-xiang)

{% tabs %}
{% tab title="Token" %}

```json
{
    "id": "tkn_sg18bff21b35d0000",
    "payment_method_id": "pmt_sg18bfbc3dab80003",
    "status_code": "waiting_for_shopper_action",
    "shopper_action": {
        "id": "tsa_sg18bff21c0810000",
        "type": "redirection",
        "redirection": {
            "id": "tar_sg18bff21c61e0000",
            "method": "GET",
            "url": "https://www.redirectionUrl.com"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## 获取Token

### GET /tokens/{token.id}

{% tabs %}
{% tab title="Token" %}

```json
curl --location '{baseUrl}/v1/tokens/{tokenId}' \
--header 'X-Partner-Id: par_sg1882402279a0000' \
--header 'X-Api-Key: sdirugnvsiguhsirghsekjhgh' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVyX2lkIjoicGFyX3NnMTg4MjQwMjI3OWEwMDAwIiwiaWF0IjoxNzAxMjMzNTM0fQ.o_tcEJUEwEms49J0MXwvRuCGbsBx3rHugfgKsXVgj9I' \
--data ''
```

{% endtab %}
{% endtabs %}

### 响应[token对象](#token-dui-xiang)

{% tabs %}
{% tab title="Response" %}

```json
{
    "id": "tkn_sg18bff21b35d0000",
    "payment_method_id": "pmt_sg18bfbc3dab80003",
    "status_code": "waiting_for_shopper_action",
    "shopper_action": {
        "id": "tsa_sg18bff21c0810000",
        "type": "redirection",
        "redirection": {
            "id": "tar_sg18bff21c61e0000",
            "method": "GET",
            "url": "https://www.redirectionUrl.com"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## 请求参数

<table><thead><tr><th width="135">参数名称</th><th width="91">类型</th><th width="79">必填？</th><th>描述</th><th>验证</th></tr></thead><tbody><tr><td>payment_method_id</td><td>String</td><td>是</td><td>Coda 生成的支付方式 ID</td><td><p>必须介于 3和 255 之间</p><p></p><p>不得留白</p></td></tr></tbody></table>

## 取消Token

### POST /tokens/{tokenid}

{% tabs %}
{% tab title="Token" %}

```json
curl --location '{baseUrl}/v1//tokens/{tokenId}/cancellations' \
--header 'X-Partner-Id: par_sg18dd4d8cead0000' \
--header 'X-Api-Key: sdirugnvsiguhsirghsekjhgh' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVyX2lkIjoicGFyX3NnMThkZDRkOGNlYWQwMDAwIiwiaWF0IjoxNzA5MDEzMzAzfQ.Xz8kyTMqK3UYEjvKIzoBo2BtXKtVJ-5_IyzIgCVPgCE' \
--data '{
    "reason": "cancelled due to failure"
}'
```

{% endtab %}
{% endtabs %}

### 响应[token对象](#token-dui-xiang)

{% tabs %}
{% tab title="Response" %}

```json
{
    "id": "tkn_sg18bff21b35d0000",
    "payment_method_id": "pmt_sg18bfbc3dab80003",
    "status_code": "waiting_for_shopper_action",
    "shopper_action": {
        "id": "tsa_sg18bff21c0810000",
        "type": "redirection",
        "redirection": {
            "id": "tar_sg18bff21c61e0000",
            "method": "GET",
            "url": "https://www.redirectionUrl.com"
        }
    }
}
```

{% endtab %}
{% endtabs %}

### 请求参数

<table><thead><tr><th>参数名称</th><th width="85">类型</th><th width="108">必填？</th><th>描述</th><th>验证</th></tr></thead><tbody><tr><td>payment_method_id</td><td>String</td><td>是</td><td>Coda 生成的支付方式 ID</td><td>必须介于 1 到 255 之间</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codapay/tokenization-api-2.0/ji-cheng-zhi-nan/token.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
