Is AI recommending you? Ask Contentstack Canoe for free
Is AI recommending your brand? Find out with Contentstack Canoe for free
Contentstack.comAcademyLogin
CS-log-dark.svgCS-log-dark.svg
  • Changelog
  • APIs
  • SDKs

Platform

  • Solution Center
  • Marketplace
  • Changelog
  • Developers & IT
  • Business users
  • Digital leaders
  • Developer Fast Track
  • Plans & Pricing

Solutions

  • Retail
  • Travel and tourism
  • Financial services
  • Technology
  • Manufacturing
  • E-commerce
  • Localization
  • Personalization
  • Portals and knowledge bases

Resources

  • Academy
  • Docs
  • Contentstack for Developers
  • Product updates
  • Contentstack on Contentstack
  • Blog
  • Insights and analyst reports
  • The Forrester Wave™: Digital Experience Platforms, Q4 2025
  • Webinars
  • Podcasts
  • Glossary
  • Content generative library
  • Community
  • Headless CMS
  • Composable AXP
  • Personalization
  • CDP

Customers

  • Case Studies
  • Customer Care
  • Contentstack Experience Awards
  • Customer support

Partners

  • Overview
  • Find a partner
  • Login

Company

  • About us
  • News
  • Customer support portal
  • Contact

Social

  • Facebook
  • LinkedIn
  • Instagram
  • GitHub
  • YouTube
  • Discord
  • X
LegalTermsPrivacyTrust Center

Cookie settings

Copyright © 2026 Contentstack Inc. All rights reserved.
/
  1. Home
  2. APIs
  3. Lytics API
  4. V1
  5. SegmentML

SegmentML

markdownView as Markdown

SegmentML provides a framework for building custom machine learning

models directly in Lytics. Lytics SegmentML models are self-training,

continuously-updating and real-time.

SegmentML models are built by identifying:

1. A segment of users, called the **Target Segment** who exhibit behavior for *prediction*,

2. A segment of users, called the **Source Segment** to be candidates for model *evaluation*, or scoring.

Models are built with a variety of pre-selected candidate features, which include behavioral scores and content affinities, and can additionally support any custom field available in Lytics user profiles.

Attributes concerning the SegmentML model's setup configuration are detailed in **SegmentML Create**. Attributes concerning the model's results are defined in **SegmentML Model Fetch**.

Generic attributes from SegmentML model GET and POST:

| field | DataType | Description |

|-------------- |------------------|---------------|

| name | string | The model's name

| state | string | The state of the model: Either *building*, *invalid*, or *complete*

| reason | string | If the state is *invalid* the reason will denote the error

| created | string | Date and time the model was created

SegmentML Model Fetch

GEThttps://api.lytics.io/api/segmentml/{id}

Get a SegmentML model.

Additional atttributes from a completed SegmentML model GET response:

| field | DataType | Description |

|-----------------------|------------------|---------------|

| features: kind | string | The field is either a Lytics Segment feature (*segment*), a lql/user-field feature (*lql*), a Lytics Behavioral Score feature (*score*), or a Lytics Content Affinity feature (*content*)

| features: fieldtype | string | Field type is either *numeric* or *categorical*

| features: name | string | The name of a field

| features: importance | number | The relative importance of a field in the model

| features: correlation | number | Correlation between specific field and target

| features: impact | object | The impact object details the Lift and shows the marginal effect of a feature on the predicted outcome of the model

| mse | number | Mean-squared error value

| rsq | number | R-squared value or coefficient of determination

| false_negative | number | The number of users in the source segment who are predicted to be in the target segment.

| false_positive | number | The number of users in the target segment who are not predicted to be in the target segment.

| true_negative | number | The number of users in the source segment who are not predicted to be in the target segment.

| true_positive | number | The number of users in the target segment who are predicted to be in the target segment.

| success | []number | Number of successful predictions for a given prediction value

| failure | []number | Number of failed predictions for a given prediction value

| auc | number | Area under the ROC curve

| threshold | number | Optimal decision threshold to minimize false-positives and false-negatives

| accuracy | number | A value that represents the accuracy of the model; scale ranges from 0 (least accurate) to 10 (most accurate).

| reach | number | A value that represents the number of source users that look like target users; scale ranges from 0 (low reach) to 10 (high reach).

| model_health | number | The overall health of the model (i.e. "healthy", "unhealthy")

| msgs | number | Messages for the user about the model with levels of severity (i.e. "debug", "info", "warn", "error")

