Skip to content

Get Credit Usage

Request

Get credit usage for a tenant within a specified date range.

Overview

This endpoint retrieves credit usage information for a tenant within a specified date range. It supports optional filtering by workflow ID, workflow run ID, and custom key-value pairs.

Query Parameters

  • start_date: Start date for the calculation period (required)
  • end_date: End date for the calculation period (required)
  • workflow_id: Optional workflow ID for filtering results
  • workflow_run_id: Optional workflow run ID for filtering results
  • custom_key: Optional custom key for filtering results
  • custom_value: Optional custom value for filtering results

Response Fields

  • success: Boolean indicating request success
  • tenant_id: The tenant ID
  • start_date: Echo of the start date
  • end_date: Echo of the end date
  • credits_used: Total credits used in the specified period

Authentication

This endpoint requires authentication via Bearer token. The tenant ID is automatically extracted from the authenticated user's token.

Example Request

GET /v1/credits/usage?start_date=2024-01-01T00:00:00Z&end_date=2024-12-31T23:59:59Z&workflow_id=workflow-123

Example Response

{
  "success": true,
  "tenant_id": 123,
  "start_date": "2024-01-01T00:00:00Z",
  "end_date": "2024-12-31T23:59:59Z",
  "credits_used": 1250.5
}
Security
BearerAuth
Query
start_datestring, (date-time)(Start Date)required

Start date for credit calculation

end_datestring, (date-time)(End Date)required

End date for credit calculation

workflow_idstring or null(Workflow Id)
Any of:

Optional workflow ID for filtering

string
workflow_run_idstring or null(Workflow Run Id)
Any of:

Optional workflow run ID for filtering

string
custom_keystring or null(Custom Key)
Any of:

Optional custom key for filtering

string
custom_valuestring or null(Custom Value)
Any of:

Optional custom value for filtering

string
curl -i -X GET \
  'https://api-gateway.agenthq.withlantern.com/v1/credits/usage?start_date=2019-08-24T14%3A15%3A22Z&end_date=2019-08-24T14%3A15%3A22Z&workflow_id=string&workflow_run_id=string&custom_key=string&custom_value=string' \
  -H 'Authorization: Bearer <YOUR_ApiToken_HERE>'

Responses

Success Response

Bodyapplication/json
successboolean(Success)required

Boolean indicating request success

tenant_idinteger(Tenant Id)required

Tenant ID

start_datestring, (date-time)(Start Date)required

Start date for credit calculation

end_datestring, (date-time)(End Date)required

End date for credit calculation

credits_usednumber(Credits Used)required

Total credits used in the period

Response
{ "success": true, "tenant_id": 123, "start_date": "2024-01-01T00:00:00Z", "end_date": "2024-12-31T23:59:59Z", "credits_used": 1250.5 }