---
title: "Create predictive scoring model (legacy)"
method: POST
path: "/audiences/{audienceId}/predictive_segments"
tags: ["Predictive Segments"]
---

# Create predictive scoring model (legacy)

`POST /audiences/{audienceId}/predictive_segments`

Create a new predictive scoring model. <br> _This endpoint is for Audience Studio legacy. For the latest Audience Studio, contact your Customer Success Representative._

## Path parameters

- `audienceId` integer, required

## Request body

- PredictiveSegmentParameters
  - `name` string
  - `description` string, nullable
  - `baseSegmentId` integer, nullable
  - `segmentId` integer
  - `scoredSegmentId` integer, nullable
  - `gradeThresholds` number[] — Given the items [a, b, c], they must meet the condition `a >= b >= c`
  - `categoricalAsColumnNames` string[]
  - `categoricalArrayAsColumnNames` string[]
  - `quantitativeAsColumnNames` string[]
  - `preprocess` PredictiveSegmentPreprocessItem[] — Definition of preprocess. All of `$item.column` must be specified in one of categoricalAsColumnNames, categoricalArrayAsColumnNames, or quantitativeAsColumnNames.
    - `column` string, required
    - `source` object, required
      - `column` string
      - `table` string
      - `functions` FunctionExpression[]
        - union
          - object
            - `function` '+' | '-' | '*' | '/', required
            - `arg` number
          - object
            - `function` 'replace', required
            - `search` string
            - `replacement` string, nullable
          - object
            - `function` 'substr', required
            - `start` number
            - `length` number
          - object
            - `function` 'regexp_extract', required
            - `pattern` string
            - `group` number
          - object
            - `function` 'day_of_week' | 'from_iso8601_timestamp' | 'ln' | 'elapsed_days' | 'td_ip_to_least_specific_subdivision_name' | 'td_ip_to_country_name' | 'td_ip_to_city_name' | 'td_ip_to_connection_type' | 'td_ip_to_domain', required
          - object
            - `function` 'cast_as_quantitative', required
            - `default` number, float, required
          - object
            - `function` 'cast_as_categorical', required
            - `default` string, required
          - object
            - `function` 'cast_as_categorical_array', required
          - object
            - `function` 'if', required
            - `op` '>' | '<' | '<=' | '>=' | '=' | '!=' | 'is' | 'is\' | 'not'
            - `right_value` number, nullable
            - `then` number
            - `else` number

## Response `200`

successful operation

- PredictiveSegment
  - `audienceId` string, integer
  - `id` string, integer
  - `baseSegmentId` string, integer, nullable
  - `segmentId` string, integer
  - `scoredSegmentId` string, integer, nullable
  - `name` string
  - `description` string, nullable
  - `categoricalAsColumnNames` string[]
  - `categoricalArrayAsColumnNames` string[]
  - `quantitativeAsColumnNames` string[]
  - `accuracy` number, double, nullable — Accuracy for trained model evaluated on initial training.
  - `areaUnderRocCurve` number, double, nullable — Evaluation score for the model. See also https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve
  - `gradeThresholds` number[] — Given the items [a, b, c], they must meet the condition `a >= b >= c`
  - `createdAt` string, date-time
  - `updatedAt` string, date-time

## Other responses

- `400` — Given parameters are not valid
- `401` — Unauthorized; You don't provide valid credentials. Maybe you didn't specify valid TD's Master API Key as 'TD1 {Your TD Master API Key}'.
- `403` — Requested resource or action is not allowed because you don't have sufficient permissions
- `404` — The specified resource was not found
- `4XX` — There is a high possibility of error of the authentication system. Please check the contents and authority of the key. Please contact the TD support team if you do not resolve it.
- `5XX` — System error. Because there is a possibility of a temporary error due to network trouble and so on, we recommend several times retry on request side. Please contact the TD support team if you do not resolve it.

---

[API](https://skmtc.net/treasure/apis/cdp-api.md) · [All operations](https://skmtc.net/treasure/apis/cdp-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/treasure/cdp-api/revisions/24caa8eb809b/schema)
