> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://contentful.com/developers/docs/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://contentful.com/_mcp/server. # Invoke an AI action POST https://api.contentful.com/spaces/{space_id}/environments/{environment_id}/ai/actions/{ai_action_id}/invoke Content-Type: application/vnd.contentful.management.v1+json Use this endpoint to invoke an AI Action for a specified space and environment. Reference: https://contentful.com/developers/docs/references/content-management-api/ai-actions/invoke-an-ai-action ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `space_id` (string, required) — ID of the space in the form of a string - `environment_id` (string, required) — ID of the environment in the form of a string - `ai_action_id` (string, required) — ID of the AI Action in form of a string ### Body (application/vnd.contentful.management.v1+json) This endpoint expects a map from string to any. - `map from string to any` ## Response ### 201 Created - Resource created successfully - `map from string to any` ## Examples **Request** ```json { "variables": [ { "id": "l6s9730ohhha", "value": "de" } ] } ``` **Response** ```json { "sys": { "aiAction": { "sys": { "id": "3D5GGn5FlhszToS2Sbkfk8", "linkType": "AiAction", "type": "Link" } }, "environment": { "sys": { "id": "staging", "linkType": "Environment", "type": "Link" } }, "id": "XgfOib1ayqA4Jl8GKIgUt", "space": { "sys": { "id": "yadj1kx9rmg0", "linkType": "Space", "type": "Link" } }, "status": "SCHEDULED", "type": "AiActionInvocation" } } ``` **SDK Code** ```android Android SDK currently doesn't implement this endpoint. ``` ```java Java SDK currently doesn't implement this endpoint. ``` ```kotlin Kotlin SDK currently doesn't implement this endpoint. ``` ```swift Swift We currently don't provide a CMA SDK for this platform. ``` ```js-legacy JavaScript (legacy) const payload = { variables: [ { id: 'l6s9730ohhha', value: 'de', }, { id: '8igfdwv6dy8y', value: 'This is an example text', }, { id: '9kf7t2pxq4wm', value: { sys: { type: 'Link', linkType: 'Entry', id: 'blogPost123', entityPaths: ['/fields/title', '/fields/body'], }, }, }, ], }; client.getSpace('') .then((space) => space.getEnvironment('')) .then((environment) => environment.invokeAiAction('', payload)) .then((aiActionInvocation) => console.log(aiActionInvocation)) .catch(console.error) ``` ```javascript JavaScript const payload = { variables: [ { id: 'l6s9730ohhha', value: 'de', }, { id: '8igfdwv6dy8y', value: 'This is an example text', }, { id: '9kf7t2pxq4wm', value: { sys: { type: 'Link', linkType: 'Entry', id: 'blogPost123', entityPaths: ['/fields/title', '/fields/body'], }, }, }, ], }; await client.aiAction.invoke({ spaceId: '', environmentId: '', aiActionId: '', }, payload); ``` ```php PHP SDK currently doesn't implement this endpoint. ``` ```ruby Ruby SDK currently doesn't implement this endpoint. ``` ```python Python SDK currently doesn't implement this endpoint. ``` ```.net .NET SDK currently doesn't implement this endpoint. ```