---
title: "Generate Preview Controller"
method: POST
path: "/modeling/propensity/generate_preview"
tags: ["modeling"]
---

# Generate Preview Controller

`POST /modeling/propensity/generate_preview`

## Request body

- GeneratePreviewPayload
  - `lapse_args` GenerateLapsePreviewPayload
    - `product_selections` SelectionPayload, required
      - `selections` array[], required
        - Selection[]
          - `field` string, required
          - `values` string[], nullable, required
    - `timeframe` SrcApiAdAnalyticsModelTimeframe, required
      - `start_date` string, date-time, required
      - `end_date` string, date-time, nullable, required
    - `lapse_criteria` EventCriteria, required
      - `event_count` integer, required — The number of events to be considered
      - `interval_type` 'day' | 'week' | 'month' | 'year', required — The interval type to use for the event
      - `interval_count` integer, required — The interval count to use for the event
    - `loyalty_criteria` EventCriteria, required
      - `event_count` integer, required — The number of events to be considered
      - `interval_type` 'day' | 'week' | 'month' | 'year', required — The interval type to use for the event
      - `interval_count` integer, required — The interval count to use for the event
    - `audience_id` string, nullable, required — The ID of the audience to use for the preview
    - `returning_is_loyal` boolean, required — Whether the returning customer is loyal
    - `lapse_to_other_criteria` EventCriteria
      - `event_count` integer, required — The number of events to be considered
      - `interval_type` 'day' | 'week' | 'month' | 'year', required — The interval type to use for the event
      - `interval_count` integer, required — The interval count to use for the event
    - `lapse_to_product_selections` SelectionPayload
      - `selections` array[], required
        - Selection[]
          - `field` string, required
          - `values` string[], nullable, required
  - `churn_args` GenerateChurnPreviewPayload
    - `table_name` string, required — The name of the table to use for the preview
    - `date_column` string, required — The name of the date column
    - `timeframe` SrcApiAdAnalyticsModelTimeframe
      - `start_date` string, date-time, required
      - `end_date` string, date-time, nullable, required
    - `loyalty_criteria` EventCriteria, required
      - `event_count` integer, required — The number of events to be considered
      - `interval_type` 'day' | 'week' | 'month' | 'year', required — The interval type to use for the event
      - `interval_count` integer, required — The interval count to use for the event
    - `churn_criteria` EventCriteria, required
      - `event_count` integer, required — The number of events to be considered
      - `interval_type` 'day' | 'week' | 'month' | 'year', required — The interval type to use for the event
      - `interval_count` integer, required — The interval count to use for the event
    - `audience_id` string, nullable — The ID of the audience to use for the preview
    - `provider_column` string, nullable — Column that identifies the provider/service
    - `provider_selections` ProviderSelection — Defines provider selection criteria for churn tracking
      - `from_provider` union, required — Providers we're tracking churn FROM. Can be a single provider string or list of providers
        - string
        - string[]
      - `to_providers` string[], nullable — Specific providers to track churn TO. If not provided, tracks any other provider
    - `churn_to_other_criteria` EventCriteria
      - `event_count` integer, required — The number of events to be considered
      - `interval_type` 'day' | 'week' | 'month' | 'year', required — The interval type to use for the event
      - `interval_count` integer, required — The interval count to use for the event

## Response `200`

Successful Response

- SrcAsyncJobServiceBuildConcreteAsyncJobRecordClassLocalsConcreteAsyncJobRecord10
  - `id` integer, nullable — ID of this object.
  - `created_at` string, date-time, nullable — datetime object representing when this object was created.
  - `updated_at` string, date-time, nullable — datetime object representing when this object was updated.
  - `deleted_at` string, date-time, nullable — datetime object representing when this object was deleted.
  - `status` 'RUNNING' | 'COMPLETED' | 'FAILED'
  - `endpoint` string — Endpoint spawning async job
  - `request` union — request sent to endpoint
    - object
    - unknown[]
      - unknown
  - `sync_response` union — sync response
    - object
    - unknown[]
      - unknown
  - `error` string, nullable — error message
  - `response` PropensityModelMetadataRecord
    - `id` integer, nullable — ID of this object.
    - `created_at` string, date-time, nullable — datetime object representing when this object was created.
    - `updated_at` string, date-time, nullable — datetime object representing when this object was updated.
    - `deleted_at` string, date-time, nullable — datetime object representing when this object was deleted.
    - `datasource_id` string, required — The ID of the datasource.
    - `preview_async_id` integer, required — The ID of the preview async.
    - `lapse_args` object, nullable — The arguments for the lapse analysis.
    - `churn_args` object, nullable — The arguments for the churn analysis.
    - `training_set_size` integer, nullable — The size of the training set.
    - `event_set_size` integer, nullable — The size of the event set.
    - `prediction_adjustment_factor` integer, nullable — The prediction adjustment factor.
    - `target_encodings` object, nullable — The target encodings.
    - `preview_quality_text` string, nullable — The preview quality text.
    - `approach_text` string, nullable — The approach text.
    - `feature_importances` object, nullable — The feature importances.
    - `ignore_columns` unknown[], nullable — The training columns to ignore.
      - unknown
    - `training_async_id` integer, nullable — The ID of the training async.
    - `shap_values` object, nullable — The SHAP values from the test set.
    - `performance_metrics` object, nullable — The performance metrics.
    - `model_path` string, nullable — The path to the model.
    - `feature_columns` string[], nullable — The columns to use as features.
    - `hyperparams` object, nullable — The hyperparams.
    - `model_text_summary` string, nullable — The text summary of the model.
    - `training_duration` number, nullable — The duration of the training in seconds.
    - `model_results` unknown[], nullable — The results of the model.
      - unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/akk/apis/fastapi.md) · [All operations](https://skmtc.net/akk/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/akk/fastapi/versions/6662a407c637/schema)
