Skip to main content
POST
/
contentful2
/
v1
/
async
/
convert-to-xliff
Convert raw content from Contentful to XLIFF asynchronously
curl --request POST \
  --url https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-Webhook: <x-webhook>' \
  --data '
{
  "rawFiles": [
    {
      "storageId": "e48eda63928c4155bez9fdbsaadc15f3",
      "info": {
        "name": "entry-123.json"
      }
    }
  ],
  "sourceLocale": "en-US"
}
'
import requests

url = "https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff"

payload = {
    "rawFiles": [
        {
            "storageId": "e48eda63928c4155bez9fdbsaadc15f3",
            "info": { "name": "entry-123.json" }
        }
    ],
    "sourceLocale": "en-US"
}
headers = {
    "X-Webhook": "<x-webhook>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {
    'X-Webhook': '<x-webhook>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    rawFiles: [
      {storageId: 'e48eda63928c4155bez9fdbsaadc15f3', info: {name: 'entry-123.json'}}
    ],
    sourceLocale: 'en-US'
  })
};

fetch('https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'rawFiles' => [
        [
                'storageId' => 'e48eda63928c4155bez9fdbsaadc15f3',
                'info' => [
                                'name' => 'entry-123.json'
                ]
        ]
    ],
    'sourceLocale' => 'en-US'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json",
    "X-Webhook: <x-webhook>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff"

	payload := strings.NewReader("{\n  \"rawFiles\": [\n    {\n      \"storageId\": \"e48eda63928c4155bez9fdbsaadc15f3\",\n      \"info\": {\n        \"name\": \"entry-123.json\"\n      }\n    }\n  ],\n  \"sourceLocale\": \"en-US\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Webhook", "<x-webhook>")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff")
  .header("X-Webhook", "<x-webhook>")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"rawFiles\": [\n    {\n      \"storageId\": \"e48eda63928c4155bez9fdbsaadc15f3\",\n      \"info\": {\n        \"name\": \"entry-123.json\"\n      }\n    }\n  ],\n  \"sourceLocale\": \"en-US\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://eu.phrase.com/connectors/contentful2/v1/async/convert-to-xliff")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Webhook"] = '<x-webhook>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"rawFiles\": [\n    {\n      \"storageId\": \"e48eda63928c4155bez9fdbsaadc15f3\",\n      \"info\": {\n        \"name\": \"entry-123.json\"\n      }\n    }\n  ],\n  \"sourceLocale\": \"en-US\"\n}"

response = http.request(request)
puts response.read_body
{
  "requestId": "e48eda63-928c-4155-bez9-fdbsaadc15f3",
  "webHookUrl": "https://example.tld/my-webhook"
}
{
  "problemDetail": {
    "type": "<string>",
    "title": "<string>",
    "status": 123,
    "detail": "<string>",
    "instance": "<string>",
    "properties": {}
  }
}

Authorizations

Authorization
string
header
required

IDM-issued JWT. Obtain via the IDM authentication flow and pass as: Bearer

Headers

X-ActionId
string

A logging ID of the request. It is propagated through Phrase systems, making it easier to connect logs from various services. If no ActionId is sent with a request, one will be generated by Bifrost and returned with the response.

X-ResponseType
string

Specify if the response should contain the processed object itself in an application/octet-stream body, or a application/json body with an ID that can be then used to retrieve the object using a /load-content endpoint. Note that for larger files (> 1 MB), it is advised to use the ID option which is also default.

X-Webhook
string
required

Required on /async/... endpoints. Bifrost POSTs the operation result to this URL once the connector finishes processing. Omitting this header on an async endpoint returns 400.

Body

application/json

Request body for converting already-stored raw Contentful content into XLIFF 2.0 without re-downloading from Contentful.

rawFiles
object[]
required

List of stored raw files (each carrying its storageId and original metadata) to convert.

sourceLocale
string
required

Source locale of the content (Contentful locale code).

Example:

"en-US"

Response

Successful operation. If X-ResponseType is set to 'ID' or no value is sent in the header, the file is saved and can be retrieved by sending a GET request to this endpoint. If X-ResponseType is set to 'OBJECT', the file is returned as a stream.

webhookUrl
string

Webhook URL you supplied in the request

requestId
string

Request ID you can use to retrieve the result