# Create a release rule

`POST https://api.cademi.com.br/api/v3/products/{product_id}/access-schedules/{access_schedule_id}/rules`

Operation ID: `products.access_schedules.rules.create` · API v3

Creates the release rule for a node of the product tree that does not yet have its own rule. The node is identified by `level` (`product`, `section`, or `lesson`) and `target_id`.

If the node already has its own rule, the request returns the `already_exists` error code; use the update operation to change it instead.

The `hidden` type is not accepted at the `product` level, and the `percentage` type is read-only and cannot be set.

Required permissions: `access_schedules.update`.

## Parameters

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

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `level` | string, one of `product`, `section`, `lesson` | yes |  |
| `params` | object | yes |  |
| `target_id` | string | yes |  |
| `type` | string, one of `free`, `hidden`, `coming_soon`, `days_after_start`, `date`, `exam`, `percentage` | yes |  |

## Responses

### 201

Returns the newly created release rule.

Body: `data`: ReleaseRule.

Fields of ReleaseRule:

| Field | Type | Required | Description |
|---|---|---|---|
| `effective` | object | yes |  |
| `explicit` | boolean | yes |  |
| `id` | string | yes |  |
| `level` | string, one of `product`, `section`, `lesson` | yes |  |
| `object` | string, one of `release_rule` | yes |  |
| `params` | object | no | Rule parameters. The shape depends on type: {days}, {date}, {exam_id}, {percent}, or empty. |
| `target_id` | string | yes | Public ID of the product, module, or lesson, depending on level. |
| `type` | string or null, one of `free`, `hidden`, `coming_soon`, `days_after_start`, `date`, `exam`, `percentage` | no | Rule type defined on the node, or null when the node has no rule of its own (explicit is false). |

### 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 access schedule was not found for this product or is not accessible with the current credentials.

Body: Error.

### 409

The node already has its own release rule. Use the update operation to change it.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

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