Skip to Content
Payrudder

Quickstart

Preview

From an empty app to your first metered usage event in five minutes.

Payrudder meters what your customers use, prices it, invoices it and collects the money. This page takes you from an empty app to a first usage event, then shows where the money part starts.

Create an app and an API key

Sign in to the console and create an app. Every app has two environments:

  • Sandbox: nothing is real. Payments run against a simulator, see Test mode.
  • Live: real customers, real money.

Create a key on the app's API keys page. A key starts with prk_test_ (sandbox) or prk_live_ (live), is shown once, and acts on its own environment only. Send it as a bearer token:

curl https://api.payrudder.com/v1/meters -H "Authorization: Bearer $PAYRUDDER_API_KEY"
The console's Connect your app page builds the code below with your own meter and address filled in.

Keys, roles and rotation: Authentication.

Define what you count

A meter says what is counted and how it adds up: sum of API calls, max of storage, unique users. Create one in the console or with POST /v1/meters. More in Usage metering.

Send usage

# Nothing to install: any HTTP client works.
export PAYRUDDER_API_KEY=prk_test_

curl -sS https://api.payrudder.com/v1/events \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"events":[{"customer_external_id":"cus_42","meter_code":"api_calls","quantity":"1","event_time":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","idempotency_key":"first-event-1"}]}'

Up to 500 events per request. The answer has one result per event, in order:

ResultMeaning
acceptedCounted.
duplicateThe same idempotency_key was sent before; counted once.
rejectedRefused, with an error_code (see Errors). A bad event does not fail the batch.
Live keys must send an idempotency_key with every event, so a retry never counts twice (see Idempotency). quantity is an exact decimal: send it as a string.

Package, price, subscribe

Publish a package (a plan with a fixed fee, per-unit prices for meters, and limits), then subscribe a customer to it with POST /v1/subscriptions. At the end of the period Payrudder turns the usage into an invoice, collects it through the payment provider you connected and sends the receipt, in the customer's language.

Hear about it

Register a webhook endpoint with POST /v1/webhook-endpoints and verify each delivery with the SDK. See Webhooks, or try it on your machine with Receive webhooks locally.

Errors, retries, limits

Every error has a stable error.key: translate the key, not the message (Errors). A 429 carries Retry-After. The SDKs retry 429 and 5xx for you, with the same idempotency key.

Where to next