# Usage ## ListEnvironmentUsageRecords `usage.list_environment_runtime_records(UsageListEnvironmentRuntimeRecordsParams**kwargs) -> SyncRecordsPage[EnvironmentUsageRecord]` **post** `/gitpod.v1.UsageService/ListEnvironmentUsageRecords` Lists completed environment runtime records within a specified date range. Returns a list of environment runtime records that were completed within the specified date range. Records of currently running environments are not included. Use this method to: - View environment runtime records - Filter by project - Create custom usage reports ### Example ```yaml filter: projectId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" dateRange: startTime: "2024-01-01T00:00:00Z" endTime: "2024-01-02T00:00:00Z" pagination: pageSize: 100 ``` ### Parameters - `token: Optional[str]` - `page_size: Optional[int]` - `filter: Optional[Filter]` Filter options. - `date_range: FilterDateRange` Date range to query runtime records within. - `end_time: Union[str, datetime]` End time of the date range (exclusive). - `start_time: Union[str, datetime]` Start time of the date range (inclusive). - `project_id: Optional[str]` Optional project ID to filter runtime records by. - `pagination: Optional[Pagination]` Pagination options. - `token: Optional[str]` Token for the next set of results that was returned as next_token of a PaginationResponse - `page_size: Optional[int]` Page size is the maximum number of results to retrieve per page. Defaults to 25. Maximum 100. ### Returns - `class EnvironmentUsageRecord: …` EnvironmentUsageRecord represents a record of an environment from start to stop. - `id: Optional[str]` Environment usage record ID. - `created_at: Optional[datetime]` Time when the environment was created. - `environment_class_id: Optional[str]` Environment class ID associated with the record. - `environment_id: Optional[str]` Environment ID associated with the record. - `project_id: Optional[str]` Project ID associated with the environment (if available). - `runner_id: Optional[str]` Runner ID associated with the environment. - `stopped_at: Optional[datetime]` Time when the environment was stopped. - `user_id: Optional[str]` User ID is the ID of the user who created the environment associated with the record. ### Example ```python import os from datetime import datetime from gitpod import Gitpod client = Gitpod( bearer_token=os.environ.get("GITPOD_API_KEY"), # This is the default and can be omitted ) page = client.usage.list_environment_runtime_records( filter={ "date_range": { "end_time": datetime.fromisoformat("2024-01-02T00:00:00"), "start_time": datetime.fromisoformat("2024-01-01T00:00:00"), }, "project_id": "d2c94c27-3b76-4a42-b88c-95a85e392c68", }, pagination={ "page_size": 100 }, ) page = page.records[0] print(page.id) ``` #### Response ```json { "pagination": { "nextToken": "nextToken" }, "records": [ { "id": "id", "createdAt": "2019-12-27T18:11:19.117Z", "environmentClassId": "environmentClassId", "environmentId": "environmentId", "projectId": "projectId", "runnerId": "runnerId", "stoppedAt": "2019-12-27T18:11:19.117Z", "userId": "userId" } ] } ``` ## Domain Types ### Environment Usage Record - `class EnvironmentUsageRecord: …` EnvironmentUsageRecord represents a record of an environment from start to stop. - `id: Optional[str]` Environment usage record ID. - `created_at: Optional[datetime]` Time when the environment was created. - `environment_class_id: Optional[str]` Environment class ID associated with the record. - `environment_id: Optional[str]` Environment ID associated with the record. - `project_id: Optional[str]` Project ID associated with the environment (if available). - `runner_id: Optional[str]` Runner ID associated with the environment. - `stopped_at: Optional[datetime]` Time when the environment was stopped. - `user_id: Optional[str]` User ID is the ID of the user who created the environment associated with the record.