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

# Query Usage Events

POST https://api.meshapi.ai/v1/usage/events
Content-Type: application/json

Paginated per-request event history for the authenticated caller.

Authenticate with an rsk_ API key. Results are scoped to that single key — any org_id / member filters in the body are ignored. API-key reads are computed fresh.

Reference: https://developers.meshapi.ai/api-reference/mesh-api/usage/query-usage-events

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/usage/events:
    post:
      operationId: query-usage-events
      summary: Query Usage Events
      description: >-
        Paginated per-request event history for the authenticated caller.


        Authenticate with an rsk_ API key. Results are scoped to that single key
        — any org_id / member filters in the body are ignored. API-key reads are
        computed fresh.
      tags:
        - usage
      parameters:
        - name: refresh
          in: query
          required: false
          schema:
            type: boolean
            default: false
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageEventsPage'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UsageFilter'
servers:
  - url: https://api.meshapi.ai
    description: Production Server
components:
  schemas:
    UsageFilter:
      type: object
      properties:
        since:
          type:
            - string
            - 'null'
        until:
          type:
            - string
            - 'null'
        model:
          type:
            - array
            - 'null'
          items:
            type: string
        status:
          type:
            - array
            - 'null'
          items:
            type: string
        key_id:
          type:
            - array
            - 'null'
          items:
            type: string
        org_id:
          type: string
        team_id:
          type:
            - string
            - 'null'
        member_user_id:
          type:
            - string
            - 'null'
        end_user_id:
          type:
            - string
            - 'null'
        limit:
          type:
            - integer
            - 'null'
          default: 50
        offset:
          type:
            - integer
            - 'null'
          default: 0
      required:
        - org_id
      title: UsageFilter
    UsageEventOut:
      type: object
      properties:
        id:
          type: string
        key_id:
          type: string
        key_label:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
        end_user_id:
          type:
            - string
            - 'null'
        request_id:
          type: string
        model:
          type: string
        model_name:
          type: string
        model_provider:
          type:
            - string
            - 'null'
        stream:
          type: boolean
        prompt_tokens:
          type:
            - integer
            - 'null'
        completion_tokens:
          type:
            - integer
            - 'null'
        total_tokens:
          type:
            - integer
            - 'null'
        cost_usd:
          type:
            - string
            - 'null'
        latency_ms:
          type:
            - integer
            - 'null'
        tokens_per_second:
          type:
            - number
            - 'null'
          format: double
        status:
          type: string
        error_code:
          type:
            - string
            - 'null'
        created_at:
          type: string
        images_generated:
          type:
            - integer
            - 'null'
        model_type:
          type:
            - string
            - 'null'
        is_byok:
          type:
            - boolean
            - 'null'
        byok_key_id:
          type:
            - string
            - 'null'
        byok_key_label:
          type:
            - string
            - 'null'
        provider:
          type:
            - string
            - 'null'
        fallback_triggered:
          type:
            - boolean
            - 'null'
        platform_fee_usd:
          type:
            - string
            - 'null'
        image_tokens:
          type:
            - integer
            - 'null'
        member_name:
          type:
            - string
            - 'null'
        member_email:
          type:
            - string
            - 'null'
        attempt_no:
          type:
            - integer
            - 'null'
        is_retry_attempt:
          type:
            - boolean
            - 'null'
      required:
        - id
        - key_id
        - key_label
        - request_id
        - model
        - model_name
        - model_provider
        - stream
        - prompt_tokens
        - completion_tokens
        - total_tokens
        - cost_usd
        - latency_ms
        - tokens_per_second
        - status
        - error_code
        - created_at
      title: UsageEventOut
    UsageEventsPage:
      type: object
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/UsageEventOut'
        total:
          type: integer
        limit:
          type: integer
        offset:
          type: integer
      required:
        - events
        - total
        - limit
        - offset
      title: UsageEventsPage
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## Examples

### Example response



**Request**

```json
undefined
```

**Response**

```json
{
  "events": [
    {
      "id": "0190a1c0-0000-7000-8000-00000000e1e1",
      "key_id": "0190a1b2-0000-7000-8000-0000000000aa",
      "key_label": "prod-key",
      "request_id": "req_01ARZ3NDEKTSV4RRFFQ69G5FAV",
      "model": "openai/gpt-4o-mini",
      "model_name": "gpt-4o-mini",
      "model_provider": "openai",
      "stream": false,
      "prompt_tokens": 128,
      "completion_tokens": 64,
      "total_tokens": 192,
      "cost_usd": "0.0000480",
      "latency_ms": 812,
      "tokens_per_second": 78.82,
      "status": "success",
      "error_code": null,
      "created_at": "2026-07-14T10:15:30+00:00",
      "user_id": "user_01JZ0Q9WZ7ZK3M9YF6R8D2C4B1",
      "end_user_id": "customer-42",
      "model_type": "text",
      "is_byok": false,
      "provider": "openai",
      "fallback_triggered": false,
      "platform_fee_usd": "0.0000024",
      "attempt_no": 1,
      "is_retry_attempt": false,
      "routing_fallback": false
    }
  ],
  "total": 1284,
  "limit": 50,
  "offset": 0
}
```

