Skip to main content
OpenAPI

Usage API

Endpoints for querying credits usage events, usage summaries, organization resource packages, and seat-month consumption.

List member usage events

GET /v1/organizations/{org_id}/members/{member_id}/usage-events
Query parameters:
ParameterTypeDescription
startDatestringOptional; start time in RFC 3339 or Unix milliseconds
endDatestringOptional; end time in RFC 3339 or Unix milliseconds. When both dates are provided, the range must not exceed 7 days
sourcesstringFilter by source, comma-separated
operationsstringFilter by operation type, comma-separated
modelTiersstringFilter by model tier, comma-separated
maxResultsintegerItems per page; default 20, max 100
nextTokenstringPagination cursor
Request example:
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/members/member_001/usage-events?startDate=2025-01-01T00:00:00Z&endDate=2025-01-07T23:59:59Z&maxResults=20" \
  -H "Authorization: Bearer <api_key>"
Response example:
{
  "usages": [
    {
      "timestamp": 1736073000000,
      "userId": "550e8400-e29b-41d4-a716-446655440000",
      "memberId": "member_001",
      "userEmail": "user@example.com",
      "source": "IDE",
      "operation": "Agent",
      "modelTier": "Standard",
      "credits": 1.5,
      "cost": 1.5
    }
  ],
  "maxResults": 20,
  "nextToken": "token_xyz"
}
This is a legacy usage endpoint: the top-level field is usages, and it does not return eventId or durationMs. Those fields belong to the V2 events endpoints under /usage/.

Get usage summary

GET /v1/organizations/{org_id}/members/{member_id}/usage-summary
Query parameters:
ParameterTypeDescription
startDatestringStart date (ISO 8601)
endDatestringEnd date (ISO 8601); range must not exceed 7 days
groupBystringGroup by: source or operation
Request example:
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/members/member_001/usage-summary?startDate=2025-01-10T00:00:00Z&endDate=2025-01-16T23:59:59Z&groupBy=source" \
  -H "Authorization: Bearer <api_key>"
Response example:
{
  "summary": {
    "IDE": 120.5,
    "Web": 30.0
  }
}

List organization usage events

GET /v1/organizations/{org_id}/usage-events
Query parameters are the same as the member usage events endpoint (startDate, endDate, sources, operations, modelTiers, maxResults, nextToken). Returns usage events across all members in the organization. Request example:
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/usage-events?startDate=2025-01-01T00:00:00Z&endDate=2025-01-07T23:59:59Z" \
  -H "Authorization: Bearer <api_key>"
Response example:
{
  "usages": [
    {
      "timestamp": 1736073000000,
      "userId": "550e8400-e29b-41d4-a716-446655440005",
      "memberId": "member_005",
      "userEmail": "member5@example.com",
      "source": "IDE",
      "operation": "Inline Chat",
      "modelTier": "Premium",
      "credits": 5.0,
      "cost": 5.0
    }
  ],
  "maxResults": 20,
  "nextToken": "token_next"
}

List organization resource packages

GET /v1/organizations/{org_id}/resource-packages
Query parameters:
ParameterTypeDescription
statusstringFilter by package status
orderBystringSort field
orderstringSort direction: asc or desc
maxResultsintegerItems per page; default 20, max 100
nextTokenstringPagination cursor
Request example:
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/resource-packages?status=ACTIVE&orderBy=createdAt&order=desc" \
  -H "Authorization: Bearer <api_key>"
Response example:
{
  "resourcePackages": [
    {
      "packageId": "pkg_001",
      "name": "Premium Credits Pack",
      "totalCredits": 10000,
      "remainingCredits": 7500,
      "status": "ACTIVE",
      "expiresAt": "2025-06-30T23:59:59Z",
      "createdAt": "2025-01-01T00:00:00Z"
    }
  ],
  "nextToken": null
}

Seat-month balance batches

GET /v1/organizations/{org_id}/seat-month-batches
Only available for organizations purchased through third-party channels.
Request example:
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/seat-month-batches" \
  -H "Authorization: Bearer <api_key>"
Response example:
{
  "batches": [
    {
      "batchId": "batch_001",
      "totalSeatMonths": 120,
      "remainingSeatMonths": 80,
      "effectiveAt": "2025-01-01T00:00:00Z",
      "expiresAt": "2025-12-31T23:59:59Z"
    }
  ]
}

Seat-month consumption by period

GET /v1/organizations/{org_id}/seat-month-usages
Only available for organizations purchased through third-party channels.
Query parameters:
ParameterTypeDescription
periodStartstringRequired; period range start time in RFC 3339 format
periodEndstringRequired; period range end time in RFC 3339 format; must be later than periodStart
memberIdstringOptional; filter by organization member ID
userIdstringOptional; filter by user ID
pageSizeintegerOptional; page size, default 100 and max 500
pageTokenstringOptional; pass the nextToken from the previous response
Request example:
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/seat-month-usages?periodStart=2025-01-01T00:00:00Z&periodEnd=2025-04-01T00:00:00Z&pageSize=100" \
  -H "Authorization: Bearer <api_key>"
Response example:
{
  "seatMonthUsages": [
    {
      "memberId": "member_001",
      "userId": "550e8400-e29b-41d4-a716-446655440000",
      "periodStart": "2025-01-01T00:00:00Z",
      "periodEnd": "2025-02-01T00:00:00Z",
      "consumedSeatMonths": 20.0,
      "refundedSeatMonths": 5.0,
      "netSeatMonths": 15.0
    }
  ],
  "pageSize": 100,
  "nextToken": "2"
}