Zum Inhalt
HALOWERK

Agent Tools

cohort / retention

Builds the cohort table from the events you pass: users grouped by the period of their first event, counted again in each following period. Returns the table per cohort, a retention curve across all cohorts, and, where events carry a value, cumulative value and value per user. The curve counts only cohorts old enough for a given period, so a young cohort is not scored as churn. Day, week and month are real calendar periods. Nothing is fetched, nothing is stored.

POST https://tools.halowerk.com/v1/cohort/retention

Eingaben

Felder des veröffentlichten Eingabeschemas
FeldTypPflichtBeschreibung
eventsarrayJaEach event needs user_id and a timestamp (time_unix_s in seconds since 1970, or time as ISO 8601). Optional: type and value. Any other field name is rejected rather than guessed. The service caps the whole request body at 256 KB, so long records reach that limit before maxItems.
periodstringNein
periodsintegerNeinHow many periods the table runs, period 0 being the entry period.
week_startstringNein
timezone_offset_sintegerNeinOffset from UTC in seconds used to place period boundaries.
activation_typestringNeinIf set, only events of this type put a user into a cohort. Without it the first event of any type counts.
retention_typesarrayNeinIf set, only events of these types count as being active. Without it every event counts.
Vollständiges Eingabeschema anzeigen
{
  "type": "object",
  "required": [
    "events"
  ],
  "properties": {
    "events": {
      "type": "array",
      "minItems": 1,
      "maxItems": 4000,
      "description": "Each event needs user_id and a timestamp (time_unix_s in seconds since 1970, or time as ISO 8601). Optional: type and value. Any other field name is rejected rather than guessed. The service caps the whole request body at 256 KB, so long records reach that limit before maxItems."
    },
    "period": {
      "type": "string",
      "enum": [
        "day",
        "week",
        "month"
      ],
      "default": "week"
    },
    "periods": {
      "type": "integer",
      "minimum": 1,
      "maximum": 52,
      "default": 12,
      "description": "How many periods the table runs, period 0 being the entry period."
    },
    "week_start": {
      "type": "string",
      "enum": [
        "monday",
        "sunday"
      ],
      "default": "monday"
    },
    "timezone_offset_s": {
      "type": "integer",
      "minimum": -50400,
      "maximum": 50400,
      "default": 0,
      "description": "Offset from UTC in seconds used to place period boundaries."
    },
    "activation_type": {
      "type": "string",
      "maxLength": 120,
      "description": "If set, only events of this type put a user into a cohort. Without it the first event of any type counts."
    },
    "retention_types": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "string"
      },
      "description": "If set, only events of these types count as being active. Without it every event counts."
    }
  }
}

Originalschema öffnen

Veröffentlichtes Eingabebeispiel

{
  "events": [
    {
      "user_id": "u1",
      "time_unix_s": 1785110400,
      "type": "order",
      "value": 19.9
    },
    {
      "user_id": "u1",
      "time_unix_s": 1785715200,
      "type": "order",
      "value": 24.5
    },
    {
      "user_id": "u2",
      "time_unix_s": 1785110400,
      "type": "order",
      "value": 12
    },
    {
      "user_id": "u3",
      "time_unix_s": 1785715200,
      "type": "order",
      "value": 30
    }
  ],
  "period": "week",
  "periods": 3
}

Ergebnis & Dokumentation

Maschinenlesbare Dokumentation dieses Hubs

Quelle dieser Seite: der veröffentlichte HALOWERK-Katalog. Stand: 2026-11-01, 15:19 UTC.

Weitere Endpunkte dieses Hubs

Alle Endpunkte dieses Hubs →