> For the complete documentation index, see [llms.txt](https://k4k3ru.gitbook.io/k4k3ru-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://k4k3ru.gitbook.io/k4k3ru-docs/api/payment/create-onchain-intent.md).

# Create an Onchain Payment Intent

Create a hosted onchain payment intent for a K4K3RU credit product. The selected product determines the blockchain, network, token, and payment amount.

## Endpoint

| Property       | Value                             |
| -------------- | --------------------------------- |
| URL            | `https://api.k4k3ru.com/`         |
| HTTP method    | `POST`                            |
| RPC method     | `PaymentOnchain.CreateIntent`     |
| Authentication | API credential signature required |

## Request

### Request Body

This method uses the common [JSON-RPC request envelope](/k4k3ru-docs/api/json-rpc.md#request-envelope). Set `method` to `PaymentOnchain.CreateIntent` and include the required `auth` object described in [API Request Authentication](/k4k3ru-docs/api/authentication.md).

### Params Fields

| Field         | Type   | Required | Description                                                                                                                                         |
| ------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `productName` | string | Yes      | Stable name of an active, client-visible credit product. The value must contain non-whitespace characters and cannot exceed 128 Unicode characters. |

Use [`AccountApp.ListProducts`](/k4k3ru-docs/api/crm/list-products.md) to discover available product names or [`AccountApp.GetProduct`](/k4k3ru-docs/api/crm/get-product.md) to inspect one product.

The service derives the blockchain, network, token, amount, and payment memo from the selected product. The memo is the product name.

USDC payment intents currently support Base Mainnet, Base Sepolia, Ethereum Mainnet, Ethereum Sepolia, Polygon Mainnet, and Polygon Amoy. JPYC payment intents support Polygon Mainnet and Polygon Amoy. Each supported network requires 12 block confirmations. Sepolia and Amoy networks are test networks and do not provide production credit-purchase settlement.

### Example Request

```json
{
  "id": "1",
  "method": "PaymentOnchain.CreateIntent",
  "params": {
    "productName": "usdc-base-mainnet-1"
  },
  "auth": {
    "apiKey": "<API_KEY>",
    "timestamp": 1786521600,
    "nonce": "<NONCE>",
    "signature": "<SIGNATURE>"
  }
}
```

Generate `timestamp`, `nonce`, and `signature` for each request according to your API credential's signing algorithm. For the params shown above, sign this canonical payload using the same timestamp and nonce placed in `auth`:

```
PaymentOnchain.CreateIntent
1786521600
<NONCE>
{"productName":"usdc-base-mainnet-1"}
```

The timestamp shown above is illustrative. Use the current Unix timestamp in seconds when signing a real request.

## Response

### Response Body

Successful requests use the common [JSON-RPC success response envelope](/k4k3ru-docs/api/json-rpc.md#success-response-envelope). Failed requests use the common [JSON-RPC error response envelope](/k4k3ru-docs/api/json-rpc.md#error-response-envelope).

### Result Fields

| Field                    | Type   | Description                                                                |
| ------------------------ | ------ | -------------------------------------------------------------------------- |
| `intentId`               | string | Unique payment intent identifier.                                          |
| `accountId`              | string | Identifier of the account that created the intent.                         |
| `status`                 | string | Current payment intent status.                                             |
| `chain`                  | string | Blockchain selected from the product metadata.                             |
| `network`                | string | Blockchain network selected from the product metadata.                     |
| `token`                  | string | Token selected from the product metadata.                                  |
| `amount`                 | string | Payment amount derived from the product price.                             |
| `address`                | string | Hosted payment address to which the payment must be sent.                  |
| `expiresAt`              | string | Payment intent expiration time.                                            |
| `metadata`               | object | Product terms captured when the intent is created.                         |
| `metadata.id`            | string | Product identifier.                                                        |
| `metadata.name`          | string | Stable product name.                                                       |
| `metadata.creditTicks`   | string | Credit ticks granted after payment completion.                             |
| `metadata.expiresInDays` | number | Number of days before the granted credit expires. `0` means no expiration. |

### Errors

| Code                | When it occurs                                                                                                           |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `invalid_parameter` | `productName` is empty, whitespace-only, or longer than 128 Unicode characters, or another request parameter is invalid. |
| `not_found`         | No active, client-visible product has the requested name.                                                                |
| `unauthorized`      | Required authentication fields are missing or signature verification fails.                                              |
| `expired`           | The request timestamp is older than the accepted 60-second window.                                                       |
| `unexpected`        | Product data cannot be decoded or the intent cannot be created because of an unexpected upstream or processing failure.  |

### Example Success Response

```json
{
  "id": "1",
  "result": {
    "intentId": "2001",
    "accountId": "3001",
    "status": "pending",
    "chain": "base",
    "network": "mainnet",
    "token": "USDC",
    "amount": "1",
    "address": "0x0000000000000000000000000000000000000001",
    "expiresAt": "2026-08-12T12:00:00Z",
    "metadata": {
      "id": "1004",
      "name": "usdc-base-mainnet-1",
      "creditTicks": "1000000",
      "expiresInDays": 30
    }
  }
}
```

Identifiers, addresses, timestamps, and status values shown above are examples. Use the values returned by the API.

Use [Get an Onchain Payment Intent](/k4k3ru-docs/api/payment/get-onchain-intent.md) with the returned `intentId` to retrieve the latest intent details.

### Example Error Response

```json
{
  "id": "1",
  "error": {
    "code": "not_found"
  }
}
```


---

# 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://k4k3ru.gitbook.io/k4k3ru-docs/api/payment/create-onchain-intent.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.
