---
title: "Replay a portable template into a project's goal graph"
method: POST
path: "/api/goal/replay-template"
tags: ["Goal"]
---

# Replay a portable template into a project's goal graph

`POST /api/goal/replay-template`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/goal/replay-template`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

T143. Node creation follows BFS from the template root; a dep edge that would create a cycle is skipped with a log.

## Request body

- object
  - `template` object, required
    - `schemaVersion` 1, required
    - `label` string, required
    - `rootTemplateId` integer, required
    - `nodes` object[], required
    - `edges` object[], required
  - `target_parent_id` integer, nullable
  - `project_id` integer, nullable
  - `preserve_status` boolean

## Response `201`

Replay result.

- object
  - `created` integer
  - `deps` integer
  - `idMap` object: The new database id for each template node, keyed by templateId.

## Other responses

- `400`: Request body/query failed Zod validation.
- `401`: Missing or invalid credentials.

---

[API](https://skmtc.dev/contextq/apis/contextq-api.md) · [All operations](https://skmtc.dev/contextq/apis/contextq-api/llms.txt) · [OpenAPI document](https://skmtc.dev/contextq/apis/contextq-api/revisions/7afc44056a22?raw)
