For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create model

Create a forecast model.

Create Model

post

Creates a new forecast model. You must provide a name and a location (via a Saved Location ID). Optionally specify demand_type, label, external_id, forecast_window, algo, and generate_baseline.

After creating a model, upload historical demand data using the Create Demand Data endpoint, then trigger training.

Authorizations
AuthorizationstringRequired

Enter your PredictHQ API key. The Bearer prefix is added automatically.

When calling the API directly, send: Authorization: Bearer <YOUR_API_KEY> as documented at https://docs.predicthq.com/api/overview/authenticating

Body
namestring · min: 1Required

Name for the forecast model.

external_idstring · min: 1Optional

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.

forecast_windowstring · enumOptional

Number of days into the future to forecast.

Possible values:
generate_baselinebooleanOptional

When true, generates a baseline model using historical demand data only - without PredictHQ demand intelligence - for benchmarking accuracy against the enhanced model.

Default: false
labelstring[] · min: 1Optional

Set of labels you can use to better identify or group your forecast models.

algoconst: phq-xgboostOptional

Currently we offer one algorithm based on XGBoost. In the future we may offer additional algos.

Default: phq-xgboost
Responses
201

Successful Response

application/json
errorsstring[]Optional

List of error messages, if any.

Default: []
warningsstring[]Optional

List of warning messages, if any.

Default: []
model_idstring · min: 1Required

Unique identifier for the newly created forecast model.

post/v1/forecasts/models
POST /v1/forecasts/models HTTP/1.1
Host: api.predicthq.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 224

{
  "name": "text",
  "external_id": "text",
  "forecast_window": "1d",
  "generate_baseline": false,
  "label": [
    "text"
  ],
  "location": {
    "saved_location_id": "text"
  },
  "algo": "phq-xgboost",
  "demand_type": {
    "interval": "text",
    "industry": "accommodation"
  }
}
{
  "errors": [
    "text"
  ],
  "warnings": [
    "text"
  ],
  "model_id": "text"
}

OpenAPI Spec

The OpenAPI spec for Forecasts API can be found here.

Guides

Last updated

Was this helpful?