Benji Pays Usage API
Usage and consumption reporting for billing (real-time calculation)
Usage and consumption reporting for billing (real-time calculation)
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/benjipays-com:benjipays-com-usage-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Benji Pays Partner Usage API
description: 'The Benji Pays Partner API is a JSON over HTTPS API. All endpoints live under `/v2`. Errors follow RFC 7807 and are served as `application/problem+json`. This overview describes the cross-cutting behavior shared by every partner endpoint. Endpoint-specific schemas live with each operation. ## Authentication
Partner endpoints authenticate with an Auth0 M2M access token in the `Authorization` header:
```
Authorization: Bearer
```
Tokens are obtained from Auth0 with the OAuth 2.0 client-credentials grant against the `https://api.benjipays.com` audience. The token''s actor claim (`distributor`, `partner`, or `organization`) and OAuth scopes determine which routes the caller can reach. Failures return `401 Unauthorized` (missing/expired/invalid credentials) or `403 Forbidden` (wrong actor type or missing scope). ## Request and Correlation IDs
Two header pairs help with tracing:
| Header | Direction | Purpose |
| --- | --- | --- |
| `X-Request-ID` | request (optional) / response (always) | Unique identifier for one request. Generated as a UUID v4 when the client omits it. |
| `X-Correlation-ID` | request (optional) / response (always) | Identifier that flows across service boundaries for distributed tracing. Generated as a UUID v4 when omitted. |
Both IDs are echoed on success and included as `requestId` / `correlationId` extensions on `application/problem+json` error responses. These headers are auto-injected on every operation in this spec — do not redeclare them per route. ## Idempotency
POST, PATCH, and PUT endpoints accept an `Idempotency-Key` header to make retries safe. - Format: 1–255 characters, alphanumeric only (`[a-zA-Z0-9]+`). - Scope: keys are scoped per actor (no cross-tenant collisions). - Cache: the first response for a given key is cached for 24 hours. - Replay: a duplicate request with the same key and the same body returns the cached response with `X-Idempotency-Replayed: true` only after credentials were resolved by the global authenticate middleware (API key or Auth0 JWT signature check) before the idempotency cache lookup. - Conflict: same key with a different body returns `409 Conflict`. - In-flight: a second request with the same key while the first is still being processed returns `429 Too Many Requests` with `Retry-After` and problem `type` `https://api.benjipays.com/problems/idempotency-processing` (distinct from rate-limit `…/rate-limit-exceeded`). `Idempotency-Key` is auto-injected on every POST/PATCH/PUT operation in this spec — do not redeclare it per route. Routes that intentionally opt out set `x-bp-skip-idempotency: true`. The middleware fails open: if the cache layer is unavailable the request proceeds without idempotency protection. ## Pagination
List endpoints use offset-based pagination with two query parameters:
| Parameter | Type | Default | Bounds |
| --- | --- | --- | --- |
| `limit` | integer | `20` | `1`–`1000` |
| `offset` | integer | `0` | `≥ 0` |
Some endpoints use different bounds (for example usage/billing and autoprocessing forecast). Check the per-operation schema. Responses follow this envelope:
```json
{
"data": [ /* items */ ],
"pagination": {
"limit": 20,
"offset": 0,
"hasMore": true,
"nextOffset": 20,
"prevOffset": null
}
}
```
Many list endpoints also include `pagination.total` (count of matching items across all pages). Per-operation response schemas are authoritative. Use `hasMore` to decide whether to fetch another page and `nextOffset` for the next request rather than computing it on the client. ## Dates and Times
All **response** timestamps are ISO-8601 strings in UTC (for example `2024-01-01T12:00:00.000Z`). Date-range **query** parameters support two input modes where the endpoint accepts them:
| Input format | Interpretation |
| --- | --- |
| `YYYY-MM-DD` (calendar day) | Full day in **UTC**. Start = `00:00:00.000Z`, end = `23:59:59.999Z` on that date. Same start and end day returns the full UTC day. |
| ISO-8601 UTC timestamp (e.g.'
version: 2.0.0
contact:
name: Benji Pays API Support
email: benji@benjipays.com
servers:
- url: https://api.benjipays.com
description: Development server
security:
- BearerAuth: []
tags:
- name: Usage
description: Usage and consumption reporting for billing (real-time calculation)
paths:
/v2/usage:
get:
summary: Get usage snapshot for a month
description: '**Access:** Requires DISTRIBUTOR actor type
Returns usage data for all Organizations under the authenticated distributor for a specified month. Used by distributors (e.g., Sherweb) to show consumption in marketplace dashboards.
**Important Notes:**
- Always calculates for entire month (MTD if current month, full month if past)
- endDate is validated but effectively ignored for calculation
- NFR plans are represented as $0 plans, no separate flag
- Each organization may have 1+ items: base plan SKU + one row per overage tier (BENJI-{PLAN}-OVERAGE-TIER{n})
**Calculation:**
- Uses existing billing.js helpers (getPlanTypeFromUser)
- Queries results collection for transaction counts
- Uses user.billing.details for plan info (priceRanges)
- Integrates with autopay.isCompanyInFreeTrial() for trial status
Requires JWT authentication and ''partners:usage:read'' scope.'
tags:
- Usage
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/RequestIdHeader'
- $ref: '#/components/parameters/CorrelationIdHeader'
- in: query
name: startDate
schema:
type: string
description: Start date - must be the 1st of the month (YYYY-MM-01)
example: '2026-01-01'
required: true
description: Start date - must be the 1st of the month (YYYY-MM-01)
- in: query
name: endDate
schema:
type: string
description: 'End date - must be in the same month as startDate (YYYY-MM-DD). Note: Effectively ignored for calculation - always calculates for entire month (MTD if current month, full month if past)'
example: '2026-01-31'
required: true
description: 'End date - must be in the same month as startDate (YYYY-MM-DD). Note: Effectively ignored for calculation - always calculates for entire month (MTD if current month, full month if past)'
- in: query
name: partnerId
schema:
description: Optional filter by specific partner (MongoDB ObjectId)
example: 6022f98854f2c41d7ef2b1fe
type: string
pattern: ^[0-9a-fA-F]{24}$
description: Optional filter by specific partner (MongoDB ObjectId)
- in: query
name: organizationId
schema:
description: Optional filter by specific organization (MongoDB ObjectId)
example: 7033a09965b3d52e8fc3c2af
type: string
pattern: ^[0-9a-fA-F]{24}$
description: Optional filter by specific organization (MongoDB ObjectId)
- in: query
name: limit
schema:
description: 'Maximum number of results to return (default: 100, max: 500)'
example: 100
type: integer
minimum: 1
maximum: 500
description: 'Maximum number of results to return (default: 100, max: 500)'
- in: query
name: offset
schema:
description: 'Number of results to skip for pagination (default: 0)'
example: 0
type: integer
minimum: 0
maximum: 9007199254740991
description: 'Number of results to skip for pagination (default: 0)'
responses:
'200':
description: Successful response with usage snapshot
content:
application/json:
example:
data:
- organizationId: 7033a09965b3d52e8fc3c2af
apiParent:
type: partner
distributorExternalId: sherweb
partnerExternalId: acme-msp
partnerId: 6022f98854f2c41d7ef2b1fe
name: Acme Corp
externalId: ext_org_67890
sku: BENJI-PRO
quantity: 1
trial: false
planName: pro
period: 2026-01
- organizationId: 7033a09965b3d52e8fc3c2af
apiParent:
type: partner
distributorExternalId: sherweb
partnerExternalId: acme-msp
partnerId: 6022f98854f2c41d7ef2b1fe
name: Acme Corp
externalId: ext_org_67890
sku: BENJI-PRO-OVERAGE-TIER1
quantity: 100
trial: false
period: 2026-01
- organizationId: 7033a09965b3d52e8fc3c2af
apiParent:
type: partner
distributorExternalId: sherweb
partnerExternalId: acme-msp
partnerId: 6022f98854f2c41d7ef2b1fe
name: Acme Corp
externalId: ext_org_67890
sku: BENJI-PRO-OVERAGE-TIER2
quantity: 45
trial: false
period: 2026-01
pagination:
nextOffset: null
prevOffset: null
limit: 100
offset: 0
hasMore: false
schema:
$ref: '#/components/schemas/UsageResponse'
'400':
description: Bad Request - Invalid date format or dates not in same month
content:
application/problem+json:
schema:
type: object
properties:
type:
type: string
description: Problem type URI
example: https://api.benjipays.com/problems/bad-request
title:
type: string
description: Error title
example: Bad Request
status:
type: number
description: HTTP status code
example: 400
detail:
type: string
description: Error detail message
example: startDate must be the 1st of the month (YYYY-MM-01)
instance:
description: Instance URI
example: /v2/usage
type: string
required:
- type
- title
- status
- detail
additionalProperties: false
description: Error response (RFC 7807 Problem Details)
example:
type: https://api.benjipays.com/problems/bad-request
title: Bad Request
status: 400
detail: startDate must be the 1st of the month (YYYY-MM-01)
instance: /v2/usage
'401':
description: Unauthorized - Invalid or missing authentication token
content:
application/problem+json:
schema:
type: object
properties:
type:
type: string
description: Problem type URI
example: https://api.benjipays.com/problems/bad-request
title:
type: string
description: Error title
example: Bad Request
status:
type: number
description: HTTP status code
example: 400
detail:
type: string
description: Error detail message
example: startDate must be the 1st of the month (YYYY-MM-01)
instance:
description: Instance URI
example: /v2/usage
type: string
required:
- type
- title
- status
- detail
additionalProperties: false
description: Error response (RFC 7807 Problem Details)
example:
type: https://api.benjipays.com/problems/unauthorized
title: Unauthorized
status: 401
detail: Invalid or missing authentication token
instance: /v2/usage
'403':
description: Forbidden - Distributor actor type required
content:
application/problem+json:
schema:
type: object
properties:
type:
type: string
description: Problem type URI
example: https://api.benjipays.com/problems/bad-request
title:
type: string
description: Error title
example: Bad Request
status:
type: number
description: HTTP status code
example: 400
detail:
type: string
description: Error detail message
example: startDate must be the 1st of the month (YYYY-MM-01)
instance:
description: Instance URI
example: /v2/usage
type: string
required:
- type
- title
- status
- detail
additionalProperties: false
description: Error response (RFC 7807 Problem Details)
example:
type: https://api.benjipays.com/problems/forbidden
title: Forbidden
status: 403
detail: Access requires distributor actor type
instance: /v2/usage
'429':
description: Too Many Requests - Rate limit exceeded
content:
application/problem+json:
schema:
type: object
properties:
type:
type: string
description: Problem type URI
example: https://api.benjipays.com/problems/bad-request
title:
type: string
description: Error title
example: Bad Request
status:
type: number
description: HTTP status code
example: 400
detail:
type: string
description: Error detail message
example: startDate must be the 1st of the month (YYYY-MM-01)
instance:
description: Instance URI
example: /v2/usage
type: string
required:
- type
- title
- status
- detail
additionalProperties: false
description: Error response (RFC 7807 Problem Details)
example:
type: https://api.benjipays.com/problems/rate-limit-exceeded
title: Too Many Requests
status: 429
detail: Rate limit exceeded. Please retry after the specified time.
instance: /v2/usage
retryAfterSeconds: 1
limit: 5
operationId: getV2Usage
x-operation-id-source: derived
components:
schemas:
UsageResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/UsageItem'
description: Array of usage items grouped by organization + SKU
pagination:
type: object
properties:
nextOffset:
anyOf:
- type: number
- type: 'null'
description: Offset for next page (null if no more results)
example: null
prevOffset:
anyOf:
- type: number
- type: 'null'
description: Offset for previous page (null if first page)
example: null
limit:
type: number
description: Number of items per page
example: 100
offset:
type: number
description: Current offset
example: 0
hasMore:
type: boolean
description: Whether more results are available
example: false
required:
- nextOffset
- prevOffset
- limit
- offset
- hasMore
additionalProperties: false
description: Pagination metadata
required:
- data
- pagination
additionalProperties: false
description: Usage snapshot response
UsageItem:
type: object
properties:
organizationId:
type: string
description: MongoDB ObjectId of the organization
example: 7033a09965b3d52e8fc3c2af
apiParent:
type: object
properties:
type:
type: string
enum:
- distributor
- partner
description: Parent type — distributor or partner
example: partner
distributorExternalId:
type: string
description: Distributor external ID
example: sherweb-prod
partnerExternalId:
description: Partner external ID (present for partner-type orgs)
example: partner-ext-123
type: string
partnerId:
description: Partner MongoDB ObjectId (present for partner-type orgs)
example: 6022f98854f2c41d7ef2b1fe
type: string
required:
- type
- distributorExternalId
additionalProperties: false
description: API parent — who created the organization
name:
type: string
description: Organization name
example: Acme Corp
externalId:
type: string
description: External ID from distributor's system
example: ext_org_67890
sku:
type: string
description: SKU identifier — plan SKU (e.g., BENJI-PRO) for base plan, or BENJI-{PLAN}-OVERAGE-TIER{n} (e.g., BENJI-PRO-OVERAGE-TIER1) for each overage tier
example: BENJI-PRO
quantity:
type: number
description: Quantity — 1 for base plan, per-tier overage count for BENJI-{PLAN}-OVERAGE-TIER{n} rows
example: 1
trial:
type: boolean
description: Whether organization is in trial period
example: false
planName:
description: Plan name (included for base plan SKU, omitted for overage)
example: pro
type: string
period:
type: string
description: Period in YYYY-MM format
example: 2026-01
required:
- organizationId
- apiParent
- name
- externalId
- sku
- quantity
- trial
- period
additionalProperties: false
description: Usage item for an organization
parameters:
CorrelationIdHeader:
name: X-Correlation-ID
in: header
required: false
description: Optional ID that flows across service boundaries for distributed tracing. The server generates a UUID v4 if omitted and always echoes the value in the response.
schema:
type: string
format: uuid
RequestIdHeader:
name: X-Request-ID
in: header
required: false
description: Optional client-supplied unique ID for one request. The server generates a UUID v4 if omitted and always echoes the value in the response.
schema:
type: string
format: uuid
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: 'Auth0 JWT token obtained via OAuth2 client credentials flow. Include the token in the Authorization header as: Bearer <token>'
x-speakeasy-retries:
strategy: backoff
backoff:
initialInterval: 500
maxInterval: 60000
maxElapsedTime: 3600000
exponent: 1.5
statusCodes:
- 5XX
retryConnectionErrors: true
x-provenance:
method: searched
source: https://developer.benjipays.com/reference
harvested: '2026-11-02'
tool: harvest-readme-openapi.py
note: Assembled verbatim from the OpenAPI definition ReadMe embeds in each operation page of the provider's developer portal; paths and components merged by API title, nothing authored.
assembled_from:
- https://developer.benjipays.com/reference/get_v2-billing.md
- https://developer.benjipays.com/reference/get_v2-organizations-organizationid.md
- https://developer.benjipays.com/reference/get_v2-organizations.md
- https://developer.benjipays.com/reference/get_v2-partners-partnerid.md
- https://developer.benjipays.com/reference/get_v2-partners.md
- https://developer.benjipays.com/reference/get_v2-plans-planid.md
- https://developer.benjipays.com/reference/get_v2-plans.md
- https://developer.benjipays.com/reference/get_v2-usage.md
- https://developer.benjipays.com/reference/get_v2-whoami.md
- https://developer.benjipays.com/reference/patch_v2-organizations-organizationid-plan.md
- https://developer.benjipays.com/reference/post_v2-organizations-organizationid-activate.md
- https://developer.benjipays.com/reference/post_v2-organizations-organizationid-close.md
- https://developer.benjipays.com/reference/post_v2-organizations-organizationid-resend-invite.md
- https://developer.benjipays.com/reference/post_v2-organizations-organizationid-suspend.md
- https://developer.benjipays.com/reference/post_v2-organizations.md
- https://developer.benjipays.com/reference/post_v2-partners.md
- https://developer.benjipays.com/reference/post_v2-whoami-echo.md
merge:
pages: 17
deduped: 61
conflicts_kept_first: 0