Skip to main content

Use Cases

Explore common scenarios supported by the Object Storage Blueprint:

File Hosting

Bill customers based on total storage usage and upload volume.

Backup Services

Track backup data uploads and charge per GB stored.

Media CDN

Monitor media uploads and bill for storage and bandwidth.

Document Management

Track document uploads per customer for usage-based pricing.
Perfect for billing based on storage uploads, file hosting, CDN usage, or backup services.

Quick Start

Track object storage uploads with bytes consumed:
1

Install the SDK

npm install @dodopayments/ingestion-blueprints
2

Get Your API Keys

  • Dodo Payments API Key: Get it from Dodo Payments Dashboard
  • Storage Provider API Key: From AWS S3, Google Cloud Storage, Azure, etc.
3

Create a Meter

Create a meter in your Dodo Payments Dashboard:
  • Event Name: object_storage_upload (or your preferred name)
  • Aggregation Type: sum to track total bytes uploaded
  • Over Property: bytes to bill based on storage size
4

Track Storage Usage

import { Ingestion, trackObjectStorage } from '@dodopayments/ingestion-blueprints';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import fs from 'fs';

const ingestion = new Ingestion({
  apiKey: process.env.DODO_PAYMENTS_API_KEY,
  environment: 'test_mode',
  eventName: 'object_storage_upload'
});

const s3 = new S3Client({ region: 'us-east-1' });

// Read the file (example: from disk or request)
const fileBuffer = fs.readFileSync('./document.pdf');

// Upload to S3
const command = new PutObjectCommand({
  Bucket: 'my-bucket',
  Key: 'uploads/document.pdf',
  Body: fileBuffer
});

await s3.send(command);

// Track the upload
await trackObjectStorage(ingestion, {
  customerId: 'customer_123',
  bytes: fileBuffer.length
});

Configuration

Ingestion Configuration

apiKey
string
required
Your Dodo Payments API key from the dashboard.
environment
string
required
Environment mode: test_mode or live_mode.
eventName
string
required
Event name that matches your meter configuration.

Track Object Storage Options

customerId
string
required
The customer ID for billing attribution.
bytes
number
Number of bytes uploaded. Required for byte-based billing.
metadata
object
Optional metadata about the upload like bucket name, content type, etc.

Best Practices

Track Before or After Upload: You can track the event before or after the actual upload depending on your error handling strategy.
Handle Upload Failures: Only track successful uploads to avoid billing for failed operations.
I