Skip to content
Feralin

Developers

Feralin API guide: from first request to webhooks

For a developer using the API for the first time, in order: address, authentication, first request, errors, limits, sending events and webhooks. Every name and path here matches the contract; the full endpoint list is on the REST API page.

Example requests

The examples follow the order of the sections below. The addresses are this site's; read keys from environment variables and never write them into source code.

First request

Put your API key in an environment variable and call the endpoint that tells you whose key it is. This endpoint needs no scope.

export FERALIN_API_KEY="fak_live_…"

curl -H "Authorization: Bearer $FERALIN_API_KEY" \
  "https://feralin.com/api/v1/developer/me"

Response

{
  "subject_id": "…",
  "tenant_id": "…",
  "scopes": [
    "metrics:read",
    "projects:read"
  ],
  "workspace_ids": [
    "…"
  ]
}

scopes are the scopes you gave the key. For a key bound to a single project the response also has project_id.

Sandbox request

With a sandbox key (it starts with fak_test_) you can try the contract without touching real data. For this request the key needs the metrics:read scope.

curl -H "Authorization: Bearer $FERALIN_SANDBOX_KEY" \
  "https://feralin.com/api/v1/sandbox/metrics/query?metric_id=sessions&from=2026-10-01T00:00:00Z&to=2026-10-08T00:00:00Z&granularity=day"

The same request always returns the same response. It is labelled DEMO and never mixes with your real measurements.

Error response

The response to a request that went over the per-minute limit. Every error has this shape; your program should look at the type field.

HTTP/1.1 429 Too Many Requests
Content-Type: application/problem+json; charset=utf-8
Retry-After: 21

{
  "type": "urn:feralin:problem:rate_limited",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "…",
  "instance": "/v1/developer/me",
  "trace_id": "…",
  "retry_after_seconds": 21,
  "limit_scope": "api_key"
}

Retry-After is in seconds. Add the trace_id to your support request; the same ID is in the response's X-Trace-Id header.

Sending events

A batch request with a single event, sent to the collector. The project key only writes events; tenant and project are resolved from it.

curl -X POST "https://feralin.com/collect/v1/batch" \
  -H "Content-Type: application/json" \
  -H "X-Feralin-Project-Key: $FERALIN_PROJECT_KEY" \
  -H "Idempotency-Key: batch-20261114-0001" \
  -d '{
  "sent_at": "2026-11-14T10:00:01Z",
  "events": [
    {
      "event_id": "01JBX5Z8K3Q9R7T2V4W6Y8A0BC",
      "event_name": "signup_completed",
      "occurred_at": "2026-11-14T10:00:00Z",
      "platform": "server",
      "schema_version": 1,
      "anonymous_id": "anon_demo_001",
      "consent": {
        "analytics": true,
        "advertising": false
      }
    }
  ]
}'

Replace occurred_at with the real time of the event: events older than 90 days or more than 24 hours in the future are rejected. Use a new Idempotency-Key and a new event_id for every send.

Verifying a webhook signature (Node.js)

The signature is an HMAC-SHA256 value computed with your secret. rawBody must be the unparsed request body; if you re-serialize the JSON, the signature will not match.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyFeralinWebhook(secret, headers, rawBody) {
  const timestamp = Number(headers["feralin-webhook-timestamp"]);
  const now = Math.floor(Date.now() / 1000);
  if (!Number.isInteger(timestamp) || Math.abs(now - timestamp) > 300) return false;

  const expected = createHmac("sha256", secret).update(`${timestamp}.${rawBody}`, "utf8").digest();
  return String(headers["feralin-webhook-signature"] ?? "")
    .split(",")
    .map((part) => part.trim())
    .filter((part) => part.startsWith("v1="))
    .some((part) => {
      const candidate = Buffer.from(part.slice(3), "hex");
      return candidate.length === expected.length && timingSafeEqual(candidate, expected);
    });
}

Reject the request when the function returns false. Keep the Feralin-Webhook-Id so you never process the same delivery twice.

Connecting to the MCP server

The command for Claude Code. On first use a browser window opens and asks you to approve access to your workspace.

claude mcp add --transport http feralin https://feralin.com/mcp

With an API key, where no browser can open:

claude mcp add --transport http feralin https://feralin.com/mcp --header "Authorization: Bearer $FERALIN_API_KEY"

The connection is read-only. Settings for Cursor and other MCP clients are on the MCP page.

Contract files