> 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/charge.md).

# Charge

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

<table><thead><tr><th width="222.33333333333331">Parameter name</th><th width="91">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>Charge ID generated by Coda</td></tr><tr><td>created_at</td><td>String</td><td>ID the partner will use to identify their customer and link the token ID</td></tr><tr><td>status_code</td><td>String</td><td>The status code of the charge</td></tr><tr><td>token_id</td><td>String</td><td>The token ID associated</td></tr><tr><td>partner_reference</td><td>String</td><td>Partner reference Id<br><br>Length must be between 4 and 64 and must follow the pattern ^[a-zA-Z0-9-_]+$</td></tr><tr><td>item_code</td><td>String</td><td>The code of item charged</td></tr><tr><td>item_name</td><td>String</td><td>The name of item charged</td></tr><tr><td>amount_value</td><td>String</td><td>The charged numerical value of the item</td></tr><tr><td>amount_currency</td><td>String</td><td>The currency of the value charged</td></tr><tr><td>subscription_id</td><td>String</td><td>The subscription id if opted-in subscription</td></tr><tr><td>shopper_action</td><td>String</td><td>Shopper action for charge flow</td></tr><tr><td>shopper_action.id</td><td>String</td><td>Charge shopper action ID</td></tr><tr><td>shopper_action.type</td><td>String</td><td>Charge shopper action type e.g redirection</td></tr><tr><td>shopper_action.redirection</td><td>String</td><td>Charge shopper redirection entity</td></tr><tr><td>shopper_action.redirection.id</td><td>String</td><td>Charge Shopper redirection ID</td></tr><tr><td>shopper_action.redirection.method</td><td>String</td><td>Charge Shopper redirect url method type e.g GET/POST</td></tr><tr><td>shopper_action.redirection.url</td><td>String</td><td>Charge Shopper redirect url</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  {Base URL}/v1/charges
GET  {Base URL}/v1/charges/{charge.id}
```

{% endtab %}
{% endtabs %}

## <mark style="color:purple;">Create new Charge with Shopper Action</mark>

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

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

```json
curl --location '{baseUrl}/v1/charges' \
--header 'X-Partner-Id: par_sg1882402279a0000' \
--header 'X-Api-Key: sdirugnvsiguhsirghsekjhgh' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVyX2lkIjoicGFyX3NnMTg4MjQwMjI3OWEwMDAwIiwiaWF0IjoxNzAxMjMzNTM0fQ.o_tcEJUEwEms49J0MXwvRuCGbsBx3rHugfgKsXVgj9I' \
--data '{
  "token_id": "tkn_sg18bffd6a3ae0003",
  "item_code": "item-code-28",
  "item_name": "item-name-28",
  "amount_value": "28",
  "amount_currency": "SAR",
 "partner_reference": "partner-reference-123",
 "token" : {
    "payment_method": {
      "card": {
        "security_code": "xxx"      
      }
    }
  }
}'
```

{% endtab %}
{% endtabs %}

### <mark style="color:purple;">Response</mark> [<mark style="color:purple;">Charge Object</mark>](#charge-object) <mark style="color:purple;">with Shopper Action</mark>

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

```json
{
    "id": "chg_sg18bffdcebd30018",
    "created_at": "2023-11-24T05:45:50.291546075Z",
    "status_code": "waiting_for_shopper_action",
    "token_id": "tkn_sg18bffd6a3ae0003",
    "partner_reference":"partner-reference-123",
    "item_code": "item-code-28",
    "item_name": "item-name-28",
    "amount_value": "28",
    "amount_currency": "SAR",
    "subscription_id": null,
    "shopper_action": {
        "id": "csa_sg18bffdcf7700007",
        "type": "redirection",
        "redirection": {
            "id": "car_sg18bffdcf82d0007",
            "method": "GET",
            "url": "https://cdn1.codapayments.com/W/pub/tc/mada/authenticate-payer.html?action=https%3A%2F%2Fap.gateway.mastercard.com%2Facs%2Fmastercard%2Fv2%2Fprompt&creq=eyJ0aHJlZURTU2VydmVyVHJhbnNJRCI6IjZjMzViOTNjLTYwN2QtNGQ1MC1iZWRmLWFlOWJjZDg1M2I3YiJ9"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## <mark style="color:purple;">Create Charge without Shopper Shopper Action</mark>

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

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

```json
curl --location '{baseUrl}/v1/charges' \
--header 'X-Partner-Id: par_sg1882402279a0000' \
--header 'X-Api-Key: sdirugnvsiguhsirghsekjhgh' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0bmVyX2lkIjoicGFyX3NnMTg4MjQwMjI3OWEwMDAwIiwiaWF0IjoxNzAxMjMzNTM0fQ.o_tcEJUEwEms49J0MXwvRuCGbsBx3rHugfgKsXVgj9I' \
--data '{
  "token_id": "tkn_sg18c23a062a90007",
  "item_code": "item-code-585",
  "item_name": "item-name-585",
  "amount_value": "585",
  "amount_currency": "IDR",
  "partner_reference": 123456789
}'
```

{% endtab %}
{% endtabs %}

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

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

```json
{
    "id": "chg_sg18c23a11fff0008",
    "created_at": "2023-12-01T04:26:51.263110116Z",
    "status_code": "succeeded",
    "token_id": "tkn_sg18c23a062a90007",
    "partner_reference": "123456789",
    "item_code": "item-code-585",
    "item_name": "item-name-585",
    "amount_value": "585",
    "amount_currency": "IDR",
    "subscription_id": null,
    "shopper_action": null
}
```

{% endtab %}
{% endtabs %}

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

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

Request

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

```json
curl --location '{baseUrl}/v1/charges/chg_sg18bffe4bd460001' \
--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;">Charge Object</mark>](#charge-object)

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

```json
{
    "id": "chg_sg18bffe4bd460001",
    "created_at": "2023-11-24T05:54:22.662466Z",
    "status_code": "succeeded",
    "token_id": "tkn_sg18bffd6a3ae0003",
    "partner_reference": null,
    "item_code": "item-code-160",
    "item_name": "item-name-160",
    "amount_value": "120",
    "amount_currency": "SAR",
    "subscription_id": null,
    "shopper_action": null
}
```

{% endtab %}
{% endtabs %}

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

<table data-full-width="false"><thead><tr><th width="219">Parameter name</th><th width="78">Type</th><th width="112">Required?</th><th>Description</th><th>Validation</th></tr></thead><tbody><tr><td>token_id</td><td>String</td><td>Yes</td><td>Token ID generated by Coda</td><td>Token ID length must be between 20 and 32<br>And must follow the pattern "[A-Za-z]+_[A-Za-z0-9]+"</td></tr><tr><td>item_code</td><td>String</td><td>Yes</td><td>The code of item charged</td><td>Must not be blank</td></tr><tr><td>item_name</td><td>String</td><td>Yes</td><td>The name of item charged</td><td>Must not be blank</td></tr><tr><td>amount_value</td><td>String</td><td>Yes</td><td>The charged numerical value of the item</td><td>Must not be blank<br><br>Must match "^\d+(.\d{1,2})?$"</td></tr><tr><td>amount_currency</td><td>String</td><td>Yes</td><td>The currency of the value charged</td><td>Must not be blank<br><br>Size must be 3</td></tr><tr><td>partner_reference</td><td>String</td><td>Yes</td><td>Partner Reference ID</td><td>Partner reference must not be blank and length must be between 4 and 64 and must follow the pattern ^[a-zA-Z0-9-_]+$</td></tr><tr><td>token.payment_method.card.security_code</td><td>String</td><td>No</td><td>The Card Security Code (CSC/CVV) is a required field for card payment methods to successfully create charge. Optional for other payment method such as GoPay</td><td>Security Code length must be 3.</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/charge.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.
