This guide walks you through creating your first customer, product, and invoice using the TRXN API.
Prerequisites
- A TRXN account (sign up)
- An API token (create one in Settings > API Tokens)
1. Authenticate
All API requests require a Bearer token in the Authorization header.
export TRXN_TOKEN="your_api_token_here"
Test your token:
curl https://api.gettrxn.com/v1/me \
-H "Authorization: Bearer $TRXN_TOKEN"
2. Create a customer
curl -X POST https://api.gettrxn.com/v1/customers \
-H "Authorization: Bearer $TRXN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"first_name": "Alice",
"last_name": "Smith"
}'
{
"id": "cust_abc123def456",
"email": "[email protected]",
"first_name": "Alice",
"last_name": "Smith",
"created_at": "2025-01-15T14:30:00Z",
"updated_at": "2025-01-15T14:30:00Z"
}
Save the id — you’ll need it for invoices.
3. Create a product and price
curl -X POST https://api.gettrxn.com/v1/products \
-H "Authorization: Bearer $TRXN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Pro Plan"}'
Then create a price for the product:
curl -X POST https://api.gettrxn.com/v1/prices \
-H "Authorization: Bearer $TRXN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"product_id": "prod_abc123",
"amount": 4900,
"currency": "usd",
"price_type": "one_time"
}'
Amounts are in cents. 4900 = $49.00 USD.
4. Create an invoice
curl -X POST https://api.gettrxn.com/v1/invoices \
-H "Authorization: Bearer $TRXN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cust_abc123def456",
"line_items": [
{
"price_id": "price_xyz789",
"quantity": 1
}
]
}'
{
"id": "inv_def456ghi789",
"customer_id": "cust_abc123def456",
"status": "pending",
"line_items": [
{
"price_id": "price_xyz789",
"quantity": 1,
"amount": 4900
}
],
"created_at": "2025-01-15T14:35:00Z"
}
5. Add a crypto address
Add a Bitcoin or Ethereum address to receive payments:
curl -X POST https://api.gettrxn.com/v1/crypto_addresses \
-H "Authorization: Bearer $TRXN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"currency": "btc"
}'
6. Receive and verify payments
When a customer sends crypto to your address, TRXN:
- Detects the transaction on the blockchain
- Looks up the historical price at the exact transaction time
- Converts the crypto amount to fiat (USD)
- Applies the slippage margin tolerance
- Allocates the payment to outstanding invoices
You can also set up webhooks to receive real-time notifications when payments are verified.
Next steps