---
title: Translate a Story by AI
description: This endpoint returns the story content, translated by AI.
url: https://storyblok.com/docs/api/management/stories/ai-translate
---

# Translate a Story by AI

PUT

```html
https://mapi.storyblok.com/v1/spaces/:space_id/stories/:story_id/ai_translate
```

This endpoint returns the story content, translated by AI.

> [!WARNING]
> This endpoint will not create or update any story. It will only return the content with the internationalized keys and values for the specific language. Please refer to [Update a Story](/docs/api/management/stories/update-a-story) to apply the translation.

## Path parameters

-   `:space_id` (required) (number)
    
    Numeric ID of a space
    
-   `:story_id` (required) (number)
    
    Numeric id of story
    

## Request body properties

-   `lang` (string)
    
    The official language code (e.g., `en`, `de`, `fr`) used for localization.
    
-   `code` (string)
    
    The custom language identifier defined in the Space Settings under Internationalization.
    
-   `overwrite` (boolean)
    
    Indicates whether the current value should replace the existing value for the specified language.
    
-   `release_id` (number)
    
    Release ID of the story.
    

## Response properties

-   `story` (The Story Object)
    
    A single [story object,](/docs/api/content-delivery/v2/stories/the-story-object) containing the translated fields in its `content` property.
    

## Examples

-   cURL
    
    ```shellscript
    curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/536503907/ai_translate" \
      -X PUT \
      -H "Authorization: YOUR_OAUTH_TOKEN" \
      -H "Content-Type: application/json" \
      -d "{\"code\":\"fr\",\"lang\":\"fr\",\"overwrite\":true,\"release_id\":0}"
    ```
    
-   JS
    
    ```javascript
    // storyblok-js-client@>=7, node@>=18
    import Storyblok from "storyblok-js-client";
    
    const storyblok = new Storyblok({
      oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",
    });
    
    try {
      const response = await storyblok.put('spaces/288868932106293/stories/536503907/ai_translate', {
        "code": "fr",
        "lang": "fr",
        "overwrite": true,
        "release_id": 0
      })
      console.log({ response })
    } catch (error) {
      console.log(error)
    }
    ```
    
-   PHP
    
    ```php
    $client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
    
    $payload = ["code" => "fr","lang" => "fr","overwrite" => true,"release_id" => 0];
    
    $client->put('spaces/288868932106293/stories/536503907/ai_translate', $payload)->getBody();
    ```
    
-   Java
    
    ```java
    HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/536503907/ai_translate")
      .header("Content-Type", "application/json")
      .header("Authorization", "YOUR_OAUTH_TOKEN")
      .body({"code":"fr","lang":"fr","overwrite":true,"release_id":0})
      .asString();
    ```
    
-   C#
    
    ```csharp
    var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/536503907/ai_translate");
    var request = new RestRequest(Method.PUT);
    
    request.AddHeader("Content-Type", "application/json");
    request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
    request.AddParameter("application/json", "{\"code\":\"fr\",\"lang\":\"fr\",\"overwrite\":true,\"release_id\":0}", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    ```
    
-   Python
    
    ```python
    import requests
    
    url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/536503907/ai_translate"
    
    querystring = {}
    
    payload = {"code":"fr","lang":"fr","overwrite":true,"release_id":0}
    headers = {
      'Content-Type': "application/json",
      'Authorization': "YOUR_OAUTH_TOKEN"
    }
    
    response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)
    
    print(response.text)
    ```
    
-   Ruby
    
    ```ruby
    require 'storyblok'
    client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
    
    payload = {"code" => "fr","lang" => "fr","overwrite" => true,"release_id" => 0}
    
    client.put('spaces/288868932106293/stories/536503907/ai_translate', payload)
    ```
    
-   Swift
    
    ```swift
    let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))
    var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/536503907/ai_translate")
    request.httpMethod = "PUT"
    request.httpBody = try JSONSerialization.data(withJSONObject: [
        "code": "fr",
        "lang": "fr",
        "overwrite": true,
        "release_id": 0,
    ])
    let (data, _) = try await storyblok.data(for: request)
    print(try JSONSerialization.jsonObject(with: data))
    ```
    
-   Kotlin
    
    ```kotlin
    val client = HttpClient {
        install(Storyblok(MAPI)) {
            accessToken = OAuth("YOUR_OAUTH_TOKEN")
        }
    }
    
    val response = client.put("spaces/288868932106293/stories/536503907/ai_translate") {
        setBody(buildJsonObject {
            put("code", "fr")
            put("lang", "fr")
            put("overwrite", true)
            put("release_id", 0)
        })
    }
    
    println(response.body<JsonElement>())
    ```

You will receive a single [story object,](/docs/api/content-delivery/v2#stories/the-story-object) containing the translated fields in its `content` property.

## Pagination

-   [Previous: Internationalization for Stories](/docs/api/management/stories/internationalization-for-stories)
-   [Next: The Story Object](/docs/api/management/stories/the-story-object)
