API Key Client Grouping for Resellers and Multi-Tenant SaaS
When you embed a PDF generation API into a service used by multiple clients, you need to know which key belongs to which client and how many PDFs each client generates each month.
FUNBREW PDF lets you set a client label and tags on each API key. A shared client_label groups PDF files and API logs by client. CSV exports also include the client_label column, so you can aggregate billing evidence in a spreadsheet.
This guide follows the actual dashboard and CSV behavior.
Why API key grouping matters
Common operational pain points
- Manual invoice allocation: checking a separate registry to map keys to clients at month end
- Logs that are hard to isolate: searching the entire account's logs when one client has a problem
- Tribal knowledge: a key name alone does not explain its purpose or owner
What grouping fixes
| Pain point | After grouping |
|---|---|
| Manual invoice allocation | Aggregate the CSV by client_label |
| Filtering logs | Filter by client name |
| Tribal knowledge | See client names and tags in the dashboard |
When to use client_label vs tags
Use client_label for the unit that groups PDFs, logs, and CSV rows. Use tags as key-management labels.
client_label |
tags |
|
|---|---|---|
| Count | One per key | Multiple allowed |
| Role | Filter PDFs and logs; aggregate CSV rows | Identify environments and purposes in the key list |
| Example | Acme Inc |
production, invoice-pdf |
| CSV export | Included as the client_label column |
Not exported |
| PDF and log filters | Supported | Not available |
Tags are not filter conditions on the PDF or API log pages. They also do not automatically aggregate costs by department or plan. For precise allocation, map your own client and department IDs to client_label in your database.
How to use it
Step 1: Add client information to each API key
Open Dashboard → API Keys → "New key" or "Edit" on an existing key.
- Key name: an internal name (e.g.
Acme Production) - Client / Project: the client company or project name (e.g.
Acme Inc) - Tags: environment or purpose (e.g.
production,invoice-pdf)
When you issue multiple keys for one client, use exactly the same client_label on every environment and purpose.
Step 2: Filter PDFs and logs by client
Use the "Client" filter on the PDF list and API log pages.
If multiple keys share a client_label, the filter shows PDFs and logs associated with all of those keys. This is a client-level view based on the keys' current labels, rather than a separate view for each key.
Step 3: Use CSV for billing allocation
Download the PDF CSV from /dashboard/pdf-files/csv. It contains these columns:
filename,original_name,source_type,file_size,download_count,max_downloads,expires_at,created_at,api_key,client_label
abc123.pdf,"acme-invoice-2026-04.pdf",html,254078,1,10,2026-05-01 00:00:00,2026-04-01 10:00:00,Acme Production,Acme Inc
def456.pdf,"beta-contract.pdf",html,128400,2,10,2026-05-01 00:00:00,2026-04-01 11:00:00,Beta Production,Beta Corp
The CSV contains the account's PDF records and does not inherit the page's current filters. After downloading it, group by client_label to calculate generation counts, file sizes, and download counts. The API log CSV is available at /dashboard/api-logs/csv and contains up to the latest 10,000 records.
Best practices by reseller scenario
Scenario 1: Agency model (separate billing per client)
client_label: "Acme Inc" tags: ["production"]
client_label: "Acme Inc" tags: ["staging"]
client_label: "Beta Corp" tags: ["production"]
client_label: "Gamma Studio" tags: ["production", "trial"]
Grouping the monthly CSV by client_label combines production and staging into one client total. If you bill only for production, add the per-key api_key column to your aggregation criteria. A trial tag is a management marker; it does not change billing state automatically.
Scenario 2: Multi-tenant SaaS
client_label: "tenant_001" tags: ["plan:pro", "production"]
client_label: "tenant_002" tags: ["plan:enterprise", "production"]
Using your database's tenant ID as client_label makes reconciliation straightforward. Manage plan changes and usage caps in your own application. Tags alone neither apply caps nor detect overage.
Scenario 3: Project-based contracting
client_label: "Project Alpha" tags: ["delivered", "support-2026"]
client_label: "Project Beta" tags: ["development"]
You can inspect PDFs and API logs by project. Tags make support windows and delivery status readable to people, while your project-management system should remain authoritative for billing status.
Design considerations
Grouping is a management label
client_label and tags organize keys. They do not change authentication scopes, billing, or per-client usage limits. Rate limiting follows the account plan and is shared by all keys on the account. Apply client-specific limits in your own application.
Keep keys safe
Rather than handing API keys directly to clients, keep keys on your own server and proxy client requests to FUNBREW PDF. Assigning a separate key to each client makes it easier to identify which key to disable after a leak.
Decide on a naming convention up front
Client labels are grouped by exact string matches. Acme Inc, acme inc, and Acme Inc. are treated as different clients, so establish rules for legal names, spaces, and honorifics before issuing keys.
Cost allocation patterns
Pattern 1: Department cost centers
Issue a key per department and combine the client and department in client_label, for example Acme Corp / Finance. For a client-wide invoice, maintain a client-ID-to-department-label mapping in your database and aggregate through that mapping rather than relying on prefix matching. A dept:finance tag is useful in the key list but does not appear in the CSV.
Pattern 2: Tiered pricing with usage caps
client_label: "tenant_A" tags: ["plan:starter", "production"]
client_label: "tenant_B" tags: ["plan:growth", "production"]
Manage tenant IDs, plans, and monthly caps in your billing service, then reconcile them with generation counts from the CSV. FUNBREW's /api/usage returns the account's monthly generation total; it has no byClient breakdown. If your application receives each client's generation requests, you can also use your own database counters for limit checks.
Pattern 3: Project-lifecycle cost tracking
Use distinct labels such as Project Omega / Internal and Project Omega / Production to separate internal work from billable output. Tags are absent from the CSV, so you cannot filter exported rows by a billable tag. Put the billing distinction in the label itself when it matters for invoicing.
Usage alert patterns
There is no real-time per-client usage API. A reliable approach is to download the PDF CSV periodically and aggregate current-month rows by created_at and client_label. This Python example reads the downloaded CSV and prints clients that have reached 90% of limits defined by your application.
import csv
from collections import Counter
from datetime import datetime
LIMITS = {"Acme Inc": 5000, "Beta Corp": 1000, "Gamma LLC": 2500}
current_month = datetime.now().astimezone().strftime("%Y-%m")
counts = Counter()
with open("pdf-files.csv", newline="", encoding="utf-8-sig") as file:
for row in csv.DictReader(file):
if row["created_at"].startswith(current_month):
counts[row["client_label"]] += 1
for client, cap in LIMITS.items():
used = counts[client]
if used >= cap * 0.9:
print(f"{client}: {used} / {cap} ({used / cap:.0%})")
This is a snapshot at the time you download the CSV, not a real-time alert. The pdf.generated webhook can notify you when generation completes, but its payload does not include client_label; do not rely on webhooks alone for per-client billing counters.
Client onboarding flow
- Create API keys — use the dashboard for each environment and purpose
- Set
client_label— use your client ID or a consistently formatted legal name - Set tags — record environments and plans for people reading the key list
- Register internal limits — add the client's cap to your own application
- Store credentials securely — use a secrets manager instead of emailing raw keys
- Smoke-test — generate one PDF from your server
- Document — add the key to your internal registry
API key creation, editing, and deletion are dashboard functions. There is no public /v1/api-keys REST API or master key for issuing keys, so onboarding automation cannot use those endpoints.
Offboarding a client
Download the final CSV before deleting the key in the dashboard. When a key is deleted, api_key_id on existing PDFs and API logs becomes null. You can no longer find that historical data through the key's current client_label, so save the CSV first and record the deletion date in your internal registry.
Summary
Effective API key grouping depends on this division of responsibility:
- Use
client_labelto group PDFs, API logs, and CSV rows by client - Use
tagsas management notes visible in the key list - Reconcile CSV exports with your accounting and billing data
- Manage client-specific limits, billing, and alerts in your own application
- Save a final CSV before deleting a key
See the official documentation for configuration and the dashboard to issue keys. The invoice API guide also covers invoice PDF automation.