Overview
You may want to grant usage credits to customers even before they make a purchase. This is useful for:- Free trial credits - Give new signups free credits to try your service
- Promotional campaigns - Grant credits as part of marketing initiatives
- Testing and demos - Provide credits for product demonstrations
How It Works
To grant credits before a purchase, you need to:- Create a customer in Polar (if they don’t exist)
- Create a meter with Sum aggregation to track usage
- Ingest an event with a negative value to grant credits
Why negative values?When you ingest an event with a negative value (e.g.,
-10) to a meter using Sum aggregation, it grants the customer credits. A negative balance means available credits, which get reduced as they use your service.Step 1: Create a Meter
First, create a meter that will track your customers’ usage.1
Navigate to Meters
In the Polar dashboard sidebar, click on Products > Meters.
2
Create a new meter
Click Create Meter and configure:
- Name: Give your meter a descriptive name (e.g., “API Calls” or “Storage Usage”)
- Filter: Add filters to match your usage events (e.g., name equals “api_usage”)
- Aggregation: Select Sum and enter the property to sum (e.g.,
units)
3
Save the meter
Save your meter and note down the meter name - you’ll need this when ingesting events.
Step 2: Create a Customer
If your customer doesn’t already exist in Polar, you need to create them first.Option A: Create via Dashboard
1
Navigate to Customers
In the Polar dashboard sidebar, click on Customers.
2
Add new customer
Click Add Customer and fill in:
- Email: Customer’s email address (required)
- Name: Customer’s full name (optional)
- External ID: Your internal user ID for easy reference (optional but recommended)
3
Save customer
Click Save and note down the Customer ID.
Option B: Create via API
Use the Polar SDK or API to create a customer programmatically:create-customer.ts
Using External ID
If you set anexternalId when creating the customer, you can use it in event ingestion instead of the Polar customer ID:
Step 3: Grant Credits by Ingesting a Negative Event
Now that you have a customer and a meter, grant credits by ingesting an event with a negative value.Using the Polar SDK
grant-credits.ts
Using External Customer ID
If you’re usingexternalId for customer management:
grant-credits-external.ts

