# Replace Model

## Replace Model

> Replaces the full configuration of an existing forecast model. This is a full replacement — all mutable fields should be provided. Changes to \`location\`, \`demand\_type\`, \`forecast\_window\`, \`algo\`, or \`generate\_baseline\` are blocked while the model is in \`preparing\`, \`training\`, or \`forecasting\` status. Changing any of those fields sets the model to \`stale\` status, requiring re-training to take effect.

```json
{"openapi":"3.1.0","info":{"title":"PredictHQ Forecasts API (Public Preview)","version":"1.0.0"},"tags":[{"name":"Models"}],"servers":[{"url":"https://api.predicthq.com"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"$API_KEY","description":"Enter your PredictHQ API key. The Bearer prefix is added automatically.\n\nWhen calling the API directly, send: `Authorization: Bearer <YOUR_API_KEY>` as documented at [https://docs.predicthq.com/api/overview/authenticating](https://docs.predicthq.com/api/overview/authenticating)\n"}},"schemas":{"ReplaceModelRequest":{"type":"object","properties":{"name":{"description":"Name for the forecast model.","type":"string","minLength":1,"title":"Name"},"external_id":{"description":"User-provided external identifier for cross-referencing with other systems.","anyOf":[{"type":"string","minLength":1},{"type":"null"}],"title":"External Id"},"forecast_window":{"description":"Number of days into the future to forecast.","anyOf":[{"$ref":"#/components/schemas/ForecastWindowDay"},{"type":"null"}]},"label":{"description":"Set of labels you can use to better identify or group your forecast models.","anyOf":[{"items":{"type":"string","minLength":1},"type":"array","minItems":1},{"type":"null"}],"title":"Label"},"location":{"description":"The geographic area for this model, specified by a Saved Location ID.","$ref":"#/components/schemas/Location"},"algo":{"description":"Algorithm to use for forecasting.","type":"string","default":"phq-xgboost","const":"phq-xgboost"},"demand_type":{"description":"Configuration for demand data type including industry and interval.","anyOf":[{"$ref":"#/components/schemas/InputDemandType"},{"type":"null"}]}},"additionalProperties":false,"required":["name","location"],"title":"ReplaceModelRequest"},"ForecastWindowDay":{"type":"string","enum":["1d","7d","14d","28d","30d","60d","90d"],"title":"ForecastWindowDay"},"Location":{"type":"object","properties":{"saved_location_id":{"description":"The unique identifier of a Saved Location defining the geographic area for this model.","type":"string","minLength":1,"title":"Saved Location ID"}},"required":["saved_location_id"],"title":"Location"},"InputDemandType":{"type":"object","properties":{"interval":{"description":"The time interval for demand data aggregation. Currently only `day` is supported.","$ref":"#/components/schemas/InputInterval"},"industry":{"description":"Industry classification determining which Predicted Impact Patterns are applied.","$ref":"#/components/schemas/Industry"}},"title":"InputDemandType"},"InputInterval":{"type":"string","const":"day","title":"InputInterval"},"Industry":{"description":"Choosing the right industry is important as this will determine the type of features used in the training and forecasting and will impact the accuracy of the results. We will use the applicable Predicted Impact Patterns for the specified industry.","type":"string","enum":["accommodation","cpg","tourism","marketing","parking","restaurants","retail","transportation","other"],"title":"Industry"},"ErrorResponse":{"type":"object","properties":{"error":{"description":"Error message","type":"string","title":"Error"}},"required":["error"],"title":"ErrorResponse"},"HTTPValidationError":{"type":"object","properties":{"error":{"description":"Error summary message","type":"string","title":"Error"},"details":{"description":"List of validation error details","type":"array","items":{"$ref":"#/components/schemas/ValidationErrorDetail"},"title":"Details"}},"required":["error","details"],"title":"HTTPValidationError"},"ValidationErrorDetail":{"type":"object","properties":{"field":{"description":"The field that failed validation","type":"string","title":"Field"},"msg":{"description":"The validation error message","type":"string","title":"Message"},"type":{"description":"The type of validation error","type":"string","title":"Error Type"}},"required":["field","msg","type"],"title":"ValidationErrorDetail"}}},"paths":{"/v1/forecasts/models/{model_id}":{"put":{"operationId":"update_model","summary":"Replace Model","description":"Replaces the full configuration of an existing forecast model. This is a full replacement — all mutable fields should be provided. Changes to `location`, `demand_type`, `forecast_window`, `algo`, or `generate_baseline` are blocked while the model is in `preparing`, `training`, or `forecasting` status. Changing any of those fields sets the model to `stale` status, requiring re-training to take effect.","parameters":[{"name":"model_id","in":"path","description":"The unique identifier of the forecast model.","required":true,"schema":{"type":"string","title":"Model Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReplaceModelRequest"}}}},"responses":{"204":{"description":"Successful Response"},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ErrorResponse"},{"$ref":"#/components/schemas/HTTPValidationError"}]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"tags":["Models"]}}}}
```

## OpenAPI Spec

The OpenAPI spec for Forecasts API can be [found here](https://api.predicthq.com/docs/?urls.primaryName=Forecasts+API).

## Guides

* [Getting Started with Forecasts API](https://docs.predicthq.com/getting-started/guides/forecasts-api-guides/getting-started)
* [Understanding Forecast Accuracy Metrics](https://docs.predicthq.com/getting-started/guides/forecasts-api-guides/understanding-forecast-accuracy-metrics)
* [Troubleshooting Guide for Forecasts API](https://docs.predicthq.com/getting-started/guides/forecasts-api-guides/troubleshooting)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.predicthq.com/api/forecasts/models/replace-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
