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

# Usage Activity

GET https://api.onepin.ai/api/v1/usage/activity

Return the workspace activity feed as a cursor-paginated event list.

Each item represents a discrete workspace event (workflow run, voice generated,
template applied, member invited, API key created, settings changed). Events are
ordered newest-first within the requested rolling window.

Filtering:
- `type` narrows to a single action kind (e.g. `workflow_run`).
- `user_id` restricts to events triggered by a specific workspace member;
  returns 404 if the user is not a member of this workspace.
- Both filters can be combined.

Pagination: pass the `cursor` value from a previous response to retrieve the
next page. An absent or null `cursor` in the response means no further pages
exist. Page size is controlled by `limit` (1–100, default 20).

Date boundaries are computed in the supplied `timezone` (IANA). Defaults to UTC.

Dual-auth: Bearer JWT or API key (scope `workspace:read`).

Reference: https://onepin.ai/docs/reference/api-reference/usage/activity-api-v-1-usage-activity-get

## Authentication

- `Authorization` header (bearer token, required) — Clerk JWT token
- `Authorization` header (bearer token, required) — Onepin live API key (`op_live_...`). Test and public keys are reserved in Phase 1.

## Servers

- `https://api.onepin.ai` (prod, default)
- `https://dev-api.onepin.ai` (dev)

## Request

### Query parameters

- `range` (enum, optional, default: 30d) — Rolling local calendar-day range.
  - Allowed values: `30d`, `60d`, `90d`
- `type` (enum, optional, nullable) — Filter by usage activity type.
  - Allowed values: `workflow_run`, `voice_generated`, `template_applied`, `member_invited`, `api_key_created`, `settings_changed`
- `user_id` (string, optional, nullable) — Filter by actor user id.
- `limit` (integer, optional, default: 20)
- `cursor` (string, optional, nullable) — Opaque pagination cursor.
- `timezone` (string, optional, default: UTC) — IANA timezone for local day bucketing.

### Headers

- `X-Workspace-Id` (string, optional, nullable)

## Response

### 200

Successful Response

- `data` (list of UsageActivityOut, required)
- `meta` (Meta, required)
- `pagination` (PaginationMeta, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### UsageActivityOut

- `id` (string, required) — Unique activity event identifier.
- `timestamp` (datetime, required) — UTC timestamp when the event occurred.
- `action` (enum, required) — Event type (e.g. `workflow_run`, `voice_generated`, `member_invited`).
  - Allowed values: `workflow_run`, `voice_generated`, `template_applied`, `member_invited`, `api_key_created`, `settings_changed`
- `kind` (string, required) — Sub-kind providing additional detail about the action.
- `resource` (UsageActivityResourceOut, required) — The primary resource involved in this event.
- `user` (UsageActivityUserOut, optional, nullable) — Actor who triggered the event, or `null` for system-generated events.
- `metadata` (map from string to any, optional) — Additional structured context for the event. Keys vary by action type.
- `ip` (string, optional, nullable) — IP address of the actor at the time of the event, if recorded.

### Meta

- `request_id` (string, required)
- `timestamp` (datetime, required)

### PaginationMeta

- `limit` (integer, required)
- `next` (string, optional, nullable)
- `prev` (string, optional, nullable)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### UsageActivityResourceOut

- `type` (string, required) — Resource type involved in the event (e.g. `workflow`, `template`, `voice`).
- `id` (string, optional, nullable) — ID of the affected resource, if applicable.
- `name` (string, optional, nullable) — Display name of the affected resource at the time of the event.

### UsageActivityUserOut

- `id` (string, required) — User ID of the event actor.
- `name` (string, required) — Display name of the event actor.

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "data": [
    {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "timestamp": "2024-04-20T14:22:00Z",
      "action": "workflow_run",
      "kind": "scheduled_run",
      "resource": {
        "type": "workflow",
        "id": "wf_1234567890abcdef",
        "name": "Monthly Report Generation"
      },
      "user": {
        "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
        "name": "Alice Johnson"
      },
      "metadata": {
        "duration_seconds": 125,
        "status": "success"
      },
      "ip": "203.0.113.42"
    }
  ],
  "meta": {
    "request_id": "req_7a8b9c0d1e2f3g4h5i6j7k8l",
    "timestamp": "2024-04-20T14:22:01Z"
  },
  "pagination": {
    "limit": 1,
    "next": "cursor_eyJpZCI6IjNmYTg1ZjY0NTcxNzQ1NjJiM2ZjMmM5NjNmNjZhZmE2IiwidGltZXN0YW1wIjoiMjAyNC0wNC0yMFQxNDoyMjowMFoifQ==",
    "prev": null
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.onepin.ai/api/v1/usage/activity"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.onepin.ai/api/v1/usage/activity';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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.onepin.ai/api/v1/usage/activity"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", 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.onepin.ai/api/v1/usage/activity")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.get("https://api.onepin.ai/api/v1/usage/activity")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.onepin.ai/api/v1/usage/activity', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.onepin.ai/api/v1/usage/activity");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/usage/activity")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```