Credits Endpoints
Manage your credit balance for API operations and storage insurance.
Deposit Credits
Deposit credits into your account via x402 payment. This enables autonomous agents to fund their own storage insurance without human intervention.
Endpoint: POST /credits/deposit
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount_usd | number | No | Amount to deposit in USD. Min: 1000. Defaults to $0.10 if not specified. |
x402 Payment Flow
This endpoint uses the x402 protocol for permissionless payments:
- Initial Request: Call the endpoint without payment
- 402 Response: Receive payment requirements (supported networks, amounts, recipient)
- Sign Payment: Use your wallet to sign an x402 payment
- Retry with Payment: Retry the request with
x-paymentheader containing the signed payment - Success: Receive confirmation and updated balance
Example: Initial Request
curl -X POST "https://api.zkstash.ai/v1/credits/deposit?amount_usd=5" \
-H "Authorization: Bearer YOUR_API_KEY"Example: 402 Response
{
"x402Version": 1,
"error": "Payment required for credit deposit",
"deposit": {
"amount_usd": 5,
"credits": 5000,
"description": "Credits will be added to your balance for future operations and storage insurance."
},
"accepts": [
{
"scheme": "exact",
"network": "solana",
"maxAmountRequired": "5000000",
"resource": "https://api.zkstash.ai/v1/credits/deposit",
"description": "Deposit 5,000 credits ($5.00 USD)",
"mimeType": "application/json",
"payTo": "...",
"extra": { "feePayer": "..." }
},
{
"scheme": "exact",
"network": "base",
"maxAmountRequired": "5000000",
"resource": "https://api.zkstash.ai/v1/credits/deposit",
"description": "Deposit 5,000 credits ($5.00 USD)",
"mimeType": "application/json",
"payTo": "..."
}
]
}Example: Success Response
After providing a valid x-payment header:
{
"success": true,
"deposit": {
"amount_usd": 5,
"credits": 5000
},
"balance": {
"credits": 5000,
"usd": 5
},
"message": "Deposit successful. Storage insurance is now active."
}Use Cases
Storage Insurance for Free Plan
Free plan memories are deleted after 7 days by default. To prevent deletion:
- Deposit credits using this endpoint
- The daily cron job will deduct ~3.33 credits per 1,000 memories to “insure” your storage
- As long as you maintain a positive balance, your memories persist
Autonomous Agent Self-Funding
Agents that earn revenue (e.g., by providing services) can use those funds to:
- Pay for their own storage costs
- Pre-fund future API operations
- Operate indefinitely without human intervention
This enables self-sovereign AI agents—a capability unique to crypto-native platforms.
Supported Networks
| Network | Token | Environment |
|---|---|---|
| Solana | USDC | Production |
| Base | USDC | Production |
| Solana Devnet | USDC | Development |
| Base Sepolia | USDC | Development |
Last updated on