---
title: "Create a materialized view (or trigger rebuild)"
method: POST
path: "/views"
tags: ["Materialized Views"]
---

# Create a materialized view (or trigger rebuild)

`POST /views`

REST equivalent of `| materialize`. If name already exists, triggers a **versioned rebuild**:
old version keeps serving queries, new version builds in background, atomic swap on completion.

Send `If-None-Match: *` to get `409 Conflict` if the view already exists (prevents accidental rebuilds).

## Headers

- `If-None-Match` string

## Request body

- ViewInput
  - `name` string, required — Must start with `mv_`. Lowercase, underscores, alphanumeric.
  - `q` string, required — SPL2 pipeline (without `| materialize`)
  - `retention` string — Duration string. Default: same as index retention.
  - `partition_by` string — Partition strategy expression

## Response `200`

Existing MV — versioned rebuild triggered

## Other responses

- `201` — MV created, backfill started
- `409` — Conflict — view exists and `If-None-Match` was set

---

[API](https://skmtc.net/lynxbase/apis/lynxdb-api.md) · [All operations](https://skmtc.net/lynxbase/apis/lynxdb-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/lynxbase/lynxdb-api/revisions/4363a070c444/schema)
