# Create a module

`POST https://api.cademi.com.br/api/v3/products/{product_id}/modules`

Operation ID: `modules.create` · API v3

Creates a module or, when `kind` is `group`, a group of modules in the product. New modules are created as `draft`.

To create a submodule, set `parent_id` to the public ID of a group in the same product.

Modules cannot be created in replicated products. Attempts to do so return the `replica_readonly` error code.

Required permissions: `modules.create`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `product_id` | path | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `kind` | string, one of `group`, `module` | yes |  |
| `name` | string | yes |  |
| `parent_id` | string or null | no |  |
| `position` | integer | no |  |

## Responses

### 201

Returns the newly created module.

Body: `data`: Module.

Fields of Module:

| Field | Type | Required | Description |
|---|---|---|---|
| `created_at` | string (date-time) | yes |  |
| `deleted` | boolean | yes |  |
| `id` | string | yes | Public ID, with the mod_ prefix. |
| `image` | string or null | yes |  |
| `kind` | string, one of `group`, `module` | yes |  |
| `lessons_count` | integer | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `module` | yes |  |
| `parent_id` | string or null | yes |  |
| `position` | integer | yes |  |
| `product_id` | string | yes | Public ID, with the prd_ prefix. |
| `revision` | string | yes |  |
| `settings` | object | yes | Module settings. Only type is supported; an empty object when no settings have been defined. |
| `status` | string, one of `published`, `draft` | yes |  |
| `updated_at` | string (date-time) | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The product was not found or is not accessible with the current credentials.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
