FreePBX Middleware API Documentation

Welcome to the API documentation for the FreePBX Middleware system. This API facilitates data ingestion from FreePBX and data consumption for PowerBI.

Authentication

This API acts as a secure middleware and requires a Bearer Token for all requests. This ensures that only authorized services (FreePBX, PowerBI) can access the data.

How to Authenticate

You must include the Authorization header in every HTTP request with your secret token.

Authorization: Bearer YOUR_SECURE_TOKEN

Note: The token is generated securely by the system administrator and is not publicly available. If you lose your token, please contact the administrator to generate a new one from the server environment.

Rate Limiting & Usage Guidelines

To ensure system stability, the API enforces the following limits:

PowerBI Best Practices

Endpoints

2. Consumption Data (PowerBI) SECURE

GET /api/v1/data

Fetches flattened call data suitable for PowerBI ingestion.

Query Parameters

Paging With a Cursor

Request the first page without a cursor, then follow nextCursor until it comes back null. Records are ordered newest first (eventtime descending).

GET /api/v1/data?limit=1000&created_after=2026-07-19T22:00:00Z
    -> meta.pagination.nextCursor = "eyJldmVudHRpbWUi..."

GET /api/v1/data?limit=1000&created_after=2026-07-19T22:00:00Z&cursor=eyJldmVudHRpbWUi...
    -> meta.pagination.nextCursor = "eyJldmVudHRpbWUi..."   (repeat)

    ...until nextCursor is null, which means the last page has been reached.

Important: keep limit and all filters identical across every request in the same walk. The cursor encodes a position within one specific ordered result set, so changing a filter mid-walk produces meaningless results. An unreadable cursor returns 400 Bad Request.

Response Format (Paginated JSON)

{
  "data": [
    {
      "id": 1025,
      "eventtype": "CHAN_START",
      "eventtime": "2026-03-28T08:30:05.000Z",
      "cid_name": "John Doe",
      "cid_num": "101",
      "cid_ani": "101",
      "cid_rdnis": "",
      "cid_dnid": "900",
      "exten": "s",
      "context": "from-internal",
      "channame": "PJSIP/101-000000a1",
      "appname": "",
      "appdata": "",
      "amaflags": 3,
      "accountcode": "",
      "uniqueid": "1711611005.161",
      "linkedid": "1711611005.161",
      "peer": "",
      "userdeftype": "",
      "extra": "{\"header\":\"value\"}"
    }
  ],
  "meta": {
    "pagination": {
      "total": 1,
      "limit": 500,
      "offset": 0,
      "hasNextPage": false,
      "hasPrevPage": false,
      "nextOffset": null,
      "prevOffset": null,
      "nextCursor": null
    }
  }
}

Pagination Fields