> 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/developers/docs/_mcp/server.

# Update AI Action

PUT https://api.contentful.com/spaces/{space_id}/ai/actions/{ai_action_id}
Content-Type: application/vnd.contentful.management.v1+json

Use this endpoint to update an AI Action for a specified space.

Reference: https://contentful.com/developers/docs/references/content-management-api/ai-actions/update-ai-action

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `space_id` (string, required) — ID of the space in the form of a string
- `ai_action_id` (string, required) — ID of the AI Action in form of a string

### Headers

- `X-Contentful-Version` (string, required) — Version of the AI Action to update

### Body (application/vnd.contentful.management.v1+json)

This endpoint expects a map from string to any.

- `map from string to any`

## Response

### 200

OK - Request successful

- `map from string to any`

## Examples

**Request**

```json
{
  "configuration": {
    "modelTemperature": 0.1,
    "modelType": "anthropic.claude-3-5-sonnet"
  },
  "description": "Convert text to another language.",
  "instruction": {
    "template": "You are an expert in translating text to {{var.t82kaxhw0s13}}. Your task is to convert the provided content to the specified language while maintaining the original message and intent.",
    "variables": [
      {
        "description": "Target language or region for the translation.",
        "name": "Locale",
        "type": "Locale"
      }
    ]
  },
  "name": "Translate",
  "testCases": [
    {
      "type": "Text",
      "value": "This is an example text"
    }
  ]
}
```

**Response**

```json
{
  "configuration": {
    "modelTemperature": 0.1,
    "modelType": "anthropic.claude-3-5-sonnet"
  },
  "description": "Convert text to another language.",
  "instruction": {
    "template": "You are an expert in translating text to {{var.t82kaxhw0s13}}. Your task is to convert the provided content to the specified language while maintaining the original message and intent.",
    "variables": [
      {
        "description": "Target language or region for the translation.",
        "name": "Locale",
        "type": "Locale"
      }
    ]
  },
  "name": "Translate",
  "sys": {
    "createdAt": "2025-03-27T09:27:43.654Z",
    "createdBy": {
      "sys": {
        "id": "1xGZIRXr2WPnsLkKfREo0z",
        "linkType": "User",
        "type": "Link"
      }
    },
    "id": "3D5GGn5FlhszToS2Sbkfk8",
    "publishedAt": "2025-03-27T09:39:33.032Z",
    "publishedBy": {
      "sys": {
        "id": "1xGZIRXr2WPnsLkKfREo0z",
        "linkType": "User",
        "type": "Link"
      }
    },
    "publishedVersion": 1,
    "space": {
      "sys": {
        "id": "yadj1kx9rmg0",
        "linkType": "Space",
        "type": "Link"
      }
    },
    "type": "AiAction",
    "updatedAt": "2025-03-27T09:39:33.032Z",
    "updatedBy": {
      "sys": {
        "id": "1xGZIRXr2WPnsLkKfREo0z",
        "linkType": "User",
        "type": "Link"
      }
    },
    "version": 1
  },
  "testCases": [
    {
      "type": "Text",
      "value": "This is an example text"
    }
  ]
}
```

**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)
import { createClient } from 'contentful-management'

const client = createClient({
  accessToken: '<content_management_api_key>'
}, { type: 'legacy' })

const payload = {
  name: "Translate",
  description: "Convert text between languages efficiently.",
  instruction: {
  variables: [
    {
      name: "Source Locale",
      description: "Source language or region for the translation.",
      id: "6phtm7FYZiLt",
      type: "Locale",
      configuration: { localeType: "Source" }
    },
    {
      name: "Target Locale",
      description: "Target language or region for the translation.",
      id: "l6s9730ohhha",
      type: "Locale",
      configuration: { localeType: "Target" }
    },
    {
      name: "Source entry",
      description: "The entry to translate.",
      id: "9kf7t2pxq4wm",
      type: "Reference"
    },
    {
      type: "StandardInput",
      id: "8igfdwv6dy8y"
    }
  ],
  template: "You are an expert translation assistant. Translate the provided text from {{var.6phtm7FYZiLt}} into {{var.l6s9730ohhha}}. Use the referenced entry {{var.9kf7t2pxq4wm}} as additional context.\n\n{{var.8igfdwv6dy8y}}"
  },
  configuration: {
    modelTemperature: 0.1,
    modelType: "anthropic.claude-3-5-sonnet"
  },
  testCases: []
}

client.getSpace('<space_id>')
.then((space) => space.updateAiAction('<ai_action_id>', payload))
.then((aiAction) => console.log(aiAction))
.catch(console.error)
```

```javascript JavaScript
import { createClient } from 'contentful-management'

// Client init
const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

const payload = {
  name: "Translate",
  description: "Convert text between languages efficiently.",
  instruction: {
  variables: [
    {
      name: "Source Locale",
      description: "Source language or region for the translation.",
      id: "6phtm7FYZiLt",
      type: "Locale",
      configuration: { localeType: "Source" }
    },
    {
      name: "Target Locale",
      description: "Target language or region for the translation.",
      id: "l6s9730ohhha",
      type: "Locale",
      configuration: { localeType: "Target" }
    },
    {
      name: "Source entry",
      description: "The entry to translate.",
      id: "9kf7t2pxq4wm",
      type: "Reference"
    },
    {
      type: "StandardInput",
      id: "8igfdwv6dy8y"
    }
  ],
  template: "You are an expert translation assistant. Translate the provided text from {{var.6phtm7FYZiLt}} into {{var.l6s9730ohhha}}. Use the referenced entry {{var.9kf7t2pxq4wm}} as additional context.\n\n{{var.8igfdwv6dy8y}}"
  },
  configuration: {
    modelTemperature: 0.1,
    modelType: "anthropic.claude-3-5-sonnet"
  },
  testCases: []
}

await client.aiAction.update({ spaceId: '<space_id>', aiActionId: '<ai_action_id>' }, 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.
```