Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.monkepay.xyz/llms.txt

Use this file to discover all available pages before exploring further.

const monkePay = MonkePayHono({
  apiKeyId: process.env.MONKEPAY_API_KEY_ID!,
  apiKeySecret: process.env.MONKEPAY_API_KEY_SECRET!,
  price: '0.10',
  paymentMode: 'one_time', // or 'per_request' (default)
})

per_request (default)

Every request requires a valid payment. The agent pays on each call.
Agent → GET /api/data
← 402 { accepts: [...] }

Agent → GET /api/data (X-Payment: ...)
← 200 OK + X-Payment-Response: ...

Agent → GET /api/data (X-Payment: ...)   ← must pay again
← 200 OK + X-Payment-Response: ...
Best for: APIs where usage should be metered per call — inference endpoints, data lookups, per-query pricing.

one_time

The agent pays once and receives an unlock token. That token grants permanent access to that endpoint — subsequent requests with the token bypass payment entirely.
Agent → GET /api/data
← 402 { accepts: [...] }

Agent → GET /api/data (X-Payment: ...)
← 200 OK
  X-MonkePay-Unlock: eyJ...   ← agent must persist this

Agent → GET /api/data (X-MonkePay-Unlock: eyJ...)
← 200 OK   ← no payment needed, works permanently
Best for: Reports, exports, one-time data access, lifetime subscriptions.

Token behavior

Tokens are tied to the token string, not the wallet. Any agent instance that holds the token gets access. Any agent without it must pay. Think of it like a password — whoever has it gets in. The agent is responsible for persisting the token. If the token is lost, the agent must pay again for a new one. MonkePay cannot recover a lost token. Tokens are scoped per endpoint. A token for /api/report does not unlock /api/data. Each endpoint issues its own token. Tokens do not expire. Once granted, access is permanent. Time-limited and subscription-based access are on the roadmap.

Changing the unlock header name

By default, MonkePay uses X-MonkePay-Unlock as the header name for unlock tokens. Change it if it conflicts with your existing headers:
const monkePay = MonkePayHono({
  apiKeyId: process.env.MONKEPAY_API_KEY_ID!,
  apiKeySecret: process.env.MONKEPAY_API_KEY_SECRET!,
  price: '1.00',
  paymentMode: 'one_time',
  unlockHeaderName: 'X-My-Access-Token',
})
The agent must send the token using the same header name you configured.