Sign in →

Developer Hub

Everything developers need to integrate with Aforo — SDKs, code samples, the API simulator, live event stream, and the event tester.

Updated 2026-07-29Suggest edits

Developer Hub

The Developer Hub is where your customers (and your team) get everything needed to integrate with your API products — from quick-start code snippets to live event testing.

ℹ

Developer Hub is a testing surface: connect, fire test events, and watch them arrive live. To browse and search the historical row-level event stream (filter by customer/metric/time, inspect raw payloads), go to Usage Ingestion → Recent Events — that's the single home for it.

Credentials

The Credentials tab is where you get the keys and endpoints to integrate.

API Key Vault

Manage your secret keys per environment with a Sandbox / Production toggle:

EnvironmentPrefixBills your customers?
Sandboxsk_test_No — safe for local dev, CI, and integration tests
Productionsk_live_Yes — every event is metered and billed

Each environment shows its active key (prefix only — the full secret is displayed once, at creation) plus a Generate button when none exists and a Roll key button to rotate. Rolling mints the replacement first, then revokes the old key, so you never lose access mid-rotation.

ℹ

There is no publishable key here — secret keys are server-side only. For a browser-safe public credential, use Embed Keys (Customize Storefront → Embed Studio), which are origin-scoped for the browser. For multiple keys or fine-grained scopes, use Workspace Admin → API Keys. Full key format, usage, and rotation details: Authentication & API Keys.

Plugs Dispatcher

Register outbound endpoints to receive real-time event notifications (invoice.created, invoice.paid, subscription.cancelled, margin.guard.blocked, and more). Each endpoint gets a signing secret you use to verify delivery authenticity.

Integration Tiers

The Integration Guide (a dedicated page in the console) organizes integrations into six tiers:

TierMethodWho Uses It
0 — GatewayAuto-capture via your API gateway pluginTeams already running Kong, Apigee, AWS, Azure, or MuleSoft
1 — MiddlewareExpress/Fastify/Django/Spring middlewareServer-side apps with request lifecycle access
2 — SDK@aforo/metering / aforo-meteringApplications without a gateway or middleware
3 — RESTDirect HTTP POST to usage-ingestorAny language, maximum flexibility
4 — File UploadBatch CSV/JSON uploadHistorical data migration, offline systems
5 — MCP ProxySidecar proxy for stdio / SSE MCP serversMCP servers you can't add an SDK to

Gateway Plugins

Aforo ships production-ready plugins for all major API gateways:

GatewayPlugin FileDetection
Kongkong-plugin-aforo-meteringLua log phase
Apigeeapigee-shared-flow-aforo-meteringJavaScript shared flow
AWS API Gatewayaws-lambda-aforo-meteringCloudWatch Logs Lambda
Azure APIMazure-apim-policy-aforo-meteringOutbound policy fragment
MuleSoftmulesoft-policy-aforo-meteringAnypoint custom policy

All plugins:

  • Auto-detect MCP tools/call JSON-RPC requests and extract tool_name + agent_id
  • Buffer events locally and batch-flush to usage-ingestor
  • Include exponential backoff with 3 retries
  • Handle gateway restarts without losing buffered events

SDK — Node.js

npm install @aforo/metering
import { AforoClient, expressMiddleware } from '@aforo/metering'

const aforo = new AforoClient({
  apiKey: process.env.AFORO_API_KEY,  // the key carries your workspace identity
})

// Meter every request automatically
app.use(expressMiddleware(aforo))

// Or record events directly
await aforo.track({
  customerId: req.user.customerId,
  metricName: 'api-calls',
  quantity: 1,
})

SDK — Python

pip install aforo-metering
from aforo_metering import AforoClient

aforo = AforoClient(api_key=os.getenv("AFORO_API_KEY"))

# Record events directly
await aforo.track(
    customer_id=request.user.customer_id,
    metric_name="api-calls",
    quantity=1
)

MCP Server SDKs