**SDK Code**

```python Example response
import requests

url = "https://api.meshapi.ai/v1/usage/events"

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

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

print(response.json())
```

```javascript Example response
const url = 'https://api.meshapi.ai/v1/usage/events';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go Example response
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/usage/events"

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

	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 Example response
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/usage/events")

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'

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

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

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/usage/events")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/usage/events', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Example response
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/usage/events");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Example response
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/usage/events")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Example request



**Request**

```json
{
  "org_id": "0190a1b2-3c4d-7e8f-9012-3456789abcde",
  "since": "2026-07-01",
  "model": [
    "openai/gpt-4o-mini"
  ],
  "status": [
    "success"
  ],
  "limit": 20,
  "offset": 0
}
```

**Response**

```json
{
  "events": [
    {
      "id": "0190a1c0-0000-7000-8000-00000000e1e1",
      "key_id": "0190a1b2-0000-7000-8000-0000000000aa",
      "key_label": "prod-key",
      "request_id": "req_01ARZ3NDEKTSV4RRFFQ69G5FAV",
      "model": "openai/gpt-4o-mini",
      "model_name": "gpt-4o-mini",
      "model_provider": "openai",
      "stream": false,
      "prompt_tokens": 128,
      "completion_tokens": 64,
      "total_tokens": 192,
      "cost_usd": "0.0000480",
      "latency_ms": 812,
      "tokens_per_second": 78.82,
      "status": "success",
      "error_code": null,
      "created_at": "2026-07-14T10:15:30+00:00",
      "user_id": "user_01JZ0Q9WZ7ZK3M9YF6R8D2C4B1",
      "end_user_id": "customer-42",
      "model_type": "text",
      "is_byok": false,
      "provider": "openai",
      "fallback_triggered": false,
      "platform_fee_usd": "0.0000024",
      "attempt_no": 1,
      "is_retry_attempt": false,
      "routing_fallback": false
    }
  ],
  "total": 1284,
  "limit": 50,
  "offset": 0
}
```

**SDK Code**

```python Example request
import requests

url = "https://api.meshapi.ai/v1/usage/events"

payload = {
    "org_id": "0190a1b2-3c4d-7e8f-9012-3456789abcde",
    "since": "2026-07-01",
    "model": ["openai/gpt-4o-mini"],
    "status": ["success"],
    "limit": 20,
    "offset": 0
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Example request
const url = 'https://api.meshapi.ai/v1/usage/events';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"org_id":"0190a1b2-3c4d-7e8f-9012-3456789abcde","since":"2026-07-01","model":["openai/gpt-4o-mini"],"status":["success"],"limit":20,"offset":0}'
};

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

```go Example request
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/usage/events"

	payload := strings.NewReader("{\n  \"org_id\": \"0190a1b2-3c4d-7e8f-9012-3456789abcde\",\n  \"since\": \"2026-07-01\",\n  \"model\": [\n    \"openai/gpt-4o-mini\"\n  ],\n  \"status\": [\n    \"success\"\n  ],\n  \"limit\": 20,\n  \"offset\": 0\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 Example request
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/usage/events")

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  \"org_id\": \"0190a1b2-3c4d-7e8f-9012-3456789abcde\",\n  \"since\": \"2026-07-01\",\n  \"model\": [\n    \"openai/gpt-4o-mini\"\n  ],\n  \"status\": [\n    \"success\"\n  ],\n  \"limit\": 20,\n  \"offset\": 0\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/usage/events")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"org_id\": \"0190a1b2-3c4d-7e8f-9012-3456789abcde\",\n  \"since\": \"2026-07-01\",\n  \"model\": [\n    \"openai/gpt-4o-mini\"\n  ],\n  \"status\": [\n    \"success\"\n  ],\n  \"limit\": 20,\n  \"offset\": 0\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/usage/events', [
  'body' => '{
  "org_id": "0190a1b2-3c4d-7e8f-9012-3456789abcde",
  "since": "2026-07-01",
  "model": [
    "openai/gpt-4o-mini"
  ],
  "status": [
    "success"
  ],
  "limit": 20,
  "offset": 0
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Example request
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/usage/events");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"org_id\": \"0190a1b2-3c4d-7e8f-9012-3456789abcde\",\n  \"since\": \"2026-07-01\",\n  \"model\": [\n    \"openai/gpt-4o-mini\"\n  ],\n  \"status\": [\n    \"success\"\n  ],\n  \"limit\": 20,\n  \"offset\": 0\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "org_id": "0190a1b2-3c4d-7e8f-9012-3456789abcde",
  "since": "2026-07-01",
  "model": ["openai/gpt-4o-mini"],
  "status": ["success"],
  "limit": 20,
  "offset": 0
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/usage/events")! 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()
```