---
title: "Create fragment"
method: POST
path: "/papi/project/{projectId}/fragments"
tags: ["Fragments"]
---

# Create fragment

`POST /papi/project/{projectId}/fragments`

## Request

- Base URL: `https://api.websitepublisher.ai`
- URL: `https://api.websitepublisher.ai/papi/project/{projectId}/fragments`
- Auth: OAuth 2 (authorization code, authorization URL `https://api.websitepublisher.ai/dapi/oauth/authorize`, token URL `https://api.websitepublisher.ai/dapi/oauth/token`, scopes: `read`, `write`)

Create a reusable HTML fragment. Returns include_tag to embed in pages: <!--#wps-include fragment="name" -->. Use for shared elements like nav, footer.

## Path parameters

- `projectId` integer, required

## Request body

- FragmentCreate
  - `name` string, required: Fragment name (lowercase, hyphens/slashes allowed)
  - `content` string, required: HTML content of the fragment

## Response `201`

Fragment created, includes include_tag

## Other responses

- `422`: Validation error

---

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