> For the complete documentation index, see [llms.txt](https://docs.predicthq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.predicthq.com/api/forecasts/demand-data/upload-demand-data.md).

# Upload demand data

Upload historical demand data for an existing forecast model.

## Create Model Demand

> Uploads historical demand data for a forecast model. The model must exist and belong to the authenticated organization.\
> \
> You can use any of the following content types:\
> \- \`application/json\`: A JSON object with a \`demand\` array of \`{date, demand}\` objects.\
> \- \`text/csv\`: A CSV file with lowercase headers \`date,demand\` and one row per data point.\
> \- \`application/x-ndjson\`: Newline-delimited JSON where each line is a \`{date, demand}\` object.\
> \
> The \`date\` field should be in \`YYYY-MM-DD\` format and \`demand\` must be a non-negative number.

```json
{"openapi":"3.1.0","info":{"title":"PredictHQ Forecasts API","version":"1.0.0"},"tags":[{"name":"Demand Data"}],"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":{"CreateModelDemandRequest":{"type":"object","properties":{"demand":{"description":"Array of demand data points to upload. Each item must include a date and demand value.","type":"array","items":{"$ref":"#/components/schemas/DemandInput"},"minItems":1,"title":"Demand"}},"additionalProperties":false,"required":["demand"]},"DemandInput":{"type":"object","properties":{"demand":{"description":"Number value (float or integer, must be a positive number).\n\n\nFor example, it could be units sold, room bookings, or number of staff rostered\non per day or any other unit.","type":"number","minimum":0},"date":{"description":"Expected format: `2025-02-21`","type":"string","format":"date"}},"additionalProperties":false,"required":["date","demand"]},"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}/demand":{"post":{"operationId":"create_demand_data","summary":"Create Model Demand","description":"Uploads historical demand data for a forecast model. The model must exist and belong to the authenticated organization.\n\nYou can use any of the following content types:\n- `application/json`: A JSON object with a `demand` array of `{date, demand}` objects.\n- `text/csv`: A CSV file with lowercase headers `date,demand` and one row per data point.\n- `application/x-ndjson`: Newline-delimited JSON where each line is a `{date, demand}` object.\n\nThe `date` field should be in `YYYY-MM-DD` format and `demand` must be a non-negative number.","parameters":[{"name":"model_id","in":"path","description":"The unique identifier of the forecast model.","required":true,"schema":{"type":"string","title":"Model Id"}},{"name":"Content-Type","in":"header","description":"Content type of the uploaded payload.","required":true,"schema":{"type":"string","enum":["text/csv","application/x-ndjson","application/json"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateModelDemandRequest"}},"application/x-ndjson":{"schema":{"description":"Newline-delimited JSON where each line is an object with date and demand.","type":"string"}},"text/csv":{"schema":{"description":"CSV with lowercase headers date,demand and multiple rows of values.","type":"string"}}}},"responses":{"201":{"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":["Demand Data"]}}}}
```

## OpenAPI spec

The OpenAPI spec for Forecasts API is available in the [Forecasts API OpenAPI spec](https://api.predicthq.com/docs/?urls.primaryName=Forecasts+API).

## Guides

The following guides cover the Forecasts API:

* [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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.predicthq.com/api/forecasts/demand-data/upload-demand-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
