> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage metrics

> Conversations and unique sessions of each subcompany over a time range

Returns the conversations and unique sessions of each subcompany over a range that ends at request time.

## Parameters

| Parameter | Values | Description |
| - | - | - |
| `range` | `last_24h`, `last_7d`, `last_30d`, `last_90d` | Required. Time window ending now. |
| `companyId` | integer | Optional. Restricts the response to one subcompany. Responds `404` when it is not yours. |
| `page`, `limit` | integer | Pagination, same as the other listings. |

## Subcompany fields

| Field | Type | Description |
| - | - | - |
| `id` | string | Jelou company id. |
| `externalId` | string \| null | Identifier of the company in your systems, when set. |
| `conversations` | integer \| null | Conversations in the range. |
| `uniqueSessions` | integer \| null | Unique sessions in the range. |
| `partial` | boolean | `true` when a metric could not be retrieved and comes as `null`. |

> [!TIP]
>
> Each subcompany queries the metrics service, so a full page can take a few seconds. Use `companyId` to refresh a single company, and retry later the ones that come with `partial: true`.

```bash cURL theme={null}
curl --request GET \
  --url 'https://gateway.jelou.ai/v1/partner/metrics?range=last_7d&page=1&limit=25' \
  --header 'x-api-key: <API_KEY>'
```

```json 200 Success theme={null}
{
  "success": true,
  "result": {
    "partner": "acme",
    "page": 1,
    "limit": 25,
    "total": 2,
    "range": "last_7d",
    "subcompanies": [
      {
        "id": "1024",
        "externalId": "C-000123",
        "conversations": 1280,
        "uniqueSessions": 942,
        "partial": false
      },
      {
        "id": "1031",
        "externalId": null,
        "conversations": 87,
        "uniqueSessions": null,
        "partial": true
      }
    ]
  },
  "statusCode": 200
}
```

```json 400 Invalid range theme={null}
{
  "success": false,
  "statusCode": 400,
  "error": "invalid_range"
}
```

```json 404 Not a subcompany theme={null}
{
  "success": false,
  "statusCode": 404
}
```


## OpenAPI

````yaml api/partner/openapi.json GET /metrics
openapi: 3.1.0
info:
  title: Jelou Partner API
  version: 1.0.0
  description: >-
    Read-only API for partners to monitor the companies subscribed to their
    products. The partner is resolved from the API key, so no route takes a
    partner identifier.
servers:
  - url: https://gateway.jelou.ai/v1/partner
    description: Production
security:
  - apiKey: []
paths:
  /metrics:
    get:
      summary: Usage metrics per subcompany
      description: >-
        Conversations and unique sessions of each subcompany over a time range
        ending now.
      operationId: listPartnerMetrics
      parameters:
        - name: range
          in: query
          required: true
          description: Time range.
          schema:
            type: string
            enum:
              - last_24h
              - last_7d
              - last_30d
              - last_90d
        - name: companyId
          in: query
          description: >-
            Restrict the result to one subcompany. Responds 404 when it is not a
            subscriber of the partner.
          schema:
            type: integer
            minimum: 1
        - name: page
          in: query
          description: Page number.
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: limit
          in: query
          description: Subcompanies per page.
          schema:
            type: integer
            minimum: 1
            maximum: 25
            default: 25
      responses:
        '200':
          description: A page of subcompanies.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - result
                  - statusCode
                properties:
                  success:
                    const: true
                  statusCode:
                    const: 200
                  result:
                    type: object
                    required:
                      - partner
                      - page
                      - limit
                      - total
                      - subcompanies
                      - range
                    properties:
                      partner:
                        type: string
                        description: Partner slug resolved from the API key.
                      page:
                        type: integer
                      limit:
                        type: integer
                      total:
                        type: integer
                        description: Subcompanies matching the request across all pages.
                      range:
                        type: string
                        enum:
                          - last_24h
                          - last_7d
                          - last_30d
                          - last_90d
                      subcompanies:
                        type: array
                        items:
                          $ref: '#/components/schemas/MetricsSubcompany'
        '400':
          description: Invalid query parameter.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - statusCode
                  - error
                properties:
                  success:
                    const: false
                  statusCode:
                    const: 400
                  error:
                    type: string
                    enum:
                      - invalid_page
                      - invalid_limit
                      - invalid_range
                      - invalid_company_id
        '401':
          description: Missing or invalid API key.
        '403':
          description: >-
            The API key lacks the `partners:read` scope, carries the `*`
            wildcard, or does not belong to an active partner.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - statusCode
                properties:
                  success:
                    const: false
                  statusCode:
                    const: 403
        '404':
          description: >-
            Resource not found. Also returned for a company that is not a
            subscriber of the partner.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - statusCode
                properties:
                  success:
                    const: false
                  statusCode:
                    const: 404
        '429':
          description: 'Rate limit exceeded: 60 requests per minute.'
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - statusCode
                properties:
                  success:
                    const: false
                  statusCode:
                    const: 500
components:
  schemas:
    MetricsSubcompany:
      type: object
      required:
        - id
        - externalId
        - conversations
        - uniqueSessions
        - partial
      properties:
        id:
          type: string
          description: Jelou company id.
        externalId:
          type:
            - string
            - 'null'
          description: Identifier of the company in the partner's own systems, when set.
        conversations:
          type:
            - integer
            - 'null'
        uniqueSessions:
          type:
            - integer
            - 'null'
        partial:
          type: boolean
          description: True when a metric could not be retrieved and is null.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Organization API key with the `partners:read` scope.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.