---
title: "Update exposure SQL model"
method: PUT
path: "/api/v2/experiments/exposure-sql-models/{exposure_sql_model_id}"
tags: ["Experiments"]
---

# Update exposure SQL model

`PUT /api/v2/experiments/exposure-sql-models/{exposure_sql_model_id}`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/experiments/exposure-sql-models/{exposure_sql_model_id}`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `product_analytics_warehouse_model_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/experiments/exposure-sql-models/:exposure_sql_model_id/put.ts> (a function with typed inputs; its response is checked against the schema)

Replace an exposure SQL model. This is a full replacement and is destructive: any subject type or property not present in the body is deleted, and properties are matched on name, column_name and column_type together, so changing one of those replaces the property rather than editing it. Send the complete set you want to keep. Anything removed is listed under meta.removed_subject_type_ids and meta.removed_property_names in the response. The warehouse connection is not settable and is left as stored.

## Path parameters

- `exposure_sql_model_id` string, uuid, required: The UUID of the exposure SQL model.

## Query parameters

- `include` string[]: Optional fields to include. Repeat this parameter to request several fields. `counts` adds experiment_count to the updated model.

## Request body

- ExperimentsCreateExposureSQLModelV2Request: Request to create a SQL model for experiment assignment data.
  - `data` ExperimentsCreateExposureSQLModelV2RequestData, required: Exposure SQL model resource to create.
    - `attributes` ExperimentsUpdateExposureSQLModelV2RequestDataAttributes, required: Complete column mappings and query used to replace the exposure SQL model.
      - `date_partition_column` string, nullable: SQL column used to partition the source data by date.
      - `experiment_column` string, required: SQL column that identifies the experiment for each exposure.
      - `migration_metadata` unknown
      - `name` string, required: Display name of the exposure SQL model.
      - `properties` ExperimentsSQLModelPropertyInput[]: Property columns exposed by the SQL model.
        - `column_name` string, required: Name of the SQL result column that supplies this property.
        - `column_type` 'STRING' | 'INTEGER' | 'FLOAT' | 'BOOLEAN' | 'DATE' | 'TIMESTAMP': Data type of a column in the SQL model.
        - `description` string, nullable: Optional text that explains what this property represents.
        - `migration_metadata` unknown
        - `name` string, required: Name used to identify the property in the model.
      - `sql` string, required: SQL query that produces the model's source data.
      - `subject_types` ExperimentsCreateExposureSQLModelV2RequestDataAttributesSubjectTypesItems[], required: Subject types mapped to columns in the SQL model.
        - `column_name` string, required: SQL result column that contains the subject identifier.
        - `subject_type_id` string, required: Identifier of the subject type mapped to this column.
      - `timestamp_column` string, required: SQL column that supplies the event timestamp.
      - `variant_column` string, required: SQL column that identifies the variant for each exposure.
    - `id` string: Optional JSON:API resource identifier field.
    - `type` 'exposure-sql-models', required: Exposure SQL models resource type.

## Response `200`

OK

- ExperimentsUpdateExposureSQLModelV2Response: Updated exposure SQL model and its removed entries.
  - `data` ExperimentsExposureSQLModelV2DTOData, required: Exposure SQL model resource with its identifier and configuration.
    - `attributes` ExperimentsExposureSQLModelV2DTODataAttributes: Query and column mappings used to read experiment assignment data.
      - `archived_at` string, date-time, nullable: Time when the exposure SQL model was archived.
      - `created_at` string, date-time: Time when the exposure SQL model was created.
      - `date_partition_column` string, nullable: Column used to identify date partitions in the exposure data.
      - `experiment_column` string: SQL result column that contains the experiment key.
      - `experiment_count` integer, nullable: Number of experiments associated with the exposure SQL model.
      - `migration_metadata` unknown
      - `name` string: Display name of the exposure SQL model.
      - `properties` ExperimentsExposureSQLModelV2DTODataAttributesItems[]: Property columns available for filtering or splitting exposure data.
        - `column_name` string: SQL result column that contains this property.
        - `column_type` string: Data type of the property column.
        - `description` string: Description of the exposure property.
        - `id` string: Identifier of the exposure property.
        - `migration_metadata` unknown
        - `name` string: Display name of the exposure property.
        - `pipeline_column_suffix` string: Suffix used for this property column in the analysis pipeline.
      - `sql` string: SQL query that supplies the experiment assignment data.
      - `subject_types` ExperimentsCreateExposureSQLModelV2RequestDataAttributesSubjectTypesItems[]: Mappings between subject types and their identifier columns.
        - `column_name` string, required: SQL result column that contains the subject identifier.
        - `subject_type_id` string, required: Identifier of the subject type mapped to this column.
      - `timestamp_column` string: SQL result column that contains the assignment timestamp.
      - `updated_at` string, date-time: Time when the exposure SQL model was last updated.
      - `variant_column` string: SQL result column that contains the assigned variant.
    - `id` string, uuid, required: Identifier of the exposure SQL model.
    - `type` 'exposure-sql-models', required: Exposure SQL models resource type.
  - `meta` ExperimentsUpdateExposureSQLModelV2ResponseMeta: Removed model entries. Present only when the update removes an entry.
    - `removed_property_names` string[]: Property names removed from the model.
    - `removed_subject_type_ids` string[]: Subject type IDs removed from the model.

## Other responses

- `400`: Malformed exposure SQL model ID, malformed body, validation failure, or the SQL was rejected by the warehouse validator.
- `401`: Missing or invalid authentication.
- `403`: Authenticated caller lacks the product_analytics_warehouse_model_write permission.
- `404`: No exposure SQL model with this ID exists for the organization.
- `409`: The write collided with an existing record for the organization.
- `415`: Request body sent with a media type other than application/json or application/vnd.api+json.
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
