Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prudra.dev/llms.txt

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

Add MPP to an endpoint

payMiddleware generates MPP challenges by default as part of dual-protocol. No additional configuration is needed for basic MPP support. The configuration below shows the full middleware chain with notes on MPP-specific behaviour.
Dashboard support for managing paid endpoints is coming soon. Use the SDK to configure MPP on your routes.

What the 402 response includes

When a request arrives without payment, the MPP challenge appears in the WWW-Authenticate header:
HTTP/1.1 402 Payment Required
WWW-Authenticate: Payment id="ch_abc123",
  realm="your-api.com",
  method="tempo",
  intent="charge",
  request="eyJhbW91bnQiOiIxMDAwMCIsInJlY2lwaWVudCI6IjB4..."
PAYMENT-REQUIRED: eyJwcmljZSI6IjAuMDUiLCJ...
Cache-Control: no-store
Content-Type: application/problem+json

{
  "type": "https://api.prudra.dev/problems/payment-required",
  "status": 402,
  "title": "Payment Required",
  "detail": "See WWW-Authenticate (MPP) or PAYMENT-REQUIRED (x402)."
}
Both headers are always present. The agent parses the WWW-Authenticate header to get the MPP challenge parameters.

What the 200 response includes

After successful MPP payment:
{
  "vaultId": "vlt_clx1abc123",
  "result": "...",
  "protocol": "mpp",
  "sessionId": null
}
If session payments are enabled (acceptSessions: true) and the agent is starting a new session, the response also includes the X-PRUDRA-SESSION-ID header and sessionId in the body.

payMiddleware options for MPP

ParameterTypeRequiredDescription
pricestringYesPayment amount in USD
descriptionstringNoHuman-readable description
acceptSessionsbooleanNoEnable session payments (Pro plan). Default: false

Error handling

ErrorStatusCause
payment-verification-failed402HMAC mismatch or transaction not found on Tempo
duplicate-payment409Same txHash used twice (replay blocked)
challenge-expired402Challenge expired — agent must request a new one
insufficient-payment402Transaction amount less than required price

Next steps