For MCP Server products, use the dedicated MCP metering SDKs:

// Node.js MCP SDK
import { billing } from '@aforo/mcp-metering'

server.tool("search", schema, billing.wrapToolHandler(async (args) => {
  // your tool implementation
  return { results: [...] }
}))

The SDK automatically records tool name, agent ID, execution duration, and status.

AI Agent SDK

For AI Agent products, use @aforoai/agent-metering — it drives the same wire path as the MCP SDK but with capability-level, not tool-level, granularity. Pass the capability name to recordStep or recordToolCall; the SDK emits it as a top-level capabilityName on the ingest payload so the platform can look up per-capability rate multipliers on your rate plan.

import { AforoAgent } from '@aforoai/agent-metering'

const agent = new AforoAgent({
  tenantId: process.env.AFORO_TENANT_ID!,
  productId: 'prod_my_agent',
  apiKey: process.env.AFORO_API_KEY!,
})

const session = await agent.startSession({ agentId: 'agt_001' })

// Capability name is emitted as top-level `capabilityName` on the wire —
// pricing engine reads it as the per-capability dimension key.
await session.recordStep({
  stepKind: 'TOOL_CALL',
  capabilityName: 'summarize_email',
  inputTokens: 320,
  outputTokens: 84,
})

await session.end({ taskCompleted: true })

If you POST directly to /v1/ingest instead of using the SDK, send capabilityName at the top level of the payload — the same slot as MCP's toolName. A metadata.capability_name (or metadata.capabilityName) fallback still works for existing integrations, but the top-level path wins when both are present.

API Simulator

The API Simulator (Developer Hub → API Simulator) is a request builder for exercising any Aforo endpoint against live services without leaving the console:

  • Pick an endpoint from the reference tree, then fill path parameters ({id}, {customerId}) and query parameters in dedicated inputs — a live URL preview shows exactly what will be sent. Send stays disabled until every required path parameter is filled, so you never accidentally fire a request with a {placeholder} still in the URL.
  • Set the workspace id (X-Tenant-Id), extra headers, and a JSON body; your bearer token is injected automatically.
  • Run the request and inspect the status code, timing, and response body.
  • On a 4xx/5xx, an inline troubleshooting panel maps the status to the likely cause and fix (missing token, unfilled path parameter, wrong verb, rate limit, …).

The environment toggle controls write safety:

ModeBehavior
SandboxRead-only — only GET requests run. Write verbs (POST/PUT/PATCH/DELETE) are blocked, so there's no data impact.
ProductionWrites are allowed, but each one asks for confirmation — naming the method and the live URL — before it fires.
ℹ

The simulator runs against live services; there is no isolated sandbox host yet, which is why Sandbox mode enforces read-only rather than implying isolation.

Event Tester & Live Stream

The Event Tester composes and fires a single test event, then shows an "accepted" receipt (event ID, customer, metric, quantity, status). Test events are validated against Aforo's own sandbox workspace — never yours — so they are not metered or billed to you. The Live Events terminal watches usage events arrive in real time — fire from one, verify in the other:

  • Connect via SSE to /v1/ingest/stream
  • Events appear within 2 seconds of ingestion
  • Filter by customer, product, or event type
  • Diagnose integration issues without reading logs

Because a test event is attributed to the Aforo sandbox workspace (not yours), it will not appear in your own Usage Ingestion → Recent Events — the tester shows a connectivity confirmation only. To inspect your real ingested traffic, send events with a live key and open Usage Ingestion → Recent Events.

Webhook Sources

If your data originates from third-party webhooks (Stripe, Twilio, SendGrid, GitHub, Slack), configure a Webhook Source to ingest those events as Aforo usage events:

  1. Go to Integrations → Webhook Sources
  2. Select a template or create custom
  3. Configure JSONPath extraction rules
  4. Copy the Aforo webhook receiver URL
  5. Paste it as the webhook destination in the third-party service