{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/instasent/json-schema/instasent-response-segment-item-schema.json",
  "title": "ResponseSegmentItem",
  "description": "Segment entity",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/instasent-segment-api-openapi.yml#/components/schemas/ResponseSegmentItem",
  "type": "object",
  "properties": {
    "contacts": {
      "allOf": [
        {
          "$ref": "#/$defs/SegmentContacts"
        }
      ],
      "description": "The segment's cached size. Present on every segment view and on the list\nendpoints, which serve what the cache already holds and never compute.\n**Null means the size is not known yet**, not that the segment is empty:\na listing returns null for any segment whose size has never been\ncomputed or has expired, and the single-segment view computes it. Always\nnull for parameterized dynamic segments.\n"
    },
    "totalContacts": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The same number as `contacts.count`, kept for existing clients. Prefer\n`contacts`, which carries the age of the figure; a bare total invites\nreading a cached number as a live one.\n"
    }
  },
  "additionalProperties": true,
  "x-stoplight": {
    "id": "1td95mbeye75x"
  },
  "$defs": {
    "SegmentContacts": {
      "type": "object",
      "description": "A segment's size as served from the segment-size cache, with its age. Never a\nlive count: the number is computed when someone looks at the segment and then\ncached, with a TTL that grows with the segment's size, so always narrate it with\nits age rather than as a current total.\n",
      "properties": {
        "count": {
          "type": "integer",
          "description": "Number of contacts in the segment when it was computed."
        },
        "computedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When the number was computed, ISO 8601."
        },
        "computedAgo": {
          "type": "string",
          "description": "The same instant in words, ready to show or say."
        },
        "approximate": {
          "type": "boolean",
          "description": "True when the count was sampled instead of counted exactly (very large\nor event-heavy segments), in which case it is rounded to three\nsignificant figures and `sampleFraction` and `marginPct` are present.\n"
        },
        "sampleFraction": {
          "type": "number",
          "format": "float",
          "description": "Fraction of the segment actually counted. Only when `approximate` is true."
        },
        "marginPct": {
          "type": "number",
          "format": "float",
          "description": "Margin of error of the sampled count, in per cent. Only when `approximate` is true."
        }
      },
      "required": [
        "count",
        "computedAt",
        "computedAgo",
        "approximate"
      ]
    }
  }
}