Overview
When using API key authentication with theX-Tenant-ID header, Papermap automatically tracks:
- Credits consumed per tenant per billing period
- Request count per tenant per billing period
- Monthly aggregation with automatic period bucketing
How It Works
Billing Period
Usage is automatically bucketed by calendar month:- Period Start: First day of month (e.g., 2025-01-01 00:00:00)
- Period End: Last day of month (e.g., 2025-01-31 23:59:59)
API Endpoints
The base URL for the Papermap API is
https://prod.dataapi.papermap.ai/.Get Workspace Tenant Usage
Retrieve usage data for all tenants in a workspace. Request:| Parameter | Type | Required | Description |
|---|---|---|---|
from_period | string | No | Start period filter (YYYY-MM format) |
to_period | string | No | End period filter (YYYY-MM format) |
page | integer | No | Page number (default: 1) |
per_page | integer | No | Items per page (default: 50, max: 100) |
Get Tenant Usage History
Retrieve usage history for a specific tenant. Request:| Parameter | Type | Required | Description |
|---|---|---|---|
from_period | string | No | Start period filter (YYYY-MM format) |
to_period | string | No | End period filter (YYYY-MM format) |
page | integer | No | Page number (default: 1) |
per_page | integer | No | Items per page (default: 50, max: 100) |
Authentication
These endpoints use the same HMAC signature authentication as other external API endpoints. See the Authentication Guide for details. Required headers:X-API-Key-ID: Your API key identifierX-Workspace-ID: Your workspace IDX-Valid-Until: Unix timestamp for request expirationX-Signature: HMAC-SHA256 signature
Implementation Examples
The
_get_auth_headers function is a helper function that generates the HMAC signature for the API request found
in the HMAC Authentication guide.Use Cases
Billing & Invoicing
Generate per-tenant invoices based on actual usage
- Query usage for billing period
- Calculate costs based on credits consumed
- Automate invoice generation
Usage Analytics
Monitor tenant consumption patterns
- Identify high-usage tenants
- Track usage trends over time
- Plan capacity accordingly
Quota Management
Implement tenant-level quotas
- Compare usage against limits
- Send usage warnings
- Enforce rate limits per tenant
Cost Allocation
Attribute costs to business units
- Track departmental usage
- Chargeback reporting
- Budget planning
Response Fields
| Field | Type | Description |
|---|---|---|
tenant_id | string | The tenant identifier from X-Tenant-ID header |
period | string | Billing period in YYYY-MM format |
period_start | datetime | Start of the billing period |
period_end | datetime | End of the billing period |
credits_used | integer | Total credits consumed in this period |
request_count | integer | Total API requests made in this period |
total_records | integer | Total number of usage records (for pagination) |
total_pages | integer | Total number of pages available |
Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | Invalid period format | Period must be in YYYY-MM format |
| 401 | Unauthorized | Invalid or missing authentication |
| 403 | Access denied | No access to the specified workspace |
| 404 | Not found | Workspace or tenant not found |

