Scrawn LogoScrawn Docs
Scrawn LogoScrawn Docs

Introduction

Your billing simplified to a single function call

Welcome to Scrawn

Scrawn is a billing infrastructure that lets you integrate usage-based billing into your application with a single function call.

Simple Integration

Track billable events, calculate usage, and handle payments - all with one line of code.

What is Scrawn?

Scrawn tracks user events, calculates usage, and handles payments - all behind a simple SDK. Instead of building billing logic yourself, you call event consumers and we handle the rest.

import { Scrawn } from '@scrawn/sdk';

const scrawn = new Scrawn({
  apiKey: process.env.SCRAWN_KEY!,
  baseUrl: process.env.SCRAWN_BASE_URL!
});

// That's it - track usage with one line
await scrawn.sdkCallEventConsumer({ 
  userId: 'uuid', 
  debitAmount: 69.69,
});

One line of code - That's all you need to start tracking billable events in your application.

Why Scrawn?

Single Line Integration

No complex billing logic. One function call tracks events, calculates usage, and triggers payments.

Usage-Based Billing

Charge users based on actual consumption. Track API calls and function invocations per user.

Built-in Admin Dashboard

Monitor events, manage API keys, and view analytics out of the box.

How It Works

  1. Deploy Backend - Self-host the gRPC server with PostgreSQL
  2. Install SDK - Add @scrawn/sdk to your application
  3. Track Events - Call scrawn.sdkCallEventConsumer() whenever billable actions occur
  4. Collect Payment - Call scrawn.collectPayment() when usage exceeds threshold

Getting Started

Use Cases

  • API Platforms - Charge per API request
  • AI Services - Bill based on compute/tokens used
  • Data Processing - Track storage, bandwidth, or processing time
  • SaaS Products - Usage-based pricing for any metric

Features

  • Self-Hosted - Full control over your billing infrastructure
  • gRPC Backend - High-performance server with PostgreSQL
  • Type-Safe SDK - TypeScript SDK with full type safety
  • Framework Agnostic - Works with Express, Next.js, Fastify, tRPC, NestJS
  • Production Ready - LRU caching, retry logic, error handling

Open Source

Scrawn is open source and available on GitHub.