# Run an AI action for a content type

_NgCms / AI Actions_

`POST /ng-cms/content-types/{projectId}/{key}/ai-actions/{actionId}/run`

## Parameters

- `projectId` (string, required) — Project (bucket) identifier
- `key` (string, required) — Content type ID or key
- `actionId` (string, required) — AI action ID to run

## Request Body

### `RunCmsTypeAiActionRequest`

- `entryId` (string, required) — ID of the content entry to run the action against

## Responses

### `202` — Action ran successfully against the entry.

Type: `ApiResponse<bool>`

- `success` (boolean) — Always true on success
- `result` (boolean) — Always true
- `errors` (ErrorDetail[]) — Empty on success

### `400` — entryId missing from the request body, or the action failed for a reason other than not-found/locked (e.g. publish failed after running).

Type: `ApiResponse<bool>`

- `success` (boolean) — Always false
- `result` (boolean) — Always false
- `errors` (ErrorDetail[]) — One error describing why the run failed

### `401` — Unauthorized.


### `404` — Either the content type does not exist for projectId/key (empty body), or the actionId/entryId does not exist (ApiResponse<bool> body with an error message).

Type: `ApiResponse<bool> | empty`

- `success` (boolean) — Always false (only present when action/entry not found)
- `errors` (ErrorDetail[]) — One error describing what wasn't found (only present when action/entry not found)

### `409` — The target entry is currently locked (e.g. being edited/processed by another operation).

Type: `ApiResponse<bool>`

- `success` (boolean) — Always false
- `errors` (ErrorDetail[]) — One error describing the lock

### `500` — Unexpected server error.

Type: `ApiResponse<bool>`

- `success` (boolean) — Always false
- `errors` (ErrorDetail[]) — Server-side errors
  - `correlationId` (string) — Trace ID
  - `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-types/{projectId}/{key}/ai-actions/{actionId}/run \
  --header 'x-api-key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{"entryId":"cnt_a1b2c3d4e5f6"}'
```

### javascript

```js
fetch('https://apis-spb.konso.io/ng-cms/content-types/{projectId}/{key}/ai-actions/{actionId}/run', {
  method: 'POST',
  headers: { 'x-api-key': '<your-api-key>', 'Content-Type': 'application/json' },
  body: JSON.stringify({ entryId: 'cnt_a1b2c3d4e5f6' })
})
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

### dotnet

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

var response = await client.PostAsJsonAsync("https://apis-spb.konso.io/ng-cms/content-types/{projectId}/{key}/ai-actions/{actionId}/run", new RunCmsTypeAiActionRequest { EntryId = "cnt_a1b2c3d4e5f6" });
var result = await response.Content.ReadFromJsonAsync<ApiResponse<bool>>();
```

### python

```python
import requests

headers = {'x-api-key': '<your-api-key>'}
response = requests.post('https://apis-spb.konso.io/ng-cms/content-types/{projectId}/{key}/ai-actions/{actionId}/run', json={'entryId': 'cnt_a1b2c3d4e5f6'}, headers=headers)
print(response.json())
```

### Request Body Example

```json
{
  "projectId": "example-string",
  "key": "example-string",
  "actionId": "example-string"
}
```

### Response Example (202)

```json
{
  "success": true,
  "result": true,
  "errors": []
}
```
