> 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/codapay/archived-tokenization-api-2.0/integration-guide/token.md).

# Token

## <mark style="color:purple;">Token Object</mark>

<table><thead><tr><th width="321">Parameter name</th><th width="95.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>Token ID generated by Coda</td></tr><tr><td>payment_method_id</td><td>String</td><td>Payment Method ID generated by Coda</td></tr><tr><td>status_code</td><td>String</td><td>The status code of the token</td></tr><tr><td>shopper_action</td><td>Object</td><td>Details concerning the shopper interaction to authorize token</td></tr><tr><td>shopper_action.id</td><td>String</td><td>Id of the shopper action entity</td></tr><tr><td>shopper_action.type</td><td>String</td><td>Type of the shopper action. Possible value = ‘redirection’</td></tr><tr><td>shopper_action.redirection</td><td>Object</td><td>Detail of the redirection</td></tr><tr><td>shopper_action.redirection.id</td><td>String</td><td>Redirection ID</td></tr><tr><td>shopper_action.redirection.method</td><td>String</td><td>The HTTP method used for redirection. Possible values include ‘GET’, ‘POST’</td></tr><tr><td>shopper_action.redirection.url</td><td>String</td><td>The URL of the shopper redirection</td></tr></tbody></table>

## <mark style="color:purple;">Base URL</mark>

<table><thead><tr><th width="107">Version</th><th>Base URL</th></tr></thead><tbody><tr><td>Sandbox</td><td>https://api-tc.codapayments-staging.com</td></tr><tr><td>Production</td><td>https://api-tc.codapayments.com</td></tr></tbody></table>

## <mark style="color:purple;">Endpoints</mark>

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

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

{% endtab %}
{% endtabs %}

## <mark style="color:purple;">Token Cancellation Object</mark>&#x20;

<table><thead><tr><th width="186">Parameter name</th><th width="114">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>Token Cancellation ID generated by Coda</td></tr><tr><td>reason</td><td>String</td><td>Reason for token cancellation</td></tr><tr><td>status_code</td><td>String</td><td>The status code of the canceled token</td></tr><tr><td>token_id</td><td>Object</td><td>Token ID provided for token cancellation</td></tr></tbody></table>

### <mark style="color:purple;">Endpoints</mark>

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

```json
POST {Base URL}/v1/tokens
GET  {Base URL}/v1/tokens/{id}
POST {Base URL}/v1/tokens/{tokenId}/cancellations
```

{% endtab %}
{% endtabs %}

## <mark style="color:purple;">Create Token</mark>

### <mark style="color:purple;">POST /tokens</mark>

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

```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 %}

### <mark style="color:purple;">Response</mark> [<mark style="color:purple;">Token Object</mark>](#token-object)

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

```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://redirectionUrl.com"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## <mark style="color:purple;">Retrieve Token</mark>

### <mark style="color:purple;">GET /tokens/{token.id}</mark>

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

```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 %}

### <mark style="color:purple;">Response</mark> [<mark style="color:purple;">Token Object</mark>](#token-object)

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

```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 %}

### <mark style="color:purple;">Request Parameters</mark>

<table><thead><tr><th width="202">Parameter Name</th><th width="84">Type</th><th width="91">Required</th><th>Description</th><th>Validation</th></tr></thead><tbody><tr><td>payment_method_id</td><td>String</td><td>Yes</td><td>Payment Method ID generated by Coda</td><td>Size must be between 3 and 255<br>Must not be blank</td></tr></tbody></table>

## <mark style="color:purple;">Token Cancellation</mark>

### <mark style="color:purple;">POST /tokens/{tokenid}/cancellations</mark>

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

```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 %}

### <mark style="color:purple;">Response</mark> [<mark style="color:purple;">Token Cancellation Object</mark>](#token-cancellation-object)

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

```json
{
    "id": "tkc_sg18de92f14190001",
    "reason": "cancelled due to failure",
    "status_code": "succeeded",
    "token_id": "tkn_sg18de8de4b420004"
}
```

{% endtab %}
{% endtabs %}

### <mark style="color:purple;">Request Parameters</mark>

<table><thead><tr><th width="174">Parameter name</th><th width="82">Type</th><th width="109">Required?</th><th width="191">Description</th><th>Validation</th></tr></thead><tbody><tr><td>reason</td><td>String</td><td>No</td><td>Reason for token cancellation</td><td>The reason length must be between 1  and 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/codapay/archived-tokenization-api-2.0/integration-guide/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.
