# Create Model

## POST /v1/forecasts/models

> Create Model

```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":{"CreateModelRequest":{"properties":{"name":{"description":"Name for the forecast model.","type":"string","minLength":1},"external_id":{"description":"External identifier for the forecast model. If you have an ID for the location/store/property/product-group in your other platforms, use the same ID here to easily connect this specific forecast model.","type":"string","minLength":1},"forecast_window":{"description":"Number of days into the future to forecast.","$ref":"#/components/schemas/ForecastWindowDay"},"label":{"description":"Set of labels you can use to better identify or group your forecast models.","items":{"type":"string","minLength":1},"type":"array","minItems":1},"location":{"description":"Location of your business so we can identify relevant events around the location impacting the demand.\n\nPlease create a Saved Location first, that can be reused across multiple forecast models if needed.","$ref":"#/components/schemas/Location"},"algo":{"description":"Currently we offer one algorithm based on XGBoost. In the future we may offer additional algos.","$ref":"#/components/schemas/AlgoType","default":"phq-xgboost"},"demand_type":{"$ref":"#/components/schemas/InputDemandType"}},"additionalProperties":false,"type":"object","required":["name","location"],"title":"CreateModelRequest"},"ForecastWindowDay":{"type":"string","enum":["1d","7d","14d","28d","30d","60d","90d"],"title":"ForecastWindowDay"},"Location":{"properties":{"saved_location_id":{"type":"string","minLength":1,"title":"Saved Location ID"}},"type":"object","required":["saved_location_id"],"title":"Location"},"AlgoType":{"type":"string","enum":["phq-xgboost"]},"InputDemandType":{"properties":{"interval":{"$ref":"#/components/schemas/InputInterval"},"industry":{"$ref":"#/components/schemas/Industry"}},"type":"object","title":"InputDemandType"},"InputInterval":{"type":"string","enum":["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"},"CreateModelResponse":{"properties":{"errors":{"items":{"type":"string"},"type":"array","title":"Errors","default":[]},"warnings":{"items":{"type":"string"},"type":"array","title":"Warnings","default":[]},"model_id":{"type":"string","minLength":1,"title":"Model Id"}},"type":"object","required":["model_id"],"title":"CreateModelResponse"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/forecasts/models":{"post":{"tags":["Models"],"summary":"Create Model","operationId":"create_model_models_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateModelRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateModelResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## 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)
