---
title: "Replace variable groups"
method: POST
path: "/variable_groups/{id}"
tags: ["Microdata"]
---

# Replace variable groups

`POST /variable_groups/{id}`

Replace the project's variable group tree. Body must be the nested storage shape (`vgid` required, `variables` unique positive UIDs, nested `variable_groups` objects). DDI-style space-separated VID/VGID strings are rejected. Empty array clears all groups.

## Path parameters

- `id` integer, required

## Request body

- object
  - `variable_groups` VariableGroupStored[], required
    - `vgid` string, required
    - `group_type` 'subject' | 'section' | 'multiResp' | 'grid' | 'display' | 'repetition' | 'version' | 'iteration' | 'analysis' | 'pragmatic' | 'record' | 'file' | 'randomized' | 'other'
    - `label` string
    - `txt` string
    - `universe` string
    - `notes` string
    - `definition` string
    - `variables` integer[] — Variable UIDs (not DDI VIDs)
    - `concepts` VariableGroupConcept[]
      - `concept` string
      - `vocab` string
      - `uri` string, uri
    - `variable_groups` VariableGroupStored[] — Nested child groups

## Response `200`

Groups saved

- object
  - `status` string

## Other responses

- `400` — Validation failed (missing vgid, DDI strings, duplicate ids)

## Changes

- **2026-08-13** `e176bc3938ca` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/worldbank/apis/metadata-editor-api/changes/variable_groups/:id/post.md)

---

[API](https://skmtc.dev/worldbank/apis/metadata-editor-api.md) · [All operations](https://skmtc.dev/worldbank/apis/metadata-editor-api/llms.txt) · [OpenAPI document](https://skmtc.dev/worldbank/apis/metadata-editor-api/revisions/629dd4bfe928?raw)
