Skip to content
Kapten
Esc
↑↓navigate↵open⌘Jpreview

Get environment usage

How long each environment of the token’s organization was active in the period [since, until), from its creation to its deletion. Usage is counted in hourly UTC windows: both bounds are truncated to the hour, and a period spans at most 93 days. Only hours before closed_through are counted, and an hour closes about five minutes after it ends. Environments that were not active in the period are left out. Requires organization_update on the organization. The billable minutes are the ones the subscription is billed for.

GET/usage/environments
Authorization
AuthorizationBearer token (JWT) · headerrequired

JWT token passed in the Authorization header using the Bearer <token> format.

Query parameters
sincestring<date-time>required

Start of the period, truncated to the hour.

untilstring<date-time>required

End of the period (exclusive), truncated to the hour.

Responses
200

The usage of the period.

sincestring<date-time>required
untilstring<date-time>required
closed_throughstring<date-time>required

End of the last closed hour; later hours are not counted yet.

environmentsenvironment_usage[]required
Show properties
Array of environment_usage
environment_idstring<uuid>required
project_idstring<uuid>required
active_secondsnumber<double>required

Active time in the period, in seconds, to the millisecond.

billable_minutesinteger<int64>required

Minutes billed for the period. In each UTC hour, the environment counts the minutes it started, so ten seconds bill one minute.

daysenvironment_usage_day[]required

Billable minutes per UTC day, for the days of the period with usage, in order. They add up to the environments' billable minutes.

Show properties
Array of environment_usage_day
daystring<date-time>required

Start of the UTC day.

billable_minutesinteger<int64>required

Minutes billed for the day, over every environment of the organization.

default

Error

codeinteger<int32>required
messagestringrequired
reasonstring

Optional stable machine-readable reason for programmatic error handling

Request
curl -X GET 'https://api.kapten.io/usage/environments?since=2019-08-24T14%3A15%3A22Z&until=2019-08-24T14%3A15%3A22Z' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json'
Response
{
  "since": "2019-08-24T14:15:22Z",
  "until": "2019-08-24T14:15:22Z",
  "closed_through": "2019-08-24T14:15:22Z",
  "environments": [
    {
      "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4",
      "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
      "active_seconds": 0.1,
      "billable_minutes": 0
    }
  ],
  "days": [
    {
      "day": "2019-08-24T14:15:22Z",
      "billable_minutes": 0
    }
  ]
}

Was this page helpful?