# Apply a content type template

_NgCms / Content Types_

`POST /ng-cms/content-type-templates/{projectId}/{code}/apply`

## Parameters

- `projectId` (string, required) — The unique identifier of the project
- `code` (string, required) — Template code to apply, as returned by the list-templates endpoint (e.g. 'website', 'blog', 'documentation', 'marketplace')

## Responses

### `200` — Content types created from the template. If a content type with the same key already exists in the project, its key and name are suffixed to avoid a collision. Returns the newly created content types, with reference fields resolved to the real IDs of the other content types created in the same call.

Type: `ApiResponse<CmsContentTypeDto[]>`

- `success` (boolean) — Always true on success
- `result` (CmsContentTypeDto[]) — The content types created from the template
  - `id` (string) — Unique identifier of the content type
  - `projectId` (string) — Project (bucket) this content type belongs to
  - `name` (string) — Human-readable display name
  - `key` (string) — Unique machine-readable identifier
  - `description` (string) — Optional description of the content type
  - `displayField` (string) — Schema field key used as the display/title field for entries
  - `schema` (CmsSchemaField[]) — Array of field definitions. Reference fields point at the real content type ID via referenceContentTypeId
  - `schemaVersion` (number) — Incremented each time the schema is modified
  - `fieldsCount` (number) — Number of fields in the schema
  - `entriesCount` (number) — Number of content entries for this content type (0 for a freshly applied template)
  - `isActive` (boolean) — Whether the content type is active
  - `createdBy` (number) — ID of the user who created the content type
  - `updatedBy` (number) — ID of the user who last updated the content type
  - `updatedByName` (string) — Name of the user who last updated the content type
  - `createdAt` (string) — ISO 8601 timestamp of creation
  - `updatedAt` (string) — ISO 8601 timestamp of last update
  - `hasNested` (boolean) — Whether the content type has nested/child content types
  - `systemTags` (string[]) — System-assigned tags
- `errors` (ErrorDetail[]) — Empty on success

### `401` — Unauthorized. A valid API key is required.


### `404` — No template exists for the given code.


### `412` — Precondition Failed. The project's current plan does not allow access to this resource, or payment is required.


### `500` — Unexpected server error.

Type: `ApiResponse<T>`

- `success` (boolean) — Always false
- `errors` (ErrorDetail[]) — List of server-side errors
  - `correlationId` (string) — Unique ID for tracing the error
  - `message` (string) — Error message
  - `stack` (string) — Stack trace (non-production only)


## Code Examples

### curl

```curl
curl --request POST \
  --url https://apis-spb.konso.io/ng-cms/content-type-templates/{projectId}/{code}/apply \
  --header 'x-api-key: <api-key>'
```

### javascript

```js
const options = {
  method: 'POST',
  headers: { 'x-api-key': '<api-key>' }
};

fetch('https://apis-spb.konso.io/ng-cms/content-type-templates/{projectId}/{code}/apply', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

### dotnet

```dotnet
var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", "<api-key>");

var response = await client.PostAsync("https://apis-spb.konso.io/ng-cms/content-type-templates/{projectId}/{code}/apply", null);
var result = await response.Content
    .ReadFromJsonAsync<ApiResponse<List<CmsContentTypeDto>>>();
```

### python

```python
import requests

url = "https://apis-spb.konso.io/ng-cms/content-type-templates/{projectId}/{code}/apply"
headers = { "x-api-key": "<api-key>" }

response = requests.post(url, headers=headers)
print(response.json())
```

### Request Body Example

```json
{
  "projectId": "example-string",
  "code": "example-string"
}
```

### Response Example (200)

```json
{
  "success": true,
  "result": [
    {
      "id": "ct_a1b2c3d4e5f6",
      "projectId": "my-project-id",
      "name": "Author",
      "key": "author",
      "description": null,
      "displayField": "name",
      "schema": [
        { "key": "name", "label": "Name", "type": "shorttext", "required": true },
        { "key": "bio", "label": "Bio", "type": "longtext" }
      ],
      "schemaVersion": 1,
      "fieldsCount": 2,
      "entriesCount": 0,
      "isActive": true,
      "createdBy": 42,
      "updatedBy": null,
      "updatedByName": null,
      "createdAt": "2026-07-24T10:00:00Z",
      "updatedAt": "2026-07-24T10:00:00Z",
      "hasNested": false,
      "systemTags": []
    },
    {
      "id": "ct_b2c3d4e5f6a7",
      "projectId": "my-project-id",
      "name": "Blog Post",
      "key": "blog_post",
      "description": null,
      "displayField": "title",
      "schema": [
        { "key": "title", "label": "Title", "type": "shorttext", "required": true },
        { "key": "author", "label": "Author", "type": "reference", "referenceContentTypeId": "ct_a1b2c3d4e5f6" }
      ],
      "schemaVersion": 1,
      "fieldsCount": 2,
      "entriesCount": 0,
      "isActive": true,
      "createdBy": 42,
      "updatedBy": null,
      "updatedByName": null,
      "createdAt": "2026-07-24T10:00:00Z",
      "updatedAt": "2026-07-24T10:00:00Z",
      "hasNested": false,
      "systemTags": []
    }
  ],
  "errors": []
}
```
