Translate a Story by AI
PUT
https://mapi.storyblok.com/v1/spaces/:space_id/stories/:story_id/ai_translateThis endpoint returns the story content, translated by AI.
Path parameters
Section titled “Path parameters”-
:space_idrequired numberNumeric ID of a space
-
:story_idrequired numberNumeric id of story
Request body properties
Section titled “Request body properties”-
langstringThe official language code (e.g.,
en,de,fr) used for localization. -
codestringThe custom language identifier defined in the Space Settings under Internationalization.
-
overwritebooleanIndicates whether the current value should replace the existing value for the specified language.
-
release_idnumberRelease ID of the story.
Response properties
Section titled “Response properties”-
storyThe Story ObjectA single story object, containing the translated fields in its
contentproperty.
Examples
Section titled “Examples”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}"// storyblok-js-client@>=7, node@>=18import 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)}$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();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();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);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)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)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))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, containing the translated fields in its content property.
Thanks! We received your feedback.
An error occurred. Please try again.
Was this page helpful?
This site uses reCAPTCHA and Google's Privacy Policy (opens in a new window) . Terms of Service (opens in a new window) apply.
Get in touch with the Storyblok community