# Update a custom code block

`PATCH https://api.cademi.com.br/api/v3/settings/custom-code/{custom_code_id}`

Operation ID: `custom_code.update` · API v3

Updates an existing custom code block. Only the fields present in the request are changed.

Changing `status` also requires the `custom_code.activate` permission. Changing the `name` or `content` of a `pushalertco` block also requires the `custom_code.manage_pwa` permission.

Send `deleted: false` to restore a block from the trash.

Send the `ETag` returned by the retrieve operation in the `If-Match` header to avoid overwriting changes made since the block was retrieved.

Required permissions: `custom_code.write`, `custom_code.activate`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `custom_code_id` | path | string | yes |  |
| `If-Match` | header | string | no |  |

## Request body

Content type: `application/json`.

Schema: object.

## Responses

### 200

Returns the updated custom code block.

Body: `data`: CustomCode.

Fields of CustomCode:

| Field | Type | Required | Description |
|---|---|---|---|
| `content` | object or null | no | Code content. Returned only when retrieving a single custom code block with a credential that has the customcode.readcontent permission. |
| `created_at` | string (date-time) | yes |  |
| `deleted` | boolean | yes |  |
| `id` | string | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `custom_code` | yes |  |
| `position` | string, one of `head`, `body` | yes |  |
| `revision` | string | yes |  |
| `status` | string, one of `active`, `inactive` | yes |  |
| `type` | string, one of `active-campaign`, `custom`, `facebook-pixel`, `analytics`, `tagmanager`, `pushalertco`, `whats` | 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 custom code block was not found or is not accessible with the current credentials.

Body: Error.

### 412

The custom code block has changed since the supplied revision was retrieved.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

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