> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.ollang.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Content

> Import translation units into your content database

Import translation units (source text + target text pairs) into your content database. This is useful for bulk-loading translations from external systems, TMS exports, or programmatic workflows.

Imported content terms become immediately available in the [Content Management](/apis/ollang-api-reference/export-content) page and can be exported, tagged, and edited.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api-integration.ollang.com/integration/content/import" \
    -H "X-Api-Key: <your-api-key>" \
    -H "Content-Type: application/json" \
    -d '{
      "targetLanguage": "de",
      "translations": [
        { "sourceText": "Good morning", "targetText": "Guten Morgen" },
        { "sourceText": "Sign in", "targetText": "Anmelden" },
        { "sourceText": "Dashboard", "targetText": "Übersicht" }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api-integration.ollang.com/integration/content/import",
    {
      method: "POST",
      headers: {
        "X-Api-Key": "<your-api-key>",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        targetLanguage: "de",
        translations: [
          { sourceText: "Good morning", targetText: "Guten Morgen" },
          { sourceText: "Sign in", targetText: "Anmelden" },
          { sourceText: "Dashboard", targetText: "Übersicht" },
        ],
      }),
    },
  );

  const result = await response.json();
  // { success: true, imported: 3 }
  ```

  ```python Python theme={null}
  import requests

  data = {
      "targetLanguage": "de",
      "translations": [
          {"sourceText": "Good morning", "targetText": "Guten Morgen"},
          {"sourceText": "Sign in", "targetText": "Anmelden"},
          {"sourceText": "Dashboard", "targetText": "Übersicht"},
      ],
  }

  response = requests.post(
      "https://api-integration.ollang.com/integration/content/import",
      json=data,
      headers={"X-Api-Key": "<your-api-key>"},
  )

  result = response.json()
  ```

  ```php PHP theme={null}
  $data = [
      'targetLanguage' => 'de',
      'translations' => [
          ['sourceText' => 'Good morning', 'targetText' => 'Guten Morgen'],
          ['sourceText' => 'Sign in', 'targetText' => 'Anmelden'],
          ['sourceText' => 'Dashboard', 'targetText' => 'Übersicht'],
      ],
  ];

  $curl = curl_init();
  curl_setopt_array($curl, [
      CURLOPT_URL => 'https://api-integration.ollang.com/integration/content/import',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => [
          'X-Api-Key: <your-api-key>',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode($data),
  ]);

  $response = curl_exec($curl);
  curl_close($curl);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "net/http"
  )

  func main() {
      data := map[string]interface{}{
          "targetLanguage": "de",
          "translations": []map[string]string{
              {"sourceText": "Good morning", "targetText": "Guten Morgen"},
              {"sourceText": "Sign in", "targetText": "Anmelden"},
              {"sourceText": "Dashboard", "targetText": "Übersicht"},
          },
      }

      jsonData, _ := json.Marshal(data)

      req, _ := http.NewRequest("POST",
          "https://api-integration.ollang.com/integration/content/import",
          bytes.NewBuffer(jsonData))
      req.Header.Set("X-Api-Key", "<your-api-key>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      client.Do(req)
  }
  ```
</RequestExample>

## Authorizations

This endpoint requires API key authentication. Include your API key in the request header:

* **Header name**: `X-Api-Key`
* **Header value**: Your API key from the Ollang dashboard

## Body Parameters

<ParamField body="targetLanguage" type="string" required>
  The target language code for all translations in this import batch (e.g.,
  `de`, `fr`, `ja`). All translation units in the `translations` array must be
  in this language.
</ParamField>

<ParamField body="translations" type="array" required>
  Array of translation units to import. Each unit represents a source-target text pair.

  <Expandable title="Translation Unit Object">
    <ParamField body="sourceText" type="string" required>
      The original source text (key). This is used to match and deduplicate content terms across languages.
    </ParamField>

    <ParamField body="targetText" type="string" required>
      The translated text in the target language.
    </ParamField>

    <ParamField body="elementId" type="string">
      Optional element identifier for tracking the origin of this translation (e.g., a DOM element ID, a JSON key path, or a custom reference).
    </ParamField>

    <ParamField body="type" type="string" default="text">
      Content type classification. Common values: `text`, `ui`, `subtitle`, `navigation`. Defaults to `text`.
    </ParamField>
  </Expandable>
</ParamField>

## Behavior

* If a content term with the same `sourceText` already exists, a new target entry for the specified language is added (or the existing one is updated).
* If the `sourceText` does not exist, a new content term is created with the provided translation.
* Import is idempotent for the same `sourceText` + `targetLanguage` combination — re-importing updates the target text.

## Response

<ResponseField name="success" type="boolean">
  Whether the import completed successfully.
</ResponseField>

<ResponseField name="imported" type="number">
  The number of translation units that were processed.
</ResponseField>

<ResponseExample>
  ```json 201 theme={null}
  {
    "success": true,
    "imported": 3
  }
  ```

  ```json 400 theme={null}
  {
    "statusCode": 400,
    "message": [
      "targetLanguage should not be empty",
      "translations should not be empty"
    ],
    "error": "Bad Request"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Unauthorized",
    "message": "Invalid or missing API key",
    "code": "UNAUTHORIZED"
  }
  ```
</ResponseExample>
