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

# Get project analytics

GET https://alephant.io/api/v1/projects/{id}/analytics

Return summary usage and top spenders across assigned members and agents for an Enterprise workspace. All workspace members may read; PATs require the read scope.

Reference: https://developers.alephant.io/api-reference/saa-s-api/projects/get-project-analytics

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: saas-openapi
  version: 1.0.0
paths:
  /api/v1/projects/{id}/analytics:
    get:
      operationId: getProjectAnalytics
      summary: Get project analytics
      description: >-
        Return summary usage and top spenders across assigned members and agents
        for an Enterprise workspace. All workspace members may read; PATs
        require the read scope.
      tags:
        - projects
      parameters:
        - name: id
          in: path
          description: Project UUID
          required: true
          schema:
            type: string
            format: uuid
        - name: period
          in: query
          description: Analytics period
          required: false
          schema:
            $ref: '#/components/schemas/ApiV1ProjectsIdAnalyticsGetParametersPeriod'
            default: 7d
        - name: Authorization
          in: header
          description: Bearer {access_token}
          required: true
          schema:
            type: string
        - name: X-Workspace-Id
          in: header
          description: Workspace UUID
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: 'data: project analytics'
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/internal_api_handlers_projects.ProjectAnalyticsDataEnvelope
        '400':
          description: X-Workspace-Id required
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '401':
          description: AUTH_TOKEN_EXPIRED
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '403':
          description: feature_unavailable or FORBIDDEN
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '404':
          description: project_not_found
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '422':
          description: validation_error (invalid project id or period)
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '503':
          description: collector_unavailable
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
servers:
  - url: https://alephant.io
    description: Production
  - url: https://dev.alephant.io
    description: Development
components:
  schemas:
    ApiV1ProjectsIdAnalyticsGetParametersPeriod:
      type: string
      enum:
        - 1d
        - 7d
        - 30d
      default: 7d
      title: ApiV1ProjectsIdAnalyticsGetParametersPeriod
    GithubComAlephantBackendSaasServiceInternalServiceProjectPeriodKey:
      type: string
      enum:
        - 1d
        - 7d
        - 30d
      title: GithubComAlephantBackendSaasServiceInternalServiceProjectPeriodKey
    github_com_alephant_backend-saas-service_internal_service.ProjectPeriod:
      type: object
      properties:
        end:
          type: string
          format: date-time
        key:
          $ref: >-
            #/components/schemas/GithubComAlephantBackendSaasServiceInternalServiceProjectPeriodKey
        start:
          type: string
          format: date-time
        timezone:
          type: string
      title: github_com_alephant_backend-saas-service_internal_service.ProjectPeriod
    github_com_alephant_backend-saas-service_internal_service.ProjectAnalyticsSummary:
      type: object
      properties:
        activeAgents:
          type: integer
          format: int64
        activeMembers:
          type: integer
          format: int64
        cost:
          type: number
          format: double
        requests:
          type: integer
          format: int64
        tokens:
          type: integer
          format: int64
      title: >-
        github_com_alephant_backend-saas-service_internal_service.ProjectAnalyticsSummary
    GithubComAlephantBackendSaasServiceInternalServiceProjectTopSpenderEntityType:
      type: string
      enum:
        - member
        - agent
      title: >-
        GithubComAlephantBackendSaasServiceInternalServiceProjectTopSpenderEntityType
    github_com_alephant_backend-saas-service_internal_service.ProjectTopSpender:
      type: object
      properties:
        cost:
          type: number
          format: double
        deleted:
          type: boolean
        entityId:
          type: string
          format: uuid
        entityType:
          $ref: >-
            #/components/schemas/GithubComAlephantBackendSaasServiceInternalServiceProjectTopSpenderEntityType
        name:
          type: string
        requests:
          type: integer
          format: int64
        tokens:
          type: integer
          format: int64
      title: >-
        github_com_alephant_backend-saas-service_internal_service.ProjectTopSpender
    github_com_alephant_backend-saas-service_internal_service.ProjectAnalytics:
      type: object
      properties:
        period:
          $ref: >-
            #/components/schemas/github_com_alephant_backend-saas-service_internal_service.ProjectPeriod
        projectId:
          type: string
          format: uuid
        summary:
          $ref: >-
            #/components/schemas/github_com_alephant_backend-saas-service_internal_service.ProjectAnalyticsSummary
        topSpenders:
          type: array
          items:
            $ref: >-
              #/components/schemas/github_com_alephant_backend-saas-service_internal_service.ProjectTopSpender
      title: >-
        github_com_alephant_backend-saas-service_internal_service.ProjectAnalytics
    internal_api_handlers_projects.ProjectAnalyticsDataEnvelope:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/github_com_alephant_backend-saas-service_internal_service.ProjectAnalytics
      title: internal_api_handlers_projects.ProjectAnalyticsDataEnvelope
    github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      title: github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody

```

## Examples



**Response**

```json
{
  "data": {
    "period": {
      "end": "2024-01-15T09:30:00Z",
      "key": "1d",
      "start": "2024-01-15T09:30:00Z",
      "timezone": "string"
    },
    "projectId": "string",
    "summary": {
      "activeAgents": 1,
      "activeMembers": 1,
      "cost": 1.1,
      "requests": 1,
      "tokens": 1
    },
    "topSpenders": [
      {
        "cost": 1.1,
        "deleted": true,
        "entityId": "string",
        "entityType": "member",
        "name": "string",
        "requests": 1,
        "tokens": 1
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://alephant.io/api/v1/projects/id/analytics"

headers = {
    "Authorization": "Authorization",
    "X-Workspace-Id": "X-Workspace-Id"
}

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

print(response.json())
```

```javascript
const url = 'https://alephant.io/api/v1/projects/id/analytics';
const options = {
  method: 'GET',
  headers: {Authorization: 'Authorization', 'X-Workspace-Id': 'X-Workspace-Id'}
};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://alephant.io/api/v1/projects/id/analytics"

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

	req.Header.Add("Authorization", "Authorization")
	req.Header.Add("X-Workspace-Id", "X-Workspace-Id")

	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://alephant.io/api/v1/projects/id/analytics")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Authorization'
request["X-Workspace-Id"] = 'X-Workspace-Id'

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://alephant.io/api/v1/projects/id/analytics")
  .header("Authorization", "Authorization")
  .header("X-Workspace-Id", "X-Workspace-Id")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://alephant.io/api/v1/projects/id/analytics', [
  'headers' => [
    'Authorization' => 'Authorization',
    'X-Workspace-Id' => 'X-Workspace-Id',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://alephant.io/api/v1/projects/id/analytics");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Authorization");
request.AddHeader("X-Workspace-Id", "X-Workspace-Id");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Authorization",
  "X-Workspace-Id": "X-Workspace-Id"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://alephant.io/api/v1/projects/id/analytics")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```