# AI Integration

> Integrate 2328.io into your application in minutes using AI assistants like Claude, ChatGPT, Cursor, and GitHub Copilot.

The 2328.io documentation is built to be **LLM-friendly**. You can hand the entire API reference to any modern AI assistant and have it generate a working integration in the language of your choice — PHP, Node.js, Python, Go, Rust — in minutes instead of hours.

This page explains how to do it efficiently.

## Why use AI to integrate

- **Faster onboarding** — skip boilerplate, jump straight to business logic
- **Correct signing** — AI reliably reproduces HMAC-SHA256 signing in any language
- **Webhook handlers** — generate signature verification and idempotent handlers out of the box
- **Up-to-date** — our `llms-full.txt` is regenerated on every docs update, so you always get current schemas

## Machine-readable docs

We publish three endpoints following the [llmstxt.org](https://llmstxt.org) standard:

| Endpoint | Purpose |
|----------|---------|
| [`/llms.txt`](https://doc.2328.io/llms.txt) | Short index of all docs with links |
| [`/llms-full.txt`](https://doc.2328.io/llms-full.txt) | Full documentation as a single file — paste this into your AI chat |
| [`/md/{locale}/{slug}`](https://doc.2328.io/md/en/payments) | Any page as raw Markdown |

Every HTML page also exposes `<link rel="alternate" type="text/markdown">` pointing to its Markdown version, so AI crawlers discover it automatically.

## Quick start with Claude or ChatGPT

### Step 1 — Provide the docs

Open a fresh chat and paste the contents of [`llms-full.txt`](https://doc.2328.io/llms-full.txt) as your first message, or just share the link if the model can fetch it.

### Step 2 — Describe your stack

Tell the assistant what you are building:

```
I'm building a Laravel 11 application. I need to:
1. Create a payment for an order (amount in USD, user pays in USDT TRC20)
2. Handle the webhook and credit the user's balance
3. Store payment records in a `payments` table

Use the 2328.io API above. Include HMAC signing, webhook signature
verification, and idempotency.
```

### Step 3 — Review and test

The assistant will produce a controller, a service class, and a webhook handler. Before shipping:

- Verify that `apiSign()` encodes the body as Base64 **before** HMAC-SHA256
- Check that webhook handlers call `hash_equals()` (not `===`) to compare signatures
- Make sure the handler is idempotent — check `order_id` / `txid` before crediting
- Test with a small real payment on a dev environment first

> **WARNING:** Never ship AI-generated payment code without reviewing the signing and webhook verification logic. These are the critical security boundaries.

## IDE integrations

### Cursor

Add the docs as a custom docs source in Cursor settings:

```
Settings → Features → Docs → Add new doc
URL: https://doc.2328.io
```

Then in chat, prefix your question with `@2328.io`:

```
@2328.io generate a webhook handler in Next.js App Router
with signature verification and idempotent credit logic
```

### GitHub Copilot

Copilot Chat can read `llms-full.txt` directly:

```
#fetch https://doc.2328.io/llms-full.txt

Using the 2328.io API docs above, implement a payout endpoint
in Express that withdraws USDT BEP20 to a user-supplied address.
```

### Windsurf / Continue / other assistants

Any assistant that supports a URL context or file attachment works the same way — attach `llms-full.txt` and describe your goal.

## Claude API (Agent SDK)

If you're building your own agent or chatbot that needs to interact with 2328.io, inject the docs once into the system prompt:

```python
from anthropic import Anthropic
import urllib.request

docs = urllib.request.urlopen(
    "https://doc.2328.io/llms-full.txt"
).read().decode()

client = Anthropic()

response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=4096,
    system=f"""You are an integration assistant for 2328.io.
Use the API reference below to answer questions and generate code.

<docs>
{docs}
</docs>""",
    messages=[
        {"role": "user", "content": "Write a Python function that creates a USDT payment"}
    ],
)

print(response.content[0].text)
```

> **INFO:** The full docs file is ~15 KB — well under any modern model's context limit. You can cache it on your side and refresh it once a day.

## Example prompts that work well

Copy these into Claude, ChatGPT, or your AI IDE after sharing `llms-full.txt`:

**Full backend integration:**
```
Build a Node.js + Express service that exposes two routes:
- POST /checkout → creates a 2328.io payment and returns the payment URL
- POST /webhook/2328 → verifies the signature and marks the order as paid
Use TypeScript, Zod for validation, and a simple in-memory store.
```

**Payout tool:**
```
Write a CLI in Go that takes a currency, network, amount, and address
and creates a payout via the 2328.io Payout API. Use a separate payout
API key from env. Poll the status endpoint until the payout is completed.
```

**Static wallet for user deposits:**
```
I have a Django app where users deposit USDT TRC20 to top up their balance.
Each user should have a permanent deposit address. Implement this using
2328.io static wallets, including the webhook handler that credits their
balance when a deposit arrives.
```

## Best practices for AI-assisted integration

- **Start from `llms-full.txt`** — it's designed for LLM context, no boilerplate
- **Be specific about your stack** — framework, language version, ORM
- **Ask for tests** — AI is good at generating unit tests for signing logic
- **Double-check error handling** — AI sometimes skips failure paths
- **Review signature code manually** — this is the only part that *must* be exactly right
- **Refresh periodically** — if our API changes, refetch `llms-full.txt` and re-prompt