> For the complete documentation index, see [llms.txt](https://docs.we360.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.we360.ai/deployment-and-it-ops/integrations-and-api-access/integrations/oauth-for-direct-api-access/derived-punches-api.md).

# Derived Punches API

Retrieve derived attendance punches for stealth-mode users and groups.

Use the Derived Punches API to retrieve calculated punch records for a date.

## Overview

* Base URL: `https://api.in.we360.ai`
* Path: `/query/external/stealth/derived_punches`
* Method: `POST`
* Response type: `application/json`

## Authentication

Send this header with every request:

* `Authorization: Bearer ${access_token}`

Get the token from [OAuth for Direct API Access](https://docs.we360.ai/deployment-and-it-ops/integrations-and-api-access/integrations/oauth-for-direct-api-access.md).

{% hint style="warning" %}
Do not store access tokens in source code or documentation. Use a secret manager or environment variable.
{% endhint %}

## Request body

```json
{
  "date": "2026-08-20",
  "buffer_seconds": 30,
  "treat_idle_as_offline": false,
  "idle_buffer_seconds": 300,
  "user_id": "",
  "group_id": "",
  "page": 1,
  "limit": 100
}
```

### Parameters

| Parameter               | Required | Type    | Default | Range        | Description                                                                                                     |
| ----------------------- | -------- | ------- | ------- | ------------ | --------------------------------------------------------------------------------------------------------------- |
| `date`                  | Yes      | String  | —       | `YYYY-MM-DD` | Date to retrieve.                                                                                               |
| `buffer_seconds`        | No       | Integer | `30`    | `0`–`3600`   | Maximum true wall-clock offline gap within one session.                                                         |
| `treat_idle_as_offline` | No       | Boolean | `false` | —            | When `true`, idle time can also break sessions.                                                                 |
| `idle_buffer_seconds`   | No       | Integer | `300`   | `0`–`86400`  | Maximum idle-since-last-active stretch within one session. Applies only when `treat_idle_as_offline` is `true`. |
| `user_id`               | No       | String  | —       | —            | Comma-separated user UUIDs. Leave empty for all users.                                                          |
| `group_id`              | No       | String  | —       | —            | Comma-separated group UUIDs. Leave empty for all groups.                                                        |
| `page`                  | No       | Integer | `1`     | —            | Page number.                                                                                                    |
| `limit`                 | No       | Integer | `100`   | `1`–`1000`   | Records per page.                                                                                               |

With the default `treat_idle_as_offline: false`, sessions break only on true offline gaps. Idle time remains within each session.

When `treat_idle_as_offline` is `true`:

* A session breaks when the offline gap exceeds `buffer_seconds`.
* A session also breaks when the gap since the last active moment exceeds `idle_buffer_seconds`.
* Each `punch_out` becomes the last active moment. Trailing idle time is excluded.
* The response omits sessions without active time.

This setting creates more, shorter punches that reflect active work.

{% hint style="warning" %}

### Accuracy of `idle_buffer_seconds`

Idle time is recorded as a per-snapshot aggregate, not as timestamped intervals. Each `STANDARD` event covers a window of a few minutes. It reports one `active_time` and `idle_time` total for that window.

The service assumes active time occurs first and idle time trails the window. Split points and `punch_out` timestamps are accurate only within one snapshot window. They do not identify the exact second that idle time starts or ends.

The service evaluates `idle_buffer_seconds` at snapshot-window granularity. Set it comfortably above the agent snapshot window for stable results. Values at or below the window size can over-fragment sessions.

`active_seconds` remains exact. Only punch boundaries and session segmentation are approximate.
{% endhint %}

## cURL example

```bash
curl -s "https://api.in.we360.ai/query/external/stealth/derived_punches" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${access_token}" \
  --data-raw '{
    "date": "2026-08-20",
    "buffer_seconds": 30,
    "treat_idle_as_offline": false,
    "idle_buffer_seconds": 300,
    "user_id": "",
    "group_id": "",
    "page": 1,
    "limit": 100
  }' | jq
```

## Response format

```json
{
  "data": [
    {
      "identity_id": "fd560efb-98d5-43e1-83f1-19b8ea94d801",
      "employee_id": null,
      "email": "1fe7ef2362b154a6228edbda57c2bbd5@tfez-poeh-fyon.we360.local",
      "date": "2026-08-20",
      "punches": [
        {
          "punch_in": "2026-08-20T00:01:44",
          "punch_out": "2026-08-20T00:46:45",
          "span_seconds": 2701,
          "active_seconds": 2532,
          "idle_seconds": 168,
          "event_count": 9
        },
        {
          "punch_in": "2026-08-20T00:51:45",
          "punch_out": "2026-08-20T04:10:08",
          "span_seconds": 11903,
          "active_seconds": 3857,
          "idle_seconds": 8039,
          "event_count": 40
        },
        {
          "punch_in": "2026-08-20T20:33:14",
          "punch_out": "2026-08-20T23:18:21",
          "span_seconds": 9907,
          "active_seconds": 6016,
          "idle_seconds": 3883,
          "event_count": 33
        },
        {
          "punch_in": "2026-08-20T23:23:21",
          "punch_out": "2026-08-20T23:59:59",
          "span_seconds": 2198,
          "active_seconds": 190,
          "idle_seconds": 2007,
          "event_count": 8
        }
      ],
      "punch_count": 4,
      "total_active_seconds": 12595,
      "total_span_seconds": 26709,
      "first_punch": {
        "punch_in_at": "2026-08-20T00:01:29",
        "ip": "245.94.60.56",
        "location_id": "00000000-0000-0000-0000-000000000001",
        "location_name": null,
        "location_label": null,
        "country_code": null,
        "country_name": null,
        "latitude": null,
        "longitude": null
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 100,
    "total_records": 1,
    "total_pages": 1,
    "has_next": false,
    "has_previous": false
  },
  "meta": {
    "date": "2026-08-20",
    "buffer_seconds": 30,
    "treat_idle_as_offline": false,
    "idle_buffer_seconds": 300
  }
}
```

## Request examples

Use this request for offline-gap-only sessions:

```json
{
  "date": "2026-09-10",
  "buffer_seconds": 30,
  "user_id": "<identity-uuid>"
}
```

Use this request to treat idle time as offline:

```json
{
  "date": "2026-09-10",
  "buffer_seconds": 30,
  "treat_idle_as_offline": true,
  "idle_buffer_seconds": 300,
  "user_id": "<identity-uuid>"
}
```

## Request guidance

* Provide comma-separated UUIDs in `user_id` or `group_id` to narrow results.
* Increase `page` to retrieve subsequent results.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.we360.ai/deployment-and-it-ops/integrations-and-api-access/integrations/oauth-for-direct-api-access/derived-punches-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
