> This page is for version Staging.
> For other versions, use one of these documentation indexes:
> - Prod (default): https://docs.chrt.com/prod/llms.txt
> - Staging: https://docs.chrt.com/staging/llms.txt
> - Dev: https://docs.chrt.com/dev/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.chrt.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.chrt.com/_mcp/server.

# Retrieve (via POST) driver analytics

POST https://api.staging.chrt.com/shipping/drivers/stats/v1/{driver_id}
Content-Type: application/json

Retrieves driver analytics for a time window. Daily rows are clipped to the requested UTC window; task-group rows include full in-progress mileage for task groups whose in-progress interval overlaps the requested window. | authz: allowed_org_types=[provider], min_org_role=operator | (DriverStatsReq) -> (DriverStatsRes)

Reference: https://docs.chrt.com/api-reference/api-reference/shipping/drivers/get-stats-v-1

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `driver_id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `end_timestamp` (datetime, required)
- `start_timestamp` (datetime, required)

## Response

### 200

Successful Response

- `driver_analytics_days` (list of DriverAnalyticsDay, optional)
- `driver_analytics_task_groups` (list of DriverAnalyticsTaskGroup, optional)

## Errors

### 422 Drivers Get Stats V1request Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### DriverAnalyticsDay

- `day` (string, required)
- `observed_mileage_order_in_progress_deduped` (double, required) — Observed GPS mileage from same-day driver ping segments fetched inside merged task-group in-progress intervals. Cross-interval and cross-midnight segments are dropped.
- `observed_mileage_order_not_in_progress` (double, required) — Observed GPS mileage remaining after subtracting order in-progress mileage from total on this UTC day. Includes off-clock segments and cross-interval boundary segments.
- `observed_mileage_total` (double, required) — Total observed GPS mileage from all same-day driver ping segments on this UTC day. Cross-midnight segments are dropped.
- `self_reported_hours_and_mileage` (DriverSelfReportedHoursAndMileage1, optional) — Driver self-reported hours and mileage record for this UTC calendar day, if one exists.

### DriverAnalyticsTaskGroup

- `observed_mileage_order_in_progress` (double, required) — Observed GPS mileage for this task group from tracking.task_group_by_driver_timeseries across the full task-group in-progress interval, excluding outlier points. This can include mileage outside the requested analytics window when the task group overlaps the window but starts before it or ends after it.
- `task_group` (TaskGroup1, required) — Task group assigned to the driver whose in-progress interval overlaps the requested analytics window.

### ValidationError

- `loc` (list of LocationItem, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (map from string to any, optional)
- `input` (any, optional)

### DriverSelfReportedHoursAndMileage1

- `_id` (string, required)
- `created_at_timestamp` (datetime, required)
- `created_by_user_id` (string, required) — Must be a string starting with `user_`
- `date` (string, required)
- `driver_id` (string, required)
- `org_id` (string, required) — Must be a string starting with `org_`
- `schema_version` (integer, required)
- `updated_at` (datetime, required)
- `hours_worked` (double, optional)
- `miles_driven` (double, optional)

### TaskGroup1

- `_id` (string, required)
- `created_by_org_id` (string, required) — Must be a string starting with `org_`
- `draft_started_at_timestamp` (datetime, required)
- `order_id` (string, required)
- `order_short_id` (string, required)
- `schema_version` (integer, required)
- `task_group_type` (enum, required)
  - Allowed values: `chrt_ground_provider`, `cargo_on_flight`, `onboard_courier`
- `cancelled_at_timestamp` (datetime, optional)
- `completed_at_timestamp` (datetime, optional)
- `coordinator_org_id` (string, optional) — Must be a string starting with `org_`
- `coordinator_setup_notes` (string, optional)
- `created_by_user_id` (string, optional) — Must be a string starting with `user_`
- `driver_id` (string, optional)
- `exception_at_timestamp` (datetime, optional)
- `executor_org_id` (string, optional) — Must be a string starting with `org_`
- `flight_leg_ids` (list of string, optional)
- `flight_setup_notes` (string, optional)
- `in_progress_at_timestamp` (datetime, optional)
- `messages` (list of TaskGroupMessage1, optional)
- `mileage_estimated` (double, optional)
- `off_chrt_executor_org_data_id` (string, optional)
- `off_chrt_shipper_org_data_id` (string, optional)
- `order_off_chrt_reference_id` (string, optional) — Must be a URL-safe string of 1-64 characters. Allowed characters: A-Z, a-z, 0-9, '.', '_', '~', '-' (RFC 3986 unreserved).
- `shipper_org_id` (string, optional) — Must be a string starting with `org_`
- `skipped_at_timestamp` (datetime, optional)
- `staged_at_timestamp` (datetime, optional)
- `status` (enum, optional)
  - Allowed values: `draft`, `staged`, `in_progress`, `completed`, `skipped`, `cancelled`, `exception`
- `task_group_s3_object_metadata_ids` (list of string, optional)
- `task_ids` (list of string, optional)
- `vehicle_type` (enum, optional)
  - Allowed values: `sedan`, `suv`, `cargo_van`, `box_truck`, `flatbed`, `semi_truck`, `airplane`
- `wait_time_total_minutes` (double, optional)

### LocationItem

- string
- integer

### TaskGroupMessage1

- `message` (string, required)
- `org_id` (string, required) — Must be a string starting with `org_`
- `timestamp` (datetime, required)
- `user_id` (string, required) — Must be a string starting with `user_`

## Examples

**Request**

```json
{
  "end_timestamp": "2024-01-15T09:30:00Z",
  "start_timestamp": "2024-01-15T09:30:00Z"
}
```

**Response**

```json
{
  "driver_analytics_days": [
    {
      "day": "day",
      "observed_mileage_order_in_progress_deduped": 1.1,
      "observed_mileage_order_not_in_progress": 1.1,
      "observed_mileage_total": 1.1,
      "self_reported_hours_and_mileage": {
        "_id": "_id",
        "created_at_timestamp": "2024-01-15T09:30:00Z",
        "created_by_user_id": "created_by_user_id",
        "date": "date",
        "driver_id": "driver_id",
        "org_id": "org_id",
        "schema_version": 1,
        "updated_at": "2024-01-15T09:30:00Z"
      }
    }
  ],
  "driver_analytics_task_groups": [
    {
      "observed_mileage_order_in_progress": 1.1,
      "task_group": {
        "_id": "_id",
        "created_by_org_id": "created_by_org_id",
        "draft_started_at_timestamp": "2024-01-15T09:30:00Z",
        "order_id": "order_id",
        "order_short_id": "order_short_id",
        "schema_version": 1,
        "task_group_type": "chrt_ground_provider"
      }
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id"

payload = {
    "end_timestamp": "2024-01-15T09:30:00Z",
    "start_timestamp": "2024-01-15T09:30:00Z"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"end_timestamp":"2024-01-15T09:30:00Z","start_timestamp":"2024-01-15T09:30:00Z"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id"

	payload := strings.NewReader("{\n  \"end_timestamp\": \"2024-01-15T09:30:00Z\",\n  \"start_timestamp\": \"2024-01-15T09:30:00Z\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"end_timestamp\": \"2024-01-15T09:30:00Z\",\n  \"start_timestamp\": \"2024-01-15T09:30:00Z\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"end_timestamp\": \"2024-01-15T09:30:00Z\",\n  \"start_timestamp\": \"2024-01-15T09:30:00Z\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id', [
  'body' => '{
  "end_timestamp": "2024-01-15T09:30:00Z",
  "start_timestamp": "2024-01-15T09:30:00Z"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"end_timestamp\": \"2024-01-15T09:30:00Z\",\n  \"start_timestamp\": \"2024-01-15T09:30:00Z\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "end_timestamp": "2024-01-15T09:30:00Z",
  "start_timestamp": "2024-01-15T09:30:00Z"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staging.chrt.com/shipping/drivers/stats/v1/driver_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```