To learn more about the metrics false negative, false positive etc., check out [binary classification](https://en.wikipedia.org/wiki/Binary_classification).

``

# Curl example of getting a SegmentML model

curl -s -J -XGET "https://api.lytics.io/api/segmentml/all::smt_power" -H "Authorization: $LIOKEY"

``

Hide Parameters

URL Parameters

idrequiredstring

ID of the SegmentML model to retrieve, of the form SOURCE_SLUG::TARGET_SLUG.

Example:

source::target

Query Parameters

account_idoptionalstring

Your Lytics account ID.

Headers

Authorizationoptionalstring

Sample Response
Status|200 OK
1
OK

SegmentML Delete

DELETEhttps://api.lytics.io/api/segmentml/{id}

Delete a SegmentML model.

``sh

# Curl example of deleting a SegmentML model

curl -s -J -XDELETE "https://api.lytics.io/api/segmentml/all::smt_power" -H "Authorization: $LIOKEY"

``

Hide Parameters

URL Parameters

idrequiredstring

ID of the SegmentML model to delete, of the form SOURCE_SLUG::TARGET_SLUG.

Example:

source::target

Query Parameters

account_idoptionalstring

Your Lytics account ID.

Headers

Authorizationoptionalstring

Sample Response
Status|204 No Content
1
No Content

SegmentML Create

POSThttps://api.lytics.io/api/segmentml

SegmentML Dependencies

GEThttps://api.lytics.io/api/segmentml/_dependencies/{modelname}


Hide Parameters

URL Parameters

modelnamerequiredstring

Name of the model to get dependencies for.

Example:

my_model

Query Parameters

account_idoptionalstring

Your Lytics account ID.

Headers

Authorizationoptionalstring

Sample Response
Status|200 OK
123456789101112131415161718192021222324252627282930313233343536
{
  "message": "success",
  "status": 200,
  "data": {
    "fields": {
      "lytics_score_frequency": [
        [
          1,
          0.5283225806451614
        ],
        [
          4.6,
          0.5283225806451614
        ],
        [
          8.2,
          0.5281612903225807
        ]
      ],
      "lytics_score_intensity": [
        [
          1,
          0.5283225806451614
        ],
        [
          4.6,
          0.5283225806451614
        ],
        [
          8.2,
          0.5281612903225807
        ]
      ]
    }
  }
}

Create a new SegmentML model.

Model configuration can be specified either through sending the options

as a flat JSON object POST body or through URL parameters on the request.

``sh

# Curl example of creating a SegmentML model

curl -s -J -XPOST "https://api.lytics.io/api/segmentml" -H "Authorization: $LIOKEY" -d '

{

"source": "all",

"target": "smt_power",

"use_scores": true

}

'

``

Sample Response
Status|201 Created
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
{
  "name": "test_rf",
  "state": "building",
  "reason": "",
  "created": "2018-07-10T16:10:54.456003352-07:00",
  "conf": {
    "source": {
      "aid": 123,
      "account_id": "lol",
      "id": "",
      "name": "all",
      "is_public": false,
      "slug_name": "",
      "description": "",
      "author_id": "",
      "updated": "0001-01-01T00:00:00Z",
      "created": "2018-07-10T16:10:54.442558895-07:00",
      "invalid": false,
      "invalid_reason": "",
      "deleted": false,
      "datemath_calc": false,
      "forward_datemath": false,
      "save_hist": false,
      "schedule_exit": false,
      "tags": null
    },
    "target": {
      "aid": 123,
      "account_id": "lol",
      "id": "",
      "name": "goal",
      "is_public": false,
      "slug_name": "",
      "description": "",
      "author_id": "",
      "updated": "0001-01-01T00:00:00Z",
      "created": "2018-07-10T16:10:54.442559277-07:00",
      "invalid": false,
      "invalid_reason": "",
      "deleted": false,
      "datemath_calc": false,
      "forward_datemath": false,
      "save_hist": false,
      "schedule_exit": false,
      "tags": null
    },
    "target_field": null,
    "model_name": "",
    "additional": null,
    "collections": null,
    "collect": 0,
    "use_scores": true,
    "use_content": false,
    "build_only": false,
    "auto_tune": false
  }
}
Hide Parameters

Query Parameters

account_idoptionalstring

Your Lytics account ID.

sourcerequiredstring

ID or slug of the source segment.

Example:

all
targetoptionalstring

ID or slug of the target segment. **Required** if target field is not supplied.

Example:

smt_power
use_scoresoptionalstring

Include raw behavioral scores as features in the model (usually very useful).

Example:

true
target_fieldoptionalstring

Slug of the target field. Cannot provide both a target and a target field, hence required if target segment is not indicated (see above).

Example:

LTV
use_contentoptionalstring

If true, include content affinities as features in the model.

Example:

false
aspect_collectionsoptionalstring

List of Segment Collections to include in the model. Possible values are "email", "web", "support", "mobile", "commerce", "behaviors", "content".

Example:

["web", "mobile"]
additional_fieldsoptionalstring

List of additional user fields to include in the model.

Example:

["age", "country"]
model_onlyoptionalstring

Build the model without scoring each user. This is useful during model building exercises when comparing efficiency and accuracy between models. Set true by default unless **evalonly** is selected.

Example:

true
eval_onlyoptionalstring

If true, a previously built model is used to rescore users. Only the source and target parameters are needed in the API call to to identify which model to use.

Example:

false
auto_tuneoptionalstring

If true, enable auto-tune feature selection.

Example:

false
tune_modeloptionalstring

If true, model tuning parameters are optimized before any models are built. Experimental.

Example:

false
tagsoptionalstring

Includes tags to be associated with the model.

Example:

["increase momentum", "mobile users"]
re_runoptionalstring

If true, re-run the model every week.

Example:

false
save_segmentsoptionalstring

If true, this saves three different segments:

1) Users from source and target segments who "look like" users from the target segment.

2) Users not in the target segment.

3) Users from the source segment who look like users from the target segment.

Example:

false
as_isoptionalstring

If true, do not remove any of the model features when creating the model.

Example:

false
num_to_trainoptionalstring

The number of samples to collect from both the source and target segment for feature matrices. Defaults to 5,000.

Example:

5000
cor_thresholdoptionalstring

Threshold (0.0-1.0) at which to remove correlated features.

Example:

0.9

Headers

Authorizationoptionalstring