Reporting

Usage

The Usage APIs give you the usage data that shows in the usage dashboard. This is the usage that Tray compares with the allowances in your contract.

All Usage endpoints use the POST method. You send the query in the JSON body.

Key terms

  • Task: One execution of one step in a workflow run. If a step is in a loop, each iteration is one task. Tray counts tasks from all steps, also from steps that had an error. Refer to What is a task?
  • Workflow tasks: Tasks from the workflows in your workspaces.
  • End user tasks: Tasks from the workflows of your solution instances (Embedded).
  • Connectivity API tasks: Calls to Call connector. Each call is one task.
  • Tokens: The input and output tokens of the AI connectors that Tray supplies, for example Merlin Text Generation. Tokens from AI models that you connect with your own account are not included.
  • Token task equivalents: The number of tasks that Tray calculates from your tokens. The conversion rate is in your contract.
  • IDP pages processed: The number of pages that Merlin Intelligent Document Processing (IDP) processed.
  • End user (Embedded): An end user that had one or more tasks in the month. An end user of a solution instance counts if a production workflow run has tasks. A Connectivity API end user counts if a call to Call connector uses a token of that end user.

The total task usage is the sum of workflow tasks, end user tasks, Connectivity API tasks and all token task equivalents.

Usage types

Use usageType to select the usage:

usageType Usage
Tasks All tasks, including token task equivalents.
WorkflowTasks Workflow tasks.
EmbeddedTasks End user tasks.
CAPITasks Connectivity API tasks.
Tokens All tokens.
WorkflowTokens, EmbeddedTokens, CAPITokens Tokens from workflows, end user workflows or the Connectivity API.
WorkflowTokenTaskEquivalents, EmbeddedTokenTaskEquivalents, CAPITokenTaskEquivalents Token task equivalents from workflows, end user workflows or the Connectivity API.
IDPPagesProcessed All IDP pages processed.
EmbeddedIDPPagesProcessed, CAPIIDPPagesProcessed IDP pages processed from end user workflows or the Connectivity API.
EndUsers All end users.
EmbeddedEndUsers End users of solution instances.
CAPIEndUsers Connectivity API end users.
Workflows Workflows that had one or more workflow runs. Solution instance copies of workflows are not included.

Organizations and regions

Usage is for your contract, not for one organization. The response includes usage from all organizations that are on the same contract as your organization.

Each Tray region keeps its data separately. Thus, there are two versions of each endpoint:

  • The endpoints with /account give usage from all regions. Use these endpoints to compare usage with your allowance.
  • The other endpoints give usage only from the region of the base URL that you use.

For example, if you have organizations in the US and the EU, send POST https://api.tray.io/insights/v1/usage/account to get the usage of both regions.

Time period

startPeriod and endPeriod are optional. Use ISO 8601 format in UTC, for example 2026-10-01T00:00:00Z.

Tray uses only the date. Tray includes all of the start day and all of the end day.

The default time period is different for each endpoint. Refer to the endpoint descriptions.

Billing months

Tray counts usage in billing months. A billing month starts on the same day of the month as your contract. For example, if your contract starts on 15 March, each billing month starts on the 15th.

Data delay

New usage shows approximately 20 minutes after a task completes.

Permissions

Use the token of an API user with the Owner or Admin organization role. Refer to API users and tokens.

Only an organization Owner or Admin can give an API user this role. A token of an API user with a different role gets a 403 response.

Trial organizations cannot use these endpoints.

Allowance values

Allowance values are strings. A value is a number, for example "150000", or "Unlimited".

Rate limits

Tray limits the number of requests to the Usage endpoints: 300 requests each minute and 5,000 requests each hour.

Each response has headers that show the limit and the number of requests that remain, for example RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset. RateLimit-Reset is the number of seconds before the limit for the minute starts again.

If you go above a limit, the response is 429. Wait, then send the request again.

Get Usage

This endpoint is non-billable.

Gets the usage for each billing month, and your allowance. This is the chart in the usage dashboard.

This endpoint gives usage only from the region of the base URL. To get usage from all regions, use Get Account Usage.

If you do not set a time period, Tray uses your current contract period. If you set only startPeriod, the time period ends today. If you set only endPeriod, the time period starts one year before endPeriod.

Response

timeseries contains one item for each billing month:

  • startPeriod and endPeriod are the first day and the last day of the billing month.
  • value is the usage in the billing month.
  • monthlyAllowance is your allowance for each billing month. The response contains this value only for Tasks, Workflows and EndUsers.
  • allowanceBreakdown shows the parts of your task allowance. The response contains this value only for Tasks.

contractAllowance is the total allowance of the packages and add-ons that are active in the time period. If you have no usage in the time period, timeseries is empty.

Workflows

For usageType Workflows, use billableTypes to select the workflows:

  • Billable: Workflows that Tray bills.
  • NonBillable: Workflows that Tray does not bill. These are workflows with a callable trigger, an alerting trigger or no trigger, and the source workflows of solutions.
  • SandBox: Workflows in sandbox workspaces.

If you do not send billableTypes, the response includes all workflows. The response contains the allowance only if billableTypes contains Billable.

Do not use billableTypes with other usage types.

Get Usage Details

This endpoint is non-billable.

Gets a table with the details of your usage, for example the tasks of each workflow. This is the table in the usage dashboard.

This endpoint gives usage only from the region of the base URL. To get usage from all regions, use Get Account Usage Details.

If you do not set a time period, Tray uses the current calendar month. If you set only startPeriod or only endPeriod, Tray uses only that day.

Columns

The columns are different for each usageType. To get the columns, use Get Usage Columns.

usageType One row for each Usage column
Tasks, Tokens, IDPPagesProcessed, EndUsers Category, for example "Workflow Tasks" task_runs, tokens, idp_pages_processed or end_users
Workflows Workflow workflow_runs
WorkflowTasks Workflow, and sandbox or production task_runs
WorkflowTokens, WorkflowTokenTaskEquivalents Workflow and AI model tokens or token_task_equivalents
EmbeddedTasks, EmbeddedEndUsers End user task_runs
EmbeddedTokens, EmbeddedTokenTaskEquivalents, EmbeddedIDPPagesProcessed End user tokens, token_task_equivalents or idp_pages_processed
CAPITasks Connector operation connector_calls
CAPIEndUsers End user connector_calls
CAPITokens, CAPITokenTaskEquivalents, CAPIIDPPagesProcessed Connector operation tokens, token_task_equivalents or idp_pages_processed

All rows also contain organization, the name and ID of the organization.

Column values

Column Value
workflow_id, workflow_name The workflow.
workflow_runs The number of workflow runs.
workflow_type Billable, or the reason that Tray does not bill the workflow.
task_runs The number of tasks.
task_type Production or Sandbox.
workspace_name The workspace of the workflow.
end_user The name and ID of the end user.
external_user_id The external user ID that you set for the end user.
connector_title, connector_operation The connector and the operation.
connector_calls The number of calls to Call connector.
model The AI model.
category The usage category.
region US, EU, AP or AP2. Only in the /account endpoints.

Rows

Each row is a list of objects with columnName and value. All values are strings, also for numbers.

Pagination and sort order

The default page size is 100. To get the next page, send the same request with after set to pageInfo.endCursor. Do this until hasNextPage is false. When the last page is full, hasNextPage can be true. In this case, the next page is empty.

To change the sort order, set orderBy to one column and a direction (Asc or Desc). If a column is not in the table, Tray does not use it.

Get Account Usage Details

This endpoint is non-billable.

Gets a table with the details of your usage from all regions. The request and the response are the same as Get Usage Details.

For Tasks, Tokens, IDPPagesProcessed and EndUsers, the response contains one row for each region, with the region column. For other usage types, the response contains usage only from the region of the base URL.

Note: Tray gets one page from each region and sorts the rows together. If the data has more than one page, use a page size that is larger than the number of rows.

Get Usage Columns

This endpoint is non-billable.

Gets the columns of the table from Get Usage Details for a usageType. Use this endpoint to make the headers of a table in your tool.

  • name is the column code. Use this code in orderBy.
  • headerName is the text for the column header.
  • columnType tells you how to show the value. hidden is for ID columns that you do not show.

The /account version also gives the region column for Tasks, Tokens, IDPPagesProcessed and EndUsers.

Get Account Usage Columns

This endpoint is non-billable.

Gets the columns of the table from Get Usage Details for a usageType. Use this endpoint to make the headers of a table in your tool.

  • name is the column code. Use this code in orderBy.
  • headerName is the text for the column header.
  • columnType tells you how to show the value. hidden is for ID columns that you do not show.

The /account version also gives the region column for Tasks, Tokens, IDPPagesProcessed and EndUsers.

Get Usage Row Count

This endpoint is non-billable.

Gets the number of items in the usage details for the time period. Send the same usageType and time period that you send to Get Usage Details.

used is:

  • For Workflows: the number of workflows that had one or more workflow runs.
  • For EmbeddedEndUsers and CAPIEndUsers: the number of end users.
  • For all other usage types: the number of rows in the table. This value is not the usage. To get the usage, use Get Usage.

The /account version gives the total of all regions in used, and the value for each region in usUsed, euUsed, apUsed and ap2Used.

Get Account Usage Row Count

This endpoint is non-billable.

Gets the number of items in the usage details for the time period. Send the same usageType and time period that you send to Get Usage Details.

used is:

  • For Workflows: the number of workflows that had one or more workflow runs.
  • For EmbeddedEndUsers and CAPIEndUsers: the number of end users.
  • For all other usage types: the number of rows in the table. This value is not the usage. To get the usage, use Get Usage.

The /account version gives the total of all regions in used, and the value for each region in usUsed, euUsed, apUsed and ap2Used.

Get Account Usage

This endpoint is non-billable.

Gets the usage for each billing month from all regions, and your allowance. This is the chart in the usage dashboard.

The request and the response are the same as Get Usage, with these changes:

  • value is the total usage of all regions.
  • usValue, euValue, apValue and ap2Value are the usage in each region. If a region has no usage, the response does not contain the value for that region.

If one region does not respond, the request fails. Send the request again.

Was this page helpful?