# Welcome to Doctranslate.io

Globalize Knowledge

In a world teeming with diverse cultures, languages, and knowledge, the power of communication is unparalleled. Yet, a vast majority of the global population faces a formidable barrier: language. **With over 60% of the internet's content in English, an astounding 80% of the world's population is at a linguistic disadvantage, struggling to access a wealth of information and opportunities that remain just beyond their grasp**. This gap not only hinders personal growth and global understanding but also poses significant challenges for businesses and educational institutions aiming to reach a wider audience.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FVRW9XZ3w41T73lgKRp0T%2Fhero_section_updated_3011.gif?alt=media&amp;token=efddfea0-bef8-4ec1-b9f3-5e852e263493" alt=""><figcaption></figcaption></figure>

[DocTranslate.io](https://doctranslate.io/) is **committed to demolishing language barriers, thereby democratizing access to information**. Whether it's localizing content for a global audience, facilitating seamless international collaborations, or enriching educational resources with diverse perspectives, our API is your ally. In a world where knowledge is power, DocTranslate.io empowers you to share that power more equitably. Join us in our mission to globalize knowledge, making it accessible and inclusive for all, one translation at a time.

Recognizing the critical need to foster inclusivity and bridge the gaps that divide us, we introduce the **DocTranslate.io Translation API**. This pioneering technology is more than just a tool; it's a gateway to a more connected, accessible, and inclusive world. Designed with precision and ease of integration at its core, our API transcends traditional translation services. By leveraging cutting-edge machine learning models, it ensures that translations are not merely accurate but imbued with the nuance and context necessary for genuine understanding.


# What is DocTranslate.io

DocTranslate.io revolutionizes document translation, combining speed, accuracy, and cost-effectiveness. This powerful tool supports over **85 languages** and can handle various file types, including **Word, Excel, PDF, and PowerPoint**. Its advanced capabilities extend to translating **scanned PDFs and images within files**, maintaining original layouts and effortlessly translating embedded content. Leveraging AI, it offers professional-grade translations with customizable tone and domain options, perfect for diverse fields. Praised by users for its quality and support, DocTranslate.io stands as a vital tool for professionals across various industries, significantly reducing manual translation efforts and costs.

{% embed url="<https://youtu.be/BoAyvXeLpmM>" %}


# User Manual

You can find our user manual [here](https://usermanual.doctranslate.io/).


# System requirement

### API Endpoint

* **Version:** 1.0
* **API end point:**  [https://api-doc.doctranslate.io](https://api-doc.doctranslate.io/)

### API Token

To access the DocTranslate.io system and utilize its powerful Translation API, each **Business Accounts** are provided with a unique API token. This token serves as a key to unlock the API's capabilities, ensuring secure and authorized access.&#x20;

If you have not yet received your API key via email or encounter any issues with obtaining it, our dedicated support team is here to assist you. Please reach out to us via email at <support@doctranslate.io> for swift and personalized assistance. Our goal is to ensure that you have everything you need to seamlessly integrate our translation services into your operations, enabling you to globalize your content and knowledge effortlessly.


# Upload API

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/translate/document`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Body form-data Parameter**

| KEY                             | TYPE     | VALUE                                                                                                        |
| ------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| file                            | File     | Upload the document to be translated. Supported formats include `DOCX, PDF, PPTX, and XLSX.`                 |
| file\_type                      | String   | The type of the file being translated. Supported formats include `DOCX, PDF, PPTX, and XLSX`.                |
| original\_lang                  | String   | The original language of the content. Optional but recommended for better accuracy.                          |
| dest\_lang                      | String   | The target language for translation.                                                                         |
| process\_mode                   | String   | Describes how the file should be processed 'replace', 'append'.                                              |
| style\_mode                     | Interger | Specifies the styling preference for the translation output. Influences formatting and presentation.         |
| translate\_type                 | String   | Specifies the translation engine or version to be used.                                                      |
| is\_translate\_images           | Bool     | Flag indicating whether images within the document should also be translated.                                |
| tone                            | String   | Tone of the translation, if applicable                                                                       |
| domain                          | String   | The domain or field of the content, which can help in choosing specialized translation models.               |
| bilingual\_text\_style\_\_font  | String   | Optional custom font to be used for the translation, specifying word-level translations.                     |
| bilingual\_text\_style\_\_color | String   | Optional custom color to be used for the translation, specifying word-level translations.                    |
| dictionary                      | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="461">KEY</th><th>VALUE</th></tr></thead><tbody><tr><td>status_code</td><td>200</td></tr><tr><td>content</td><td>{ "data": { "task_id": "81812b70082840039e6a4baedd70e985" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td></tr><tr><td></td><td></td></tr></tbody></table>

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: Authencation** Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Upload multiple files and calculate usage cost

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/upload`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE   | VALUE                                                                                                                                     |
| -------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| task\_type     | String | Classifying tasks corresponding to each translation mode such as: `document`, `images`, `audio`, `video`, `summarization`, `create_video` |
| files          | String | List of input files                                                                                                                       |
| youtube\_link  | String | link youtube if using video translation mode for youtube                                                                                  |
| access\_domain | String | Not transmitted by default                                                                                                                |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| content      | { "data": \[ { "filename": "2.text\_image.pdf", "status": true, "credits": 4.92, "task\_id": "f911298671b240f5984060c62cbbb218", "size": "0.18 MB" }, { "filename": "5.text\_images.docx", "status": true, "credits": 2.89, "task\_id": "af60061f95c8439a9ee55971b37a7e06", "size": "0.3 MB" } ], "errors": \[], "error\_description": "", "start\_time": "2024-07-09 11:28:00.044402", "end\_time": "2024-07-09 11:28:08.825665", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# User API

#### &#x20;<a href="#http-request" id="http-request"></a>

| detail |   |
| ------ | - |


# User History

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/user/history`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Query Parameter**

| KEY        | TYPE    | VALUE                                                                                    |
| ---------- | ------- | ---------------------------------------------------------------------------------------- |
| page       | Integer | The page number to retrieve, for pagination. Must be greater than 0.                     |
| page\_size | Integer | The number of items to retrieve per page, for pagination. Must be greater than 0.        |
| keyword    | String  | A keyword to search for file name. Used to filter results based on a specific criterion. |
|            |         |                                                                                          |

**Body Payload**

| KEY         | TYPE   | VALUE                                                                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------- |
| start\_date | String | <p>The start time for the query. Should be in ISO 8601 format.<br>format: yyyy-mm-dd hh-mm-ss utc+7<br>ex: 2024-03-07 04:44:11</p> |
| end\_date   | String | <p>The end time for the query. Should be in ISO 8601 format.<br>format: yyyy-mm-dd hh-mm-ss utc+7<br>ex: 2024-03-07 15:44:11</p>   |
|             |        |                                                                                                                                    |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                                                                                                                                                                                                 |
| content      | { "data": \[ { "id": 26524, "file\_name": "5\_1709782940\_trial.docx", "url\_download": "\<translated\_file\_download\_URL>", "translation\_type": "Document", "datetime": "2024-03-07 04:44:11", "cost": 1, "credit": 1, "dest\_lang": "en", "share\_url": "" } ], "errors": \[], "error\_description": "", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Translation API


# API V1


# Document Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/translate/document`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

| KEY                             | TYPE     | VALUE                                                                                                                        |
| ------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
| file                            | File     | Upload the document to be translated. Supported formats include `DOCX, PDF, PPTX, and XLSX.`                                 |
| file\_type                      | String   | The type of the file being translated. Supported formats include `DOCX, PDF, PPTX, and XLSX`.                                |
| original\_lang                  | String   | The original language of the content. Optional but recommended for better accuracy.                                          |
| dest\_lang                      | String   | The target language for translation.                                                                                         |
| process\_mode                   | String   | Describes how the file should be processed 'replace', 'append'.                                                              |
| style\_mode                     | Interger | <p>Default: 0</p><p>Specifies the styling preference for the translation output. Influences formatting and presentation.</p> |
| translate\_type                 | String   | <p>Specifies the translation engine or version to be used.<br><code>Paraphrase</code>, <code>Professional</code></p>         |
| is\_translate\_images           | Bool     | Flag indicating whether images within the document should also be translated.                                                |
| tone                            | String   | Tone of the translation, if applicable                                                                                       |
| domain                          | String   | The domain or field of the content, which can help in choosing specialized translation models.                               |
| bilingual\_text\_style\_\_font  | String   | Used to set the font for the bilingual translation mode and when process\_mode=append                                        |
| bilingual\_text\_style\_\_color | String   | Used to set the color for the bilingual translation mode and when process\_mode=append                                       |
| dictionary                      | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.                |
| custom\_prompt                  | String   | Custom prompt to be used for the translation                                                                                 |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Translate Multiple Files (currently supports document, summarization)

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/process`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

<table><thead><tr><th>KEY</th><th>TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td>Classifying tasks corresponding to each translation mode such as: <code>document</code>, <code>images</code>, <code>audio</code>, <code>video</code>, <code>summarization</code>, <code>create_video</code></td></tr><tr><td>original_lang</td><td>String</td><td>The original language of the content. Optional but recommended for better accuracy.</td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td>process_mode</td><td>String</td><td>Describes how the file should be processed 'replace', 'append'.</td></tr><tr><td>translate_type</td><td>String</td><td>Specifies the translation engine or version to be used.<br><code>Paraphrase</code>, <code>Professional</code></td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    },
    {
        "filename": "5.text_images.docx",
        "status": true,
        "credits": 2.89,
        "task_id": "af60061f95c8439a9ee55971b37a7e06",
        "size": "0.3 MB"
    }
]
</code></pre></td></tr><tr><td>is_translate_images</td><td>Bool</td><td>Flag indicating whether images within the document should also be translated.</td></tr><tr><td>tone</td><td>String</td><td>Tone of the translation, if applicable</td></tr><tr><td>domain</td><td>String</td><td>The domain or field of the content, which can help in choosing specialized translation models.</td></tr><tr><td>bilingual_text_style__font</td><td>String</td><td>Used to set the font for the bilingual translation mode and when process_mode=append</td></tr><tr><td>bilingual_text_style__color</td><td>String</td><td>Used to set the color for the bilingual translation mode and when process_mode=append</td></tr><tr><td>dictionary</td><td>List</td><td><p>Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.</p><pre><code>Example: [
    {
       "ori_lang": "en",
       "des_lang": "vi"
       "ori_word": "hello",
       "des_word": "xin chào",
    },
    {
       "ori_lang": "en",
       "des_lang": "vi"
       "ori_word": "hi",
       "des_word": "chào",
    }]
</code></pre></td></tr><tr><td>custom_prompt</td><td>String</td><td>Custom prompt to be used for the translation</td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Image Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/translate/images`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE        | VALUE                                                                                                                        |
| -------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- |
| files          | list\[File] | List of image files for translation                                                                                          |
| original\_lang | String      | The original language of the content. Optional but recommended for better accuracy.                                          |
| dest\_lang     | String      | The target language for translation.                                                                                         |
| process\_mode  | String      | Describes how the file should be processed 'replace', 'append'.                                                              |
| style\_mode    | Interger    | <p>Default: 0</p><p>Specifies the styling preference for the translation output. Influences formatting and presentation.</p> |
| tone           | String      | Tone of the translation, if applicable                                                                                       |
| domain         | String      | The domain or field of the content, which can help in choosing specialized translation models.                               |
| font           | String      | Optional custom font to be used for the translation, specifying word-level translations.                                     |
| font\_size     | String      | Optional custom font size to be used for the translation, specifying word-level translations.                                |
| dictionary     | String      | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.                |
| custom\_prompt | String      | Custom prompt to be used for the translation                                                                                 |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Audio Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/translate/audio`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE        | VALUE                                                                                          |
| -------------- | ----------- | ---------------------------------------------------------------------------------------------- |
| files          | list\[File] | List of audio files for translation                                                            |
| source\_lang   | String      | Source language of the audio content.                                                          |
| dest\_lang     | String      | The target language for translation.                                                           |
| tone           | String      | Tone of the translation, if applicable                                                         |
| domain         | String      | The domain or field of the content, which can help in choosing specialized translation models. |
| custom\_prompt | String      | Custom prompt to be used for the translation                                                   |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Text Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/translate/text`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

### Body form-data

| KEY                                  | TYPE     | VALUE                                                                                                         |
| ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------- |
| text                                 | String   | Text to be translated                                                                                         |
| original\_lang                       | String   | The original language of the content. Optional but recommended for better accuracy.                           |
| dest\_lang                           | String   | The target language for translation.                                                                          |
| process\_mode                        | String   | Describes how the file should be processed 'replace', 'append'.                                               |
| style\_mode                          | Interger | Defines the styling mode for the translation output                                                           |
| translate\_type                      | String   | <p>Translate type to be used<br>"Paraphrase", "Professional", "Accurate"</p>                                  |
| tone                                 | String   | Tone of the translation, if applicable                                                                        |
| domain                               | String   | The domain or field of the content, which can help in choosing specialized translation models.                |
| bilingual\_text\_style\_\_font       | String   | Optional custom font to be used for the translation, specifying word-level translations.                      |
| bilingual\_text\_style\_\_font\_size | String   | Optional custom font size to be used for the translation, specifying word-level translations.                 |
| bilingual\_text\_style\_\_color      | String   | Optional custom color to be used for the translation, specifying word-level translations.                     |
| dictionary                           | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations. |
| custom\_prompt                       | String   | Custom prompt to be used for the translation                                                                  |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{ "data": { "task_id": "81812b70082840039e6a4baedd70e985" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{ "data": {}, "errors": [ "Error" ], "error_description": "Error while sending message. Please check server!", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# Get result

Get result translate by task id

#### HTTP request <a href="#http-request" id="http-request"></a>

GET `/v1/result/{task_id}`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Path Parameters**

| KEY       | TYPE   | VALUE                                  |
| --------- | ------ | -------------------------------------- |
| `task_id` | String | Provided when calling translation API. |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{ "data": { "percent": 100, "status": "done", "text": "Translating", "url_download": "https://www.google.com", "task_id": "401306de73194954830e3f3bb6642ed6" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{ "data": {}, "errors": [ "Error" ], "error_description": "Error while sending message. Please check server!", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# API V2


# Document Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/translate/document`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

| KEY                             | TYPE     | VALUE                                                                                                                        |
| ------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
| file                            | File     | Upload the document to be translated. Supported formats include `DOCX, PDF, PPTX, and XLSX.`                                 |
| file\_type                      | String   | The type of the file being translated. Supported formats include `DOCX, PDF, PPTX, and XLSX`.                                |
| original\_lang                  | String   | The original language of the content. Optional but recommended for better accuracy.                                          |
| dest\_lang                      | String   | The target language for translation.                                                                                         |
| process\_mode                   | String   | Describes how the file should be processed 'replace', 'append', 'append\_reverse' .                                          |
| style\_mode                     | Interger | <p>Default: 0</p><p>Specifies the styling preference for the translation output. Influences formatting and presentation.</p> |
| translate\_type                 | String   | <p>Specifies the translation engine or version to be used.<br><code>Paraphrase</code>, <code>Professional</code></p>         |
| is\_translate\_images           | Bool     | Flag indicating whether images within the document should also be translated.                                                |
| tone                            | String   | Tone of the translation, if applicable                                                                                       |
| domain                          | String   | The domain or field of the content, which can help in choosing specialized translation models.                               |
| bilingual\_text\_style\_\_font  | String   | Used to set the font for the bilingual translation mode and when process\_mode=append                                        |
| bilingual\_text\_style\_\_color | String   | Used to set the color for the bilingual translation mode and when process\_mode=append                                       |
| dictionary                      | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.                |
| custom\_prompt                  | String   | Custom prompt to be used for the translation                                                                                 |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Translate Multiple Files (currently supports document, summarization)

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/process`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

<table><thead><tr><th width="287">KEY</th><th width="119">TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td>Classifying tasks corresponding to each translation mode such as: <code>document</code>, <code>images</code>, <code>audio</code>, <code>video</code>, <code>summarization</code>, <code>create_video</code></td></tr><tr><td>original_lang</td><td>String</td><td>The original language of the content. Optional but recommended for better accuracy.</td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td>process_mode</td><td>String</td><td>Describes how the file should be processed 'replace', 'append', 'append_reverse' .</td></tr><tr><td>translate_type</td><td>String</td><td>Specifies the translation engine or version to be used.<br><code>Paraphrase</code>, <code>Professional</code></td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    },
    {
        "filename": "5.text_images.docx",
        "status": true,
        "credits": 2.89,
        "task_id": "af60061f95c8439a9ee55971b37a7e06",
        "size": "0.3 MB"
    }
]
</code></pre></td></tr><tr><td>is_translate_images</td><td>Bool</td><td>Flag indicating whether images within the document should also be translated.</td></tr><tr><td>tone</td><td>String</td><td>Tone of the translation, if applicable</td></tr><tr><td>domain_translate_document</td><td>String</td><td>The domain or field of the content for document, which can help in choosing specialized translation models.</td></tr><tr><td>domain_translate_image</td><td>String</td><td>The domain or field of the content for image, which can help in choosing specialized translation models.</td></tr><tr><td>domain_translate_audio</td><td>String</td><td>The domain or field of the content for audio, which can help in choosing specialized translation models.</td></tr><tr><td>domain_translate_video</td><td>String</td><td>The domain or field of the content video, which can help in choosing specialized translation models.</td></tr><tr><td>bilingual_text_style__font</td><td>String</td><td>Used to set the font for the bilingual translation mode and when process_mode=append</td></tr><tr><td>bilingual_text_style__color</td><td>String</td><td>Used to set the color for the bilingual translation mode and when process_mode=append</td></tr><tr><td>dictionary</td><td>List</td><td><p>Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.</p><pre><code>Example: [
    {
       "ori_lang": "en",
       "des_lang": "vi"
       "ori_word": "hello",
       "des_word": "xin chào",
    },
    {
       "ori_lang": "en",
       "des_lang": "vi"
       "ori_word": "hi",
       "des_word": "chào",
    }]
</code></pre></td></tr><tr><td>custom_prompt</td><td>String</td><td>Custom prompt to be used for the translation</td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Image Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/translate/images`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE        | VALUE                                                                                                                        |
| -------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- |
| files          | list\[File] | List of image files for translation                                                                                          |
| original\_lang | String      | The original language of the content. Optional but recommended for better accuracy.                                          |
| dest\_lang     | String      | The target language for translation.                                                                                         |
| process\_mode  | String      | Describes how the file should be processed 'replace', 'append'.                                                              |
| style\_mode    | Interger    | <p>Default: 0</p><p>Specifies the styling preference for the translation output. Influences formatting and presentation.</p> |
| domain         | String      | The new domain or field of the content, which can help in choosing specialized translation models.                           |
| font           | String      | Optional custom font to be used for the translation, specifying word-level translations.                                     |
| font\_size     | String      | Optional custom font size to be used for the translation, specifying word-level translations.                                |
| color          | String      | Optional custom color to be used for the translation, specifying word-level translations.                                    |
| dictionary     | String      | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.                |
| custom\_prompt | String      | Custom prompt to be used for the translation                                                                                 |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Audio Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/translate/audio`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE        | VALUE                                                                                                        |
| -------------- | ----------- | ------------------------------------------------------------------------------------------------------------ |
| files          | list\[File] | List of audio files for translation                                                                          |
| source\_lang   | String      | Source language of the audio content.                                                                        |
| dest\_lang     | String      | The target language for translation.                                                                         |
| process\_mode  | String      | Describes how the file should be processed 'replace', 'append', 'append\_reverse'.                           |
| domain         | String      | The new domain or field of the content for audio, which can help in choosing specialized translation models. |
| custom\_prompt | String      | Custom prompt to be used for the translation                                                                 |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Text Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/translate/text`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

### Body form-data

| KEY                                  | TYPE     | VALUE                                                                                                         |
| ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------- |
| text                                 | String   | Text to be translated                                                                                         |
| original\_lang                       | String   | The original language of the content. Optional but recommended for better accuracy.                           |
| dest\_lang                           | String   | The target language for translation.                                                                          |
| process\_mode                        | String   | Describes how the file should be processed 'replace', 'append', 'append\_reverse' .                           |
| style\_mode                          | Interger | Defines the styling mode for the translation output                                                           |
| translate\_type                      | String   | <p>Translate type to be used<br>"Paraphrase", "Professional".</p>                                             |
| tone                                 | String   | New tone of the translation, if applicable                                                                    |
| domain                               | String   | The new domain or field of the content, which can help in choosing specialized translation models.            |
| bilingual\_text\_style\_\_font       | String   | Optional custom font to be used for the translation, specifying word-level translations.                      |
| bilingual\_text\_style\_\_font\_size | String   | Optional custom font size to be used for the translation, specifying word-level translations.                 |
| bilingual\_text\_style\_\_color      | String   | Optional custom color to be used for the translation, specifying word-level translations.                     |
| dictionary                           | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations. |
| custom\_prompt                       | String   | Custom prompt to be used for the translation                                                                  |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{ "data": { "task_id": "81812b70082840039e6a4baedd70e985" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{ "data": {}, "errors": [ "Error" ], "error_description": "Error while sending message. Please check server!", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# Get result

Get result translate by task id

#### HTTP request <a href="#http-request" id="http-request"></a>

GET `/v1/result/{task_id}`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Path Parameters**

| KEY       | TYPE   | VALUE                                  |
| --------- | ------ | -------------------------------------- |
| `task_id` | String | Provided when calling translation API. |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{<br>"data": {<br>"7be10528f259430381daa6885bbb11a9": {<br>"task_id": "7be10528f259430381daa6885bbb11a9",<br>"url_download": "https://media.doctranslate.io/doctranslator-production/output/docx/test_truyen_16_en_1747902169.docx?X-Amz-Algorithm=AWS4-HMAC-SHA256&#x26;X-Amz-Credential=qa0e1UFJ0Trmajw8ttCM%2F20250522%2Fus-east-1%2Fs3%2Faws4_request&#x26;X-Amz-Date=20250522T084129Z&#x26;X-Amz-Expires=604800&#x26;X-Amz-SignedHeaders=host&#x26;X-Amz-Signature=b51064047dcc20dbf4bb237df6345d9d8148ac46cee071b852a480461edc84a1",<br>"type": "document",<br>"status": "done",<br>"file_name": "test_truyen_16_en_1747902169.docx",<br>"filename": null,<br>"cost": 0.54,<br>"dest_lang": "en",<br>"translation_type": "Document",<br>"datetime": "2025-05-22 15:41:29.098340"<br>},<br>"status": null<br>},<br>"errors": [],<br>"error_description": "",<br>"start_time": "2025-05-22 15:41:31.451406",<br>"end_time": "2025-05-22 15:41:31.451933",<br>"status": "success"<br>}</td><td></td></tr><tr><td>task_id (data/task_id)</td><td>Unique identifier for the translation task.</td><td></td></tr><tr><td>url_download (data/url_download)</td><td>URL to download the translated file.</td><td></td></tr><tr><td>type (data/type)</td><td>Type of translation.</td><td></td></tr><tr><td>status (data/status )</td><td>Current status of the task (e.g., <code>done</code>, <code>processing</code>, <code>failed</code>).</td><td></td></tr><tr><td>file_name (data/file_name )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>filename (data/filename )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>cost (data/cost )</td><td>Credit or cost consumed for the translation task.</td><td></td></tr><tr><td>dest_lang (data/dest_lang )</td><td>Destination language code (e.g., <code>en</code>, <code>ja</code>, <code>vi</code>).</td><td></td></tr><tr><td>translation_type (data/translation_type )</td><td>Type of translation service used.</td><td></td></tr><tr><td>start_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr><tr><td>end_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{<br>"data": {<br>"status": "failed",<br>"task_id": "7be10528f259430381daa6885bbb11a9",<br>"success": false,<br>"type": "fail_task",<br>"cost": 0,<br>"file_name": "test_truyen_16_1747902169.docx",<br>"filename": "test_truyen_16_1747902169.docx",<br>"dest_lang": "en",<br>"translation_type": "Document",<br>"datetime": "2025-05-22 15:23:14.637752"<br>},<br>"errors": [],<br>"error_description": "",<br>"start_time": "2025-05-22 15:52:06.087026",<br>"end_time": "2025-05-22 15:52:06.087519",<br>"status": "success"<br>}</td><td></td></tr><tr><td>task_id</td><td>Unique identifier for the translation task.</td><td></td></tr><tr><td>status (data/status )</td><td>Current status of the task (e.g., <code>done</code>, <code>processing</code>, <code>failed</code>).</td><td></td></tr><tr><td>type (data/type)</td><td>Type of translation.</td><td></td></tr><tr><td>cost (data/cost )</td><td>Credit or cost consumed for the translation task.</td><td></td></tr><tr><td>file_name (data/file_name )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>filename (data/filename )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>dest_lang (data/dest_lang )</td><td>Destination language code (e.g., <code>en</code>, <code>ja</code>, <code>vi</code>).</td><td></td></tr><tr><td>translation_type (data/translation_type )</td><td>Type of translation service used.</td><td></td></tr><tr><td>start_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr><tr><td>end_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# API V3


# Document Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v3/translate/document`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Request Body schema: multipart/form-data**

| KEY                             | TYPE     | VALUE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| file                            | File     | Upload the document to be translated. Supported formats include `DOCX, PDF, PPTX, and XLSX.`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| file\_type                      | String   | The type of the file being translated. Supported formats include `DOCX, PDF, PPTX, and XLSX`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| original\_lang                  | String   | The original language of the content. Optional but recommended for better accuracy.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| dest\_lang                      | String   | The target language for translation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| process\_mode                   | String   | Describes how the file should be processed 'replace', 'append', 'append\_reverse' .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| style\_mode                     | Interger | <p>Default: 0</p><p>Specifies the styling preference for the translation output. Influences formatting and presentation.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| translate\_type                 | String   | <p>Specifies the translation engine or version to be used.<br><code>Paraphrase</code>, <code>Professional</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| is\_translate\_images           | Bool     | Flag indicating whether images within the document should also be translated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| tone                            | String   | Tone of the translation, if applicable                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| domain                          | String   | The domain or field of the content, which can help in choosing specialized translation models.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| bilingual\_text\_style\_\_font  | String   | Used to set the font for the bilingual translation mode and when process\_mode=append                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| bilingual\_text\_style\_\_color | String   | Used to set the color for the bilingual translation mode and when process\_mode=append                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| dictionary                      | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| custom\_prompt                  | String   | Custom prompt to be used for the translation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| output\_format                  | String   | <p></p><h4>1. <strong>Scanned PDFs</strong></h4><p>These are image-based PDFs, typically from printed or photographed documents.</p><ul><li><strong>auto</strong>: Automatically selects the best format for readability. The translated text will follow the original content as closely as possible, but layout may vary.</li><li><strong>docx</strong>: Text is extracted and translated with a focus on preserving the original wording. Layout and formatting may not be retained.</li><li><strong>pptx</strong>: Not recommended unless the scanned file has a visual structure that benefits from slide-based formatting.</li></ul><h4>2. <strong>Regular PDFs</strong></h4><p>These contain selectable digital text and may include structured layouts or design elements.</p><ul><li><strong>auto</strong>: Automatically chooses between DOCX and PPTX to best preserve the original layout and formatting.</li><li><strong>docx</strong>: Suitable for text-based documents. May simplify layout while keeping the content intact.</li><li><strong>pptx</strong>: Best for visually rich documents (e.g., presentations, flyers). Maintains layout, formatting, and visual fidelity.</li></ul> |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Translate Multiple Files (currently supports document, summarization)

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v3/process`

**Authorization**

*OAuth2PasswordBearer***(***Bearer token or API key)*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Request Body schema: json data**

<table><thead><tr><th width="287">KEY</th><th width="119">TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td>Classifying tasks corresponding to each translation mode such as: <code>document</code>, <code>images</code>, <code>audio</code>, <code>video</code>, <code>summarization</code>, <code>create_video</code></td></tr><tr><td>original_lang</td><td>String</td><td>The original language of the content. Optional but recommended for better accuracy.</td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td>process_mode</td><td>String</td><td>Describes how the file should be processed 'replace', 'append', 'append_reverse' .</td></tr><tr><td>translate_type</td><td>String</td><td>Specifies the translation engine or version to be used.<br><code>Paraphrase</code>, <code>Professional</code></td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    },
    {
        "filename": "5.text_images.docx",
        "status": true,
        "credits": 2.89,
        "task_id": "af60061f95c8439a9ee55971b37a7e06",
        "size": "0.3 MB"
    }
]
</code></pre></td></tr><tr><td>is_translate_images</td><td>Bool</td><td>Flag indicating whether images within the document should also be translated.</td></tr><tr><td>tone</td><td>String</td><td>Tone of the translation, if applicable</td></tr><tr><td>domain_translate_document</td><td>String</td><td>The domain or field of the content for document, which can help in choosing specialized translation models.</td></tr><tr><td>domain_translate_image</td><td>String</td><td>The domain or field of the content for image, which can help in choosing specialized translation models.</td></tr><tr><td>domain_translate_audio</td><td>String</td><td>The domain or field of the content for audio, which can help in choosing specialized translation models.</td></tr><tr><td>domain_translate_video</td><td>String</td><td>The domain or field of the content video, which can help in choosing specialized translation models.</td></tr><tr><td>bilingual_text_style__font</td><td>String</td><td>Used to set the font for the bilingual translation mode and when process_mode=append</td></tr><tr><td>bilingual_text_style__color</td><td>String</td><td>Used to set the color for the bilingual translation mode and when process_mode=append</td></tr><tr><td>dictionary</td><td>List</td><td><p>Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations.</p><pre><code>Example: [
    {
       "ori_lang": "en",
       "des_lang": "vi"
       "ori_word": "hello",
       "des_word": "xin chào",
    },
    {
       "ori_lang": "en",
       "des_lang": "vi"
       "ori_word": "hi",
       "des_word": "chào",
    }]
</code></pre></td></tr><tr><td>custom_prompt</td><td>String</td><td>Custom prompt to be used for the translation</td></tr><tr><td>output_format</td><td>String</td><td><p></p><p></p><h4>1. <strong>Scanned PDFs</strong></h4><p>These are image-based PDFs, typically from printed or photographed documents.</p><ul><li><strong>auto</strong>: Automatically selects the best format for readability. The translated text will follow the original content as closely as possible, but layout may vary.</li><li><strong>docx</strong>: Text is extracted and translated with a focus on preserving the original wording. Layout and formatting may not be retained.</li><li><strong>pptx</strong>: Not recommended unless the scanned file has a visual structure that benefits from slide-based formatting.</li></ul><h4>2. <strong>Regular PDFs</strong></h4><p>These contain selectable digital text and may include structured layouts or design elements.</p><ul><li><strong>auto</strong>: Automatically chooses between DOCX and PPTX to best preserve the original layout and formatting.</li><li><strong>docx</strong>: Suitable for text-based documents. May simplify layout while keeping the content intact.</li><li><strong>pptx</strong>: Best for visually rich documents (e.g., presentations, flyers). Maintains layout, formatting, and visual fidelity.</li></ul></td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Audio Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v3/translate/audio`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE        | VALUE                                                                                                        |
| -------------- | ----------- | ------------------------------------------------------------------------------------------------------------ |
| files          | list\[File] | List of audio files for translation                                                                          |
| source\_lang   | String      | Source language of the audio content.                                                                        |
| dest\_lang     | String      | The target language for translation.                                                                         |
| process\_mode  | String      | Describes how the file should be processed 'replace', 'append', 'append\_reverse'.                           |
| domain         | String      | The new domain or field of the content for audio, which can help in choosing specialized translation models. |
| custom\_prompt | String      | Custom prompt to be used for the translation                                                                 |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Text Translation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v3/translate/text`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

### Body form-data

| KEY                                  | TYPE     | VALUE                                                                                                         |
| ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------- |
| text                                 | String   | Text to be translated                                                                                         |
| original\_lang                       | String   | The original language of the content. Optional but recommended for better accuracy.                           |
| dest\_lang                           | String   | The target language for translation.                                                                          |
| process\_mode                        | String   | Describes how the file should be processed 'replace', 'append', 'append\_reverse' .                           |
| style\_mode                          | Interger | Defines the styling mode for the translation output                                                           |
| translate\_type                      | String   | <p>Translate type to be used<br>"Paraphrase", "Professional".</p>                                             |
| tone                                 | String   | New tone of the translation, if applicable                                                                    |
| domain                               | String   | The new domain or field of the content, which can help in choosing specialized translation models.            |
| bilingual\_text\_style\_\_font       | String   | Optional custom font to be used for the translation, specifying word-level translations.                      |
| bilingual\_text\_style\_\_font\_size | String   | Optional custom font size to be used for the translation, specifying word-level translations.                 |
| bilingual\_text\_style\_\_color      | String   | Optional custom color to be used for the translation, specifying word-level translations.                     |
| dictionary                           | String   | Optional custom dictionary in JSON format to be used for the translation, specifying word-level translations. |
| custom\_prompt                       | String   | Custom prompt to be used for the translation                                                                  |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{ "data": { "task_id": "81812b70082840039e6a4baedd70e985" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{ "data": {}, "errors": [ "Error" ], "error_description": "Error while sending message. Please check server!", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# Get result

Get result translate by task id

#### HTTP request <a href="#http-request" id="http-request"></a>

GET `/v3/result/{task_id}`

**Authorization(***Bearer token or API key)*

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

Header API Key

```
X-API-Key: <your_api_key>
```

**Path Parameters**

| KEY       | TYPE   | VALUE                                  |
| --------- | ------ | -------------------------------------- |
| `task_id` | String | Provided when calling translation API. |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{<br>"data": {<br>"7be10528f259430381daa6885bbb11a9": {<br>"task_id": "7be10528f259430381daa6885bbb11a9",<br>"url_download": "https://media.doctranslate.io/doctranslator-production/output/docx/test_truyen_16_en_1747902169.docx?X-Amz-Algorithm=AWS4-HMAC-SHA256&#x26;X-Amz-Credential=qa0e1UFJ0Trmajw8ttCM%2F20250522%2Fus-east-1%2Fs3%2Faws4_request&#x26;X-Amz-Date=20250522T084129Z&#x26;X-Amz-Expires=604800&#x26;X-Amz-SignedHeaders=host&#x26;X-Amz-Signature=b51064047dcc20dbf4bb237df6345d9d8148ac46cee071b852a480461edc84a1",<br>"type": "document",<br>"status": "done",<br>"file_name": "test_truyen_16_en_1747902169.docx",<br>"filename": null,<br>"cost": 0.54,<br>"dest_lang": "en",<br>"translation_type": "Document",<br>"datetime": "2025-05-22 15:41:29.098340"<br>},<br>"status": null<br>},<br>"errors": [],<br>"error_description": "",<br>"start_time": "2025-05-22 15:41:31.451406",<br>"end_time": "2025-05-22 15:41:31.451933",<br>"status": "success"<br>}</td><td></td></tr><tr><td>task_id (data/task_id)</td><td>Unique identifier for the translation task.</td><td></td></tr><tr><td>url_download (data/url_download)</td><td>URL to download the translated file.</td><td></td></tr><tr><td>type (data/type)</td><td>Type of translation.</td><td></td></tr><tr><td>status (data/status )</td><td>Current status of the task (e.g., <code>done</code>, <code>processing</code>, <code>failed</code>).</td><td></td></tr><tr><td>file_name (data/file_name )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>filename (data/filename )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>cost (data/cost )</td><td>Credit or cost consumed for the translation task.</td><td></td></tr><tr><td>dest_lang (data/dest_lang )</td><td>Destination language code (e.g., <code>en</code>, <code>ja</code>, <code>vi</code>).</td><td></td></tr><tr><td>translation_type (data/translation_type )</td><td>Type of translation service used.</td><td></td></tr><tr><td>start_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr><tr><td>end_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{<br>"data": {<br>"status": "failed",<br>"task_id": "7be10528f259430381daa6885bbb11a9",<br>"success": false,<br>"type": "fail_task",<br>"cost": 0,<br>"file_name": "test_truyen_16_1747902169.docx",<br>"filename": "test_truyen_16_1747902169.docx",<br>"dest_lang": "en",<br>"translation_type": "Document",<br>"datetime": "2025-05-22 15:23:14.637752"<br>},<br>"errors": [],<br>"error_description": "",<br>"start_time": "2025-05-22 15:52:06.087026",<br>"end_time": "2025-05-22 15:52:06.087519",<br>"status": "success"<br>}</td><td></td></tr><tr><td>task_id</td><td>Unique identifier for the translation task.</td><td></td></tr><tr><td>status (data/status )</td><td>Current status of the task (e.g., <code>done</code>, <code>processing</code>, <code>failed</code>).</td><td></td></tr><tr><td>type (data/type)</td><td>Type of translation.</td><td></td></tr><tr><td>cost (data/cost )</td><td>Credit or cost consumed for the translation task.</td><td></td></tr><tr><td>file_name (data/file_name )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>filename (data/filename )</td><td>The name of the <strong>translated output file</strong>, including the file extension (e.g., <code>.docx</code>, <code>.pdf</code>, <code>.srt</code>). This is the actual filename users will download.</td><td></td></tr><tr><td>dest_lang (data/dest_lang )</td><td>Destination language code (e.g., <code>en</code>, <code>ja</code>, <code>vi</code>).</td><td></td></tr><tr><td>translation_type (data/translation_type )</td><td>Type of translation service used.</td><td></td></tr><tr><td>start_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr><tr><td>end_time</td><td>The timestamp when the translation task started, in <strong>Vietnam time (UTC+7, Asia/Ho_Chi_Minh)</strong>.</td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# Data Entry API

Auto-fill a template document with data extracted from one or more source files. **New** — v3-only (not part of the legacy contract). **Paid** (deducts credit per completed task).

* **Endpoint:** `POST /v3/data-entry` (`multipart/form-data`)
* **Base URL:** `https://doctranslate-api.doctranslate.io`
* **Auth:** header `X-API-Key: <key>` (or `Authorization: Bearer <key>`)

## What it does

Give it **source file(s)** to read data from plus a **template** (a DOCX, XLSX, or fillable PDF form). It extracts the relevant fields and returns a filled copy of the template. Async: you get a `task_id`, then poll `get_result`.

## Parameters

| Param           | Required | Type    | Meaning                                                                            |
| --------------- | :------: | ------- | ---------------------------------------------------------------------------------- |
| `files`         |     ✅    | file(s) | Source file(s) to extract data from (multipart field `files`, one or more).        |
| `template`      |    ⚠️    | file    | The form/template to fill. **Required unless `template_id` is given.**             |
| `template_id`   |    ⚠️    | integer | A template already saved on this account — an alternative to uploading `template`. |
| `target_lang`   |          | string  | Output language for the filled values.                                             |
| `domain`        |          | string  | Domain hint (exact enum string; a `422` lists valid values).                       |
| `custom_prompt` |          | string  | Extra extraction/fill instructions.                                                |
| `dictionary`    |          | string  | JSON-encoded dictionary array (term overrides).                                    |

## Response

* `200` → `{ "data": { "task_id": "..." } }` — queued. Poll `GET /v3/result/{task_id}` for the filled file's `url_download`.
* `401` invalid/missing key · `402` not enough credits · `404` `template_id` doesn't resolve · `422` bad/missing field (`detail[].loc`).

## Quick start (cURL)

```bash
# submit — fill template.docx using data read from source.pdf
curl -s https://doctranslate-api.doctranslate.io/v3/data-entry \
  -H "X-API-Key: dtl_xxx" \
  -F "files=@source.pdf" \
  -F "template=@template.docx" \
  -F "target_lang=en"
# -> { "data": { "task_id": "..." } }

# poll
curl -s https://doctranslate-api.doctranslate.io/v3/result/<task_id> \
  -H "X-API-Key: dtl_xxx"
# -> { "data": { "status": "success", "url_download": "https://..." } }
```


# Note Taker API

Turn a **meeting audio** recording into **structured meeting notes** (markdown + a DOCX). Two steps: audio → speaker dialog, then dialog → notes. **New** third-party feature.

> **Different base URL.** Note Taker is served by the main app, **not** the translation-file host: `https://www.doctranslate.io/api/v1/third-party/note-taker/…` — same `X-API-Key`. A bad key returns `401 INVALID_API_KEY`.

## Step 1 — Audio → dialog

* `POST /audio2dialog` (`multipart/form-data`, field `files` = the meeting audio) → returns a `task_id`.
* Poll `GET /audio2dialog/{task_id}` until `data.result.dialog_url` is set, then fetch that URL for the JSON speaker dialog.

## Step 2 — Dialog → meeting notes

* `POST /dialog2meeting` (send the dialog) → returns a `task_id`.
* Poll `GET /dialog2meeting/{task_id}` until `data.result` is set:
  * `data.result.markdown` — the notes as markdown
  * `data.result.docx_url` — a downloadable DOCX of the notes

## Quick start (cURL)

```bash
BASE=https://www.doctranslate.io/api/v1/third-party/note-taker

# 1) audio -> dialog
curl -s $BASE/audio2dialog -H "X-API-Key: dtl_xxx" -F "files=@meeting.mp3"
# -> { "data": { "task_id": "A" } }
curl -s $BASE/audio2dialog/A -H "X-API-Key: dtl_xxx"
# -> { "data": { "result": { "dialog_url": "https://..." } } }

# 2) dialog -> meeting notes
curl -s $BASE/dialog2meeting -H "X-API-Key: dtl_xxx" -d @dialog.json
# -> { "data": { "task_id": "B" } }
curl -s $BASE/dialog2meeting/B -H "X-API-Key: dtl_xxx"
# -> { "data": { "result": { "markdown": "# Meeting…", "docx_url": "https://..." } } }
```

## Notes

* Both steps are async (poll the matching `GET .../{task_id}`).
* Not included in the OpenAPI spec (different service) — call the base URL above directly.


# Presentation Maker API


# API  V1


# Presentation Maker

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/summarization`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

| KEY            | TYPE   | VALUE                                                                               |
| -------------- | ------ | ----------------------------------------------------------------------------------- |
| file           | File   | Upload the document to be translated. Supported formats include `DOCX, PDF.`        |
| file\_type     | String | The type of the file being translated. Supported formats include `DOCX, PDF`.       |
| dest\_lang     | String | The target language for translation.                                                |
| slides\_number | String | <p>The number of slides in the presentation.<br>Default: 10</p>                     |
| template\_path | String | <p>The path to the template file.<br>Default: <code>system/Template.pptx</code></p> |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

| detail |   |
| ------ | - |


# Presentation Maker For Multiple Files

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v1/process`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

<table><thead><tr><th width="270">KEY</th><th width="161">TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td><code>summarization</code></td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    },
    {
        "filename": "5.text_images.docx",
        "status": true,
        "credits": 2.89,
        "task_id": "af60061f95c8439a9ee55971b37a7e06",
        "size": "0.3 MB"
    }
]
</code></pre></td></tr><tr><td>slides_number</td><td>String</td><td>The number of slides in the presentation.<br>Default: <code>10</code></td></tr><tr><td>template_path</td><td>String</td><td>The path to the template file.<br>Default: <code>system/Template_7.pptx</code></td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# API V2


# Presentation Maker

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/summarization`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: multipart/form-data**

<table><thead><tr><th width="245">KEY</th><th width="130">TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>file</td><td>File</td><td>Upload the document to be translated. Supported formats include <code>DOCX, PDF.</code></td></tr><tr><td>file_type</td><td>String</td><td>The type of the file being translated. Supported formats include <code>DOCX, PDF</code>.</td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td>slides_number</td><td>String</td><td>The number of slides in the presentation.<br>Default: <code>10</code></td></tr><tr><td>is_image</td><td>Bool</td><td>Create/Search for more images<br>Default: <code>False</code></td></tr><tr><td>orientation</td><td>String</td><td>The orientation of the presentation.<br>Default: <code>presentation</code></td></tr><tr><td>template_path</td><td>String</td><td>The path to the template file.<br>Default: <code>system/New_templates/1.pptx</code></td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

| detail |   |
| ------ | - |


# Presentation Maker For Multiple Files

#### HTTP request <a href="#http-request" id="http-request"></a>

POST `/v2/process`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

<table><thead><tr><th width="270">KEY</th><th width="161">TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td><code>summarization</code></td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    },
    {
        "filename": "5.text_images.docx",
        "status": true,
        "credits": 2.89,
        "task_id": "af60061f95c8439a9ee55971b37a7e06",
        "size": "0.3 MB"
    }
]
</code></pre></td></tr><tr><td>orientation</td><td>String</td><td>The orientation of the presentation.<br>Default: <code>presentation</code></td></tr><tr><td>is_image</td><td>Bool</td><td>Create/Search for more images<br>Default: <code>False</code></td></tr><tr><td>slides_number</td><td>String</td><td>The number of slides in the presentation.<br>Default: <code>10</code></td></tr><tr><td>template_path</td><td>String</td><td>The path to the template file.<br>Default: <code>system/New_templates/1.pptx</code></td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Presentation Video API

#### &#x20;<a href="#http-request" id="http-request"></a>

| detail |   |
| ------ | - |


# API V1


# Create transcripts presentation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST  /v1/create/transcripts

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

<table><thead><tr><th>KEY</th><th>TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td> <code>create_video</code></td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    }
]
</code></pre></td></tr><tr><td>tone</td><td>String</td><td>Tone of the translation, if applicable</td></tr><tr><td>domain</td><td>String</td><td>The domain or field of the content, which can help in choosing specialized translation models.</td></tr><tr><td>custom_prompt</td><td>String</td><td>Custom prompt to be used for the translation</td></tr><tr><td>voice</td><td>String</td><td>The voice of the text-to-speech.<br>Enum: "james", "john" ,"william", "michael", "david", "emily"</td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Update transcripts presentation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST  /v1/update/transcripts

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

| KEY                               | TYPE     | VALUE                  |
| --------------------------------- | -------- | ---------------------- |
| task\_id                          | String   | task id                |
| transcript\_number                | interger | Transcript number      |
| <p></p><p>transcript\_content</p> | String   | New transcript content |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th>KEY</th><th>VALUE</th></tr></thead><tbody><tr><td>status_code</td><td>200</td></tr><tr><td>content</td><td><p></p><pre><code>{
    "status": True,
    "message": "Transcripts updated successfully"
}
</code></pre></td></tr></tbody></table>

**400:** Bad Request

<table><thead><tr><th>KEY</th><th>VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td><p></p><pre><code>{
    "status": False,
    "message": "Error while updating transcripts"
}
</code></pre></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Create video presentation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST  /v1/create/transcripts

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

| KEY        | TYPE   | VALUE            |
| ---------- | ------ | ---------------- |
| `task_ids` | String | List of task IDs |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Get result

Get result translate by task id

#### HTTP request <a href="#http-request" id="http-request"></a>

GET `/v1/result/{task_id}`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Path Parameters**

| KEY       | TYPE   | VALUE                                  |
| --------- | ------ | -------------------------------------- |
| `task_id` | String | Provided when calling translation API. |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{ "data": { "percent": 100, "status": "done", "text": "Translating", "url_download": "https://www.google.com", "task_id": "401306de73194954830e3f3bb6642ed6" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{ "data": {}, "errors": [ "Error" ], "error_description": "Error while sending message. Please check server!", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# API V2


# Create transcripts presentation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST  /v2/create/transcripts

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

<table><thead><tr><th>KEY</th><th>TYPE</th><th>VALUE</th></tr></thead><tbody><tr><td>task_type</td><td>String</td><td> <code>create_video</code></td></tr><tr><td>dest_lang</td><td>String</td><td>The target language for translation.</td></tr><tr><td><p></p><p>meta_files</p></td><td>String</td><td><p>The value is taken from the upload api<br></p><pre><code>Example: [
    {
        "filename": "2.text_image.pdf",
        "status": true,
        "credits": 4.92,
        "task_id": "f911298671b240f5984060c62cbbb218",
        "size": "0.18 MB"
    }
]
</code></pre></td></tr><tr><td>domain</td><td>String</td><td>The new domain or field of the content for video, which can help in choosing specialized creation models.</td></tr><tr><td>voice</td><td>String</td><td>The voice of the text-to-speech.<br>Enum: "james", "john" ,"william", "michael", "david", "emily"</td></tr><tr><td>custom_prompt</td><td>String</td><td>Custom prompt to be used for the translation</td></tr></tbody></table>

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Update transcripts presentation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST  /v2/update/transcripts

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

| KEY                               | TYPE     | VALUE                  |
| --------------------------------- | -------- | ---------------------- |
| task\_id                          | String   | task id                |
| transcript\_number                | interger | Transcript number      |
| <p></p><p>transcript\_content</p> | String   | New transcript content |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th>KEY</th><th>VALUE</th></tr></thead><tbody><tr><td>status_code</td><td>200</td></tr><tr><td>content</td><td><p></p><pre><code>{
    "status": True,
    "message": "Transcripts updated successfully"
}
</code></pre></td></tr></tbody></table>

**400:** Bad Request

<table><thead><tr><th>KEY</th><th>VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td><p></p><pre><code>{
    "status": False,
    "message": "Error while updating transcripts"
}
</code></pre></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Create video presentation

#### HTTP request <a href="#http-request" id="http-request"></a>

POST  /v2/create/video

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Request Body schema: json data**

| KEY        | TYPE   | VALUE            |
| ---------- | ------ | ---------------- |
| `task_ids` | String | List of task IDs |

**Response**

**200:** Success

Response schema: *application/json*

| KEY          | VALUE                                                                                                                                                                                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | 200                                                                                                                                                                                                                  |
| content      | { "data": { "task\_id": "0d05c89e6f2c472ab86b291516e8e466" }, "errors": \[], "error\_description": "", "start\_time": "2024-03-11 13:05:42.080757", "end\_time": "2024-03-11 13:05:42.348086", "status": "success" } |

**400:** Bad Request

| KEY          | VALUE                                                                                                                                                                                                   |   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| status\_code | 400                                                                                                                                                                                                     |   |
| content      | { "data": {}, "errors": \[ "Error" ], "error\_description": "Error while sending message. Please check server!", "start\_time": "yyyy-mm-dd hh-mm-ss utc+7", "end\_time": "yyyy-mm-dd hh-mm-ss utc+7" } |   |
|              |                                                                                                                                                                                                         |   |

**401: A**uthentication Error

| KEY          | VALUE                             |   |
| ------------ | --------------------------------- | - |
| status\_code | 401                               |   |
| content      | { "detail": "Not authenticated" } |   |
|              |                                   |   |

Response schema: *application/json*

| detail |   |
| ------ | - |


# Get result

Get result translate by task id

#### HTTP request <a href="#http-request" id="http-request"></a>

GET `/v2/result/{task_id}`

**Authorization**

*OAuth2PasswordBearer*

```
Authorization: OAuth2PasswordBearer
```

**Path Parameters**

| KEY       | TYPE   | VALUE                                  |
| --------- | ------ | -------------------------------------- |
| `task_id` | String | Provided when calling translation API. |

**Response**

**200:** Success

Response schema: *application/json*

<table><thead><tr><th width="316">KEY</th><th width="498">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>200</td><td></td></tr><tr><td>content</td><td>{ "data": { "percent": 100, "status": "done", "text": "Translating", "url_download": "https://www.google.com", "task_id": "401306de73194954830e3f3bb6642ed6" }, "errors": [], "error_description": "", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**400:** Bad Request\
Response schema: *application/json*

<table><thead><tr><th width="245">KEY</th><th width="377">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>400</td><td></td></tr><tr><td>content</td><td>{ "data": {}, "errors": [ "Error" ], "error_description": "Error while sending message. Please check server!", "start_time": "yyyy-mm-dd hh-mm-ss utc+7", "end_time": "yyyy-mm-dd hh-mm-ss utc+7" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**401: A**uthentication Error

Response schema: *application/json*

<table><thead><tr><th width="286">KEY</th><th width="524">VALUE</th><th></th></tr></thead><tbody><tr><td>status_code</td><td>401</td><td></td></tr><tr><td>content</td><td>{ "detail": "Not authenticated" }</td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>


# Api Key

#### How to Create API Key

To get started with DocTranslate MCP Server, you need to create an API key by following these steps:

**Step 1:** Visit [doctranslate.io/manage-api-key](https://doctranslate.io/manage-api-key)<br>

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FC6sqw4FKEdPnZLnL4uv6%2FStep%201.png?alt=media&amp;token=2d27cf1d-16fa-4e9c-8985-af5818fb4bd7" alt=""><figcaption></figcaption></figure>

**Notice:** To generate an API key on Doctranslate, you must be the owner or an administrator of a Team Subscription plan !!!

**Step 2:** Click "Create API Key" button

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FM63xCntUg5pCJLfR6GRg%2Fstep2-create-api-key-button.png?alt=media&amp;token=62601cc3-60eb-47f4-8f8c-88201aac96a3" alt=""><figcaption></figcaption></figure>

**Step 3:** Copy the generated API Key for use in your configuration

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FLTbzH5Z0baK9sRHWp0cY%2Fstep3-copy-api-key.png?alt=media&amp;token=ddc79691-2edf-4651-9ad5-a12a95f1237d" alt=""><figcaption></figcaption></figure>


# MCP (Model Context Protocol)


# V1

Doctranslate.io MCP Server is a Model Context Protocol (MCP) server that provides document translation, text translation, and slide creation services through API. The server supports multilingual


# Setup

## Setting Up Doctranslate.io MCP Server

There are two methods to set up and use the Doctranslate.io  MCP Server:

1. Self-hosted setup using our GitHub repository
2. Using our hosted MCP service

### Method 1: Self-Hosted Setup

#### System Requirements

* Python >= 3.10
* pip (Python package manager)
* Docker & Docker Compose (optional)

#### Installation Steps

1. **Clone repository:**

```bash
git clone https://github.com/thinkprompt/doctranslateio-mcp.git
cd doctranslateio-mcp
```

2. **Create virtual environment:**

```bash
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or
venv\Scripts\activate  # Windows
```

3. **Install dependencies:**

```bash
pip install -r requirements.txt
```

#### Running the Server

**Direct execution:**

```bash
python main.py
```

**With uvicorn:**

```bash
uvicorn main:server --host 0.0.0.0 --port 8000 --reload
```

**With Docker:**

```bash
docker-compose up -d
```

Your server will be running at: `http://localhost:8000`

### Method 2: Using Our Hosted Service

#### Quick Setup

Instead of setting up your own server, you can use our hosted MCP service. Simply use the following production URL in your configuration:

**Production URL**: [`https://mcp.doctranslate.io`](https://mcp.doctranslate.io)

#### Authentication

Before you can start using the service, you'll need a valid API key. You can find instructions on how to obtain one [here](https://developer.doctranslate.io/api-key)

#### Integration Methods

**1. Cursor Integration**

**Step 1: Configure MCP Tool in Cursor**

1. Open Cursor Settings and find Tools and Integrations
2. Click "Add a custom MCP Server"

**Step 2: Add Configuration**

**Using Headers:**

```json
{
  "mcpServers": {
    "doctranslate-mcp-server": {
      "url": "https://mcp.doctranslate.io/mcp",
      "type": "streamable-http",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}
```

**2. Claude Desktop Integration**

**Step 1: Configure claude\_desktop\_config.json**

1. Open Claude Desktop
2. Go to **Claude > Settings > Developer > Edit Config**
3. Add the following configuration:

```json
{
  "mcpServers": {
    "mcp-server-doctranslate": {
      "url": "https://mcp.doctranslate.io/mcp",
      "type": "streamable-http",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}
```

**Step 2: Restart Claude Desktop**

After saving the configuration, restart Claude Desktop to apply changes.

**3. Python Code Integration**

**Installation:**

```bash
pip install langchain_mcp_adapters
```

**Basic Usage:**

```python
from langchain_mcp_adapters.client import MultiServerMCPClient
import asyncio

# Initialize MCP client
client = MultiServerMCPClient(
    {
        "doctranslate": {
            "transport": "streamable_http",
            "url": "https://mcp.doctranslate.io/mcp",
            "headers": {
              "X-API-Key": "YOUR_API_KEY"
            }
        },
    }
)

# Get available tools asynchronously
tools = asyncio.run(client.get_tools())
print("Available tools:", tools)
```

### Available Tools

The MCP Server provides the following tools:

* create\_upload - Get a presigned URL to upload a file before calling translate, data\_entry, or pdf\_tool
* translate\_text - Translate a plain text string (free); returns a task\_id, then poll get\_result
* translate\_document - Translate an uploaded document (PDF, DOCX, PPTX, XLSX)
* translate\_image - Translate text in an image or scanned PDF via OCR (paid); returns a task\_id
* translate\_media - Translate an uploaded audio or video file (subtitles/transcript)
* pdf\_tool - Run a tool from the PDF Tools / PDF Formatter suite
* data\_entry - Fill a template (DOCX/XLSX/fillable PDF) with data extracted from source files
* get\_result - Poll the status/result of a task\_id returned by the translate\_\* tools

### Documentation & Support

For detailed API documentation and implementation guides:

* **Official Documentation**: <https://developer.doctranslate.io/document-translation-api/translation-api/api-v3>
* **Interactive API Docs**: <https://api-doc.doctranslate.io/>
* **Contact Form**: <https://doctranslate.io/en/contact>
* **Email Support**: <support@doctranslate.io>


# Trados

Doctranslate.io × Trados Studio 2024 — Installation Guide


# Installation Guide

This document explains how to install and connect the Doctranslate.io Plugin for Trados Studio 2024 (Studio18). The plugin is only compatible with Trados Studio 2024.

### 1. Download the Plugin

Download the official plugin file here:

👉 [Download Doctranslate.io Plugin for Trados 2024](https://media.doctranslate.io/doctranslate-public/resources/trados/plugin/DoctranslateXTrados2024.sdlplugin)

> *Note:* If your browser blocks the `.sdlplugin` file, click **Keep** or **Allow Download**.

***

### 2. Install the Plugin (recommended method)

#### Step 1 — Double-click the `.sdlplugin` file

After downloading, **double-click** the file `DoctranslateXTrados2024.sdlplugin`.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FWXrQv1dFDxNwkfOJgSsJ%2Fimage.png?alt=media&amp;token=3c5a6aee-bc4b-4b2b-b56b-af786217e4ee" alt="" width="492"><figcaption></figcaption></figure>

#### Step 2 — Run the installer

The **SDL Plugin Installer** will open. Click **Next** to begin installation, then click **Finish** to complete the installation.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FZEPyy3XRmd05HDTm3WtL%2F2.png?alt=media&amp;token=ce573ec8-7227-42e7-a4c0-a9bf8ba6d87e" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2F3Zbr9QDSrM8IduowbcFT%2F3.png?alt=media&amp;token=b307db1b-e218-46c0-97e5-2b01505156dc" alt="" width="563"><figcaption></figcaption></figure>

***

### 3. Verify the Plugin in Trados

#### Step 3 — Launch Trados Studio

When launching Trados, you may be prompted to **load the plugin**. Choose **Yes** to load the plugin into Trados.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FM3gwPrlxJEcWD8vCJzUj%2F4.png?alt=media&amp;token=4520c793-7d49-440e-b450-81ef73b1a8e2" alt=""><figcaption></figcaption></figure>

Then click on **Add-Ins**, followed by **Plug-ins**, to check that **Doctranslate.io** has been successfully integrated into Trados.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FhXrJBwwYWdJZUGNDJHJ2%2F5.png?alt=media&amp;token=bb45f73a-ba83-4bd8-acb8-2eec99a1cf4c" alt="" width="563"><figcaption></figcaption></figure>

***

### 4. Manual Installation (alternative method)

If the automatic installation fails, you can install the plugin manually.

#### Step 1 — Close Trados Studio

#### Step 2 — Copy the `.sdlplugin` file into the following folder:

```
%AppData%\Trados\Trados Studio\18\Plugins\Packages
```

If the plugin still doesn’t appear after restarting Trados, copy the same file into:

```
%AppData%\Trados\Trados Studio\18\Plugins\Installed
```

#### Step 3 — Reopen Trados Studio and verify it in **Plug-ins**.

***

### 5. Connect the Plugin to Your Doctranslate.io Account

#### Step 1 — Generate an API Key

Visit your Doctranslate account to create or retrieve your API key:\
👉 <https://doctranslate.io/manage-api-key>

Need help? See the detailed guide here:\
👉 <https://developer.doctranslate.io/api-key>

#### Step 2 — Connect the API Key in Trados

* Open **Trados Studio**.
* Click on **Home**, then click **Project Settings**, and afterwards click on **Use...**

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2Ff1j5gH1dyKzqmhUDP8vk%2F6.png?alt=media&amp;token=92214475-46c1-4671-8061-2682a9eb4c12" alt="" width="563"><figcaption></figcaption></figure>

* Click **Use...**, then select `Doctranslate.io Translator Provider` from the list.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FROShZXSHCXjLwCpfKlVv%2F7.png?alt=media&amp;token=a77b58d0-d856-4aed-bb46-939749115629" alt="" width="563"><figcaption></figcaption></figure>

* Click on `Doctranslate.io API Key`, then enter the API Key obtained from **Step 1**. After that, click `Connect`, and finally click `Finish` to complete setting up the plugin in your project.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FUmdSlepzsbYlc493YbL2%2F8.png?alt=media&amp;token=057d74ab-692b-4da9-81b1-e7a44867296b" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FTCCcOYfPMCYIu2gsMk45%2F9.png?alt=media&amp;token=fb26e77e-a17b-413c-a64e-7912de674abc" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FT51OxpYs07IQJVDSJOnI%2F10.png?alt=media&amp;token=204af8c1-6979-41f3-bd98-936a212517c8" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FOoCu4MDcNz07XZi0Bj21%2F11.png?alt=media&amp;token=c073ea9a-9086-48a7-8cf3-3d5c1d91b90c" alt="" width="563"><figcaption></figcaption></figure>

***

### 6. Test the Plugin

#### Step 1 — Add the Plugin to Your Trados Project

See Section 5 – Connect the Plugin to Your Doctranslate.io Account.

#### Step 2 — Open a file and test

Open a translation file in the **Editor** view. When you select a source segment, translation suggestions from Doctranslate should appear in the **Translation Results** panel.

If translations appear, your plugin is working correctly.

<figure><img src="https://737377980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjQFDg26ZHcDOKXpuczrM%2Fuploads%2FHdL6mlr74nKYhG2YcwPy%2F12.png?alt=media&amp;token=4a161311-c70b-46af-a476-b206a7746003" alt="" width="563"><figcaption></figcaption></figure>

***

#### ✅ Done

You have successfully installed and connected the **Doctranslate.io Plugin** for **Trados Studio 2024**.

If you encounter any issues or need support:

* Email: [**support@doctranslate.io**](mailto:support@doctranslate.io)
* Contact form: <https://doctranslate.io/en/contact>
* Technical documentation: [https://developer.doctranslate.io](https://developer.doctranslate.io/)

***

> ⚠️ **Compatibility Notice:** This plugin is **only supported on Trados Studio 2024 (Studio18)**. It will not work on earlier versions such as 2021 or 2022.


# Code examples


# API V1


# Upload Multiple Files

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v1/process"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# File paths
input_file_path = ['/data/example.docx', '/data/example_2.docx']  # Input file path

# UPLOAD FILE PART
TASK_TYPE = 'document'

form_data = {
    'task_type': TASK_TYPE,
}

# add files to the form data
files = [('files', open(file_path, 'rb')) for file_path in input_file_paths]

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data, files=files,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')
```


# Translate Multiple Document Files

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v1/process"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# File paths
input_file_paths = ['/data/example.docx', '/data/example_2.docx']  # Input file path

# UPLOAD FILE PART
TASK_TYPE = 'document'

form_data = {
    'task_type': TASK_TYPE,
}

# add files to the form data
files = [('files', open(file_path, 'rb')) for file_path in input_file_paths]

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data, files=files,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# TRANSLATE DOCUMENT PART
# Translation settings
original_language = None  # Automatically detect language if not specified
destination_language = 'vi'
process_mode = 'append'
translate_type = 'Professional'
publish_api = True
dictionary = [{"ori_word": "Hello", "des_word": "Chào mừng", "des_lang": "en", "ori_lang": "vi"},
                   {"ori_word": "You", "des_word": "Cậu", "des_lang": "en", "ori_lang": "vi"}]
custom_prompt = None    # Edit the translation as desired. For example, 'Uppercase the nouns in the text.'

# Corrected variable names according to their declaration at the top
json_data = {
    'task_type': TASK_TYPE,
    'dest_lang': destination_language,
    'process_mode': process_mode,
    'translate_type': translate_type,
    'is_translate_images': False,
    'bilingual_text_style__font': 'Helvetica',
    'bilingual_text_style__color': '#96d35f',
    'meta_files': meta_files,
    "dictionary": dictionary,
    'custom_prompt': custom_prompt
}

# Corrected file upload part to match the expected key 'file' in the API
try:
    response = requests.post(TRANSLATE_DOCUMENT_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {}).get('task_id')

    if parent_task_id:
        print(f'Parent Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'parent_task_id' not in locals():
    print('Error: missing parent_task_id')
    exit()

timeout = 600  # 10 minutes
start_time = datetime.datetime.now()
url_download = ''

printed_tasks = set()  # Set to store printed task_ids

while True:
    if (datetime.datetime.now() - start_time).seconds >= timeout:
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(f"{GET_RESULT_ENDPOINT}{parent_task_id}", headers=headers)
        response.raise_for_status()  # Ensure HTTP request success
        response_data = response.json()

        # Check all tasks in response
        results = response_data.get('data', {})

        for task_id, result in results.items():
            if isinstance(result, dict) and result.get('status') == 'done' and task_id not in printed_tasks:
                url_download = result.get('url_download')
                if url_download:
                    print(f"URL Download file {result.get('filename')}: {url_download}")
                    printed_tasks.add(task_id)  # Mark this task_id as printed

        # Stop checking if all tasks have been printed
        if len(printed_tasks) == len(results) - 1:  # Ignore the "status": null key
            break

    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Avoid overloading the server

if not url_download:
    print('Error: missing URL for download.')
```


# Text Translation

```python
import requests
import datetime
from time import sleep
import json

# Endpoints
BASE_URL = "https://doctranslate-api.doctranslate.io"
BE_TRANSLATE_URL = f"{BASE_URL}/v1/translate/text"
BE_GET_RESULT_URL = f"{BASE_URL}/v1/result/"
DEST_LANG = 'vi'

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

TEXT = "Hello, my name is Thanh. I am a software engineer."

DICTIONARY = json.dumps(
[
    {
        "ori_lang": "en",
        "des_lang": "vi",
        "ori_word": "hello",
        "des_word": "Tạm biệt",
    },
    {
        "ori_lang": "en",
        "des_lang": "vi",
        "ori_word": "I",
        "des_word": "Tớ",
    },
])

# Function to post translation request
def post_translation(text, dest_lang, token):
    form_data = {
        'original_lang': None,  # Assuming server handles 'None' as auto-detect
        'dest_lang': dest_lang,
        'process_mode': 'replace',
        'translate_type': 'Professional',
        'text': text,
        'dictionary': DICTIONARY
    }
    headers = {'Authorization': f'Bearer {token}'}
    response = requests.post(BE_TRANSLATE_URL, data=form_data, headers=headers)
    return response.json()

# Function to check translation result
def check_translation(task_id, token, timeout=600):
    start_time = datetime.datetime.now()
    while (datetime.datetime.now() - start_time).seconds < timeout:
        response = requests.get(f"{BE_GET_RESULT_URL}{task_id}", headers={'Authorization': f'Bearer {token}'})
        response_data = response.json()
        if response_data['status'] == 'success' and 'data' in response_data and 'url_download' in response_data['data'] and response_data['data']['url_download'] != '':
            return response_data['data']
        sleep(5)
    return None

# Main execution
response_data = post_translation(TEXT, DEST_LANG, auth_token )
if response_data['status'] == 'success':
    task_id = response_data['data']['task_id']
    print(f'Task ID: {task_id}')
    result_data = check_translation(task_id, auth_token)
    if result_data and 'url_download' in result_data:
        print(f"URL Download: {result_data['url_download']}")
        print(f"\nText: {result_data['text']}")
    else:
        print('Error: No download URL found within the given timeout.')
else:
    print('Error: Failed to initiate translation task. Please check your request and try again.')


```


# Document Translation

```python
import requests
import datetime
import time

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v1/translate/document"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
CONTENT_TYPE = 'application/docx'

# Translation settings
original_language = None  # Automatically detect language if not specified
destination_language = 'ja'
process_mode = 'append'
translate_type = 'Professional'
publish_api = True

# File paths
input_file_path = '/data/example.docx'  # Input file path
output_folder_path = '/data/translated/'  # Output folder path

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Corrected variable names according to their declaration at the top
form_data = {
    'file_type': CONTENT_TYPE,
    'original_lang': original_language,
    'dest_lang': destination_language,
    'process_mode': process_mode,
    'translate_type': translate_type,
    'bilingual_text_style__font': 'Helvetica',
    'bilingual_text_style__color': '#96d35f'
}

headers = {'Authorization': f'Bearer {auth_token}'}

# Corrected file upload part to match the expected key 'file' in the API
with open(input_file_path, 'rb') as file_to_translate:
    try:
        response = requests.post(TRANSLATE_DOCUMENT_URL, data=form_data, files={'file': file_to_translate}, headers=headers)
        response.raise_for_status()  # Proper error handling
        
        response_data = response.json()
        task_id = response_data.get('data', {}).get('task_id')
        
        if task_id:
            print(f'Task ID: {task_id}')
        else:
            print('Failed to get the task ID from the response.')
    except requests.exceptions.RequestException as e:
        print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'task_id' not in locals():
    print('Error: missing task_id')
    exit()

start_time = datetime.datetime.now()
url_download = ''

while True:
    if (datetime.datetime.now() - start_time).seconds >= 600:  # 10 minutes timeout
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(GET_RESULT_ENDPOINT + task_id, headers=headers)  # Use GET and append task_id to URL
        
        response_data = response.json()
        if response_data.get('status') == 'success' and response_data.get('data', {}).get('status') == 'done':
            url_download = response_data['data']['url_download']
            print(f'URL Download: {url_download}')
            break
    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Wait before the next check to avoid flooding the server

if not url_download:
    print('Error: missing URL for download.')

```


# Image Translation

```python
import datetime
import requests
from time import sleep

# Endpoints
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_IMAGES_ENDPOINT = f"{BASE_URL}/v1/translate/images"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"

# Configuration variables for the request
ORIGINAL_LANG = None  # It's better to use `None` explicitly if a value is optional
DEST_LANG = 'vi'
PROCESS_MODE = 'replace'
TRANSLATE_TYPE = 'Professional'
FILE_PATH = '/path/to/your/file.jpg'  # Use a generic path or explain how to set this
OUTPUT_FOLDER = '/path/to/output/folder/'

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Organize your script into functions to improve readability and reusability
def upload_file_for_translation(file_path, token):
    form_data = {
        'original_lang': ORIGINAL_LANG,
        'dest_lang': DEST_LANG,
        'process_mode': PROCESS_MODE,
        'translate_type': TRANSLATE_TYPE
    }
    
    with open(file_path, 'rb') as file:
        files = {'files': file}
        headers = {'Authorization': f'Bearer {token}'}
        response = requests.post(TRANSLATE_IMAGES_ENDPOINT, data=form_data, files=files, headers=headers)
    return response.json()

def check_translation_status(task_id, token):
    start_time = datetime.datetime.now()
    timeout = 60 * 10  # 10 minutes
    while True:
        elapsed_time = datetime.datetime.now() - start_time
        if elapsed_time.seconds >= timeout:
            print('Error: Process timed out')
            return None

        headers = {'Authorization': f'Bearer {token}'}
        response = requests.get(f"{GET_RESULT_ENDPOINT}{task_id}", headers=headers)
        response_data = response.json()

        if response_data.get('status') == 'success' and response_data.get('data', {}).get('status') == 'done':
            return response_data['data']['url_download']
        sleep(5)

def download_file(url_download, output_folder):
    response = requests.get(url_download)
    filename = url_download.split('/')[-1].split('?')[0]
    output_file_path = f"{output_folder}{filename}"
    with open(output_file_path, 'wb') as file:
        file.write(response.content)
    return output_file_path

# Main execution flow
response_data = upload_file_for_translation(FILE_PATH, auth_token)
if response_data['status'] == 'success':
    task_id = response_data['data']['task_id']
    print(f'Task ID: {task_id}')
    url_download = check_translation_status(task_id, auth_token)
    if url_download:
        output_file = download_file(url_download, OUTPUT_FOLDER)
        print(f'Downloaded file: {output_file}')
    else:
        print('Error: missing url_download')
else:
    print('Error: Failed to initiate translation task')

```


# Audio Translation

```python
import datetime
import requests
from time import sleep

# Endpoints
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_IMAGES_ENDPOINT = f"{BASE_URL}/v1/translate/audio"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"

# Configuration variables for the request
SOURCE_LANG = 'vi'
DEST_LANG = 'vi'
FILE_PATH = '/path/to/your/file.mp3'  # Use a generic path or explain how to set this
OUTPUT_FOLDER = '/path/to/output/folder/'

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Organize your script into functions to improve readability and reusability
def upload_file_for_translation(file_path, token):
    form_data = {
        'source_lang': SOURCE_LANG,
        'dest_lang': DEST_LANG
    }
    
    with open(file_path, 'rb') as file:
        files = {'files': file}
        headers = {'Authorization': f'Bearer {token}'}
        response = requests.post(TRANSLATE_IMAGES_ENDPOINT, data=form_data, files=files, headers=headers)
    return response.json()

def check_translation_status(task_id, token):
    start_time = datetime.datetime.now()
    timeout = 60 * 10  # 10 minutes
    while True:
        elapsed_time = datetime.datetime.now() - start_time
        if elapsed_time.seconds >= timeout:
            print('Error: Process timed out')
            return None, None

        headers = {'Authorization': f'Bearer {token}'}
        response = requests.get(f"{GET_RESULT_ENDPOINT}{task_id}", headers=headers)
        response_data = response.json()

        if response_data.get('status') == 'success' and response_data.get('data', {}).get('status') == 'done':
            return response_data['data']['transcript_urls'], response_data['data']['translated_transcribe_urls']
        sleep(5)

def download_file(url_download, output_folder, filename):
    response = requests.get(url_download)
    _filename = url_download.split('/')[-1].split('?')[0]
    output_file_path = f"{output_folder}{filename}-{_filename}"
    with open(output_file_path, 'wb') as file:
        file.write(response.content)
    return output_file_path

# Main execution flow
response_data = upload_file_for_translation(FILE_PATH, auth_token)
if response_data['status'] == 'success':
    task_id = response_data['data']['task_id']
    print(f'Task ID: {task_id}')
    transcript_urls,translated_transcribe_urls = check_translation_status(task_id, auth_token)
    if transcript_urls and translated_transcribe_urls:
        transcript_file = download_file(transcript_urls, OUTPUT_FOLDER, 'transcript')
        translated_transcribe_file = download_file(translated_transcribe_urls, OUTPUT_FOLDER, 'translated')
        print(f'Transcript file: {transcript_file}')
        print(f'Translated file: {translated_transcribe_file}')
    else:
        print('Error: missing url_download')
else:
    print('Error: Failed to initiate translation task')

```


# Video Translation

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v1/process"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# Youtube link
youtube_link = "<YOUR_LINK>"

# UPLOAD FILE PART
TASK_TYPE = 'video'

form_data = {
    'task_type': TASK_TYPE,
    'youtube_link': youtube_link
}

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# TRANSLATE PART
# Translation settings
original_language = 'en'  # Automatically detect language if not specified
destination_language = 'vi'
process_mode = 'append'
translate_type = 'Professional'
publish_api = True
dictionary_data = [{"ori_word": "Hello", "des_word": "Chào mừng", "des_lang": "en", "ori_lang": "vi"},
                   {"ori_word": "You", "des_word": "Cậu", "des_lang": "en", "ori_lang": "vi"}]
custom_prompt = None    # Edit the translation as desired. For example, 'Uppercase the nouns in the text.'

# Corrected variable names according to their declaration at the top
json_data = {
    'task_type': TASK_TYPE,
    'dest_lang': destination_language,
    'process_mode': process_mode,
    'translate_type': translate_type,
    'is_translate_images': False,
    'meta_files': meta_files,
    "dictionary": dictionary_data,
    'custom_prompt': custom_prompt
}

# Corrected file upload part to match the expected key 'file' in the API
try:
    response = requests.post(TRANSLATE_DOCUMENT_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {}).get('task_id')

    if parent_task_id:
        print(f'Parent Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'parent_task_id' not in locals():
    print('Error: missing parent_task_id')
    exit()

timeout = 600  # 10 minutes
start_time = datetime.datetime.now()
url_download = ''

printed_tasks = set()  # Set to store printed task_ids

while True:
    if (datetime.datetime.now() - start_time).seconds >= timeout:
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(f"{GET_RESULT_ENDPOINT}{parent_task_id}", headers=headers)
        response.raise_for_status()  # Ensure HTTP request success
        response_data = response.json()

        # Check all tasks in response
        results = response_data.get('data', {})

        for task_id, result in results.items():
            if isinstance(result, dict) and result.get('status') == 'done' and task_id not in printed_tasks:
                url_download = result.get('url_download')
                if url_download:
                    print(f"URL Download file {result.get('filename')}: {url_download}")
                    printed_tasks.add(task_id)  # Mark this task_id as printed

        # Stop checking if all tasks have been printed
        if len(printed_tasks) == len(results) - 1:  # Ignore the "status": null key
            break

    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Avoid overloading the server

if not url_download:
    print('Error: missing URL for download.')
```


# Presentation Maker

```python
import requests
import datetime
import time

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v1/summarization"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"

# summarization settings
FILE_TYPE = "application/docx"
DEST_LANG = 'ja'
SLIDES_NUMBER = "10"
TEMPLATE_PATH="system/Template_2.pptx"

# File paths
FILE_PATH = '/path/to/your/file.docx'  # Input file path
OUTPUT_FOLDER = '/path/to/output/folder/'  # Output folder path

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Corrected variable names according to their declaration at the top
form_data = {
    'file_type': FILE_TYPE,
    'dest_lang': DEST_LANG,
    'slides_number': SLIDES_NUMBER,
    'template_path': TEMPLATE_PATH
}

headers = {'Authorization': f'Bearer {auth_token}'}

# Corrected file upload part to match the expected key 'file' in the API
with open(FILE_PATH, 'rb') as file_to_translate:
    try:
        response = requests.post(TRANSLATE_DOCUMENT_URL, data=form_data, files={'file': file_to_translate}, headers=headers)
        response.raise_for_status()  # Proper error handling
        
        response_data = response.json()
        task_id = response_data.get('data', {}).get('task_id')
        
        if task_id:
            print(f'Task ID: {task_id}')
        else:
            print('Failed to get the task ID from the response.')
    except requests.exceptions.RequestException as e:
        print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'task_id' not in locals():
    print('Error: missing task_id')
    exit()

def download_file(url_download, output_folder):
    response = requests.get(url_download)
    filename = url_download.split('/')[-1].split('?')[0]
    output_file_path = f"{output_folder}{filename}"
    with open(output_file_path, 'wb') as file:
        file.write(response.content)
    return output_file_path


start_time = datetime.datetime.now()
url_download = ''

while True:
    if (datetime.datetime.now() - start_time).seconds >= 600:  # 10 minutes timeout
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(GET_RESULT_ENDPOINT + task_id, headers=headers)  # Use GET and append task_id to URL
        
        response_data = response.json()
        if response_data.get('status') == 'success' and response_data.get('data', {}).get('url_download'):
            url_download = response_data['data']['url_download']
            output_file = download_file(url_download, OUTPUT_FOLDER)
            print(f'Downloaded file: {output_file}')
            break
    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Wait before the next check to avoid flooding the server

if not url_download:
    print('Error: missing URL for download.')

```


# Presentation Video

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
CREATE_TRANSCRIPTS_URL = f"{BASE_URL}/v1/create/transcripts"
UPDATE_TRANSCRIPTS_URL = f"{BASE_URL}/v1/update/transcripts"
CREATE_VIDEO_URL = f"{BASE_URL}/v1/create/video"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# File paths
input_file_paths = ['Template_2.pptx']  # Input file PPTX, PDF

# UPLOAD FILE PART
TASK_TYPE = 'create_video'

form_data = {
    'task_type': TASK_TYPE,
}

# add files to the form data
files = [('files', open(file_path, 'rb')) for file_path in input_file_paths]

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data, files=files,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Upload file success Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# CREATE TRANCRIPTS PART
# create transcripts settings
destination_language = 'vi'
translate_type = 'Professional'
custom_prompt = ""    # Edit the translation as desired. For example, 'Uppercase the nouns in the text.'
voice = 'john'
tone = 'Default'
domain = 'Default'

# Corrected variable names according to their declaration at the top
json_data = {
    'task_type': TASK_TYPE,
    'dest_lang': destination_language,
    'translate_type': translate_type,
    'meta_files': meta_files,
    'custom_prompt': custom_prompt,
    'voice': voice,
    'tone': tone,
    'domain': domain,
}

# Corrected file upload part to match the expected key 'file' in the API
try:
    response = requests.post(CREATE_TRANSCRIPTS_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {})

    if parent_task_id:
        print(f'Processing... create transcript with Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'parent_task_id' not in locals():
    print('Error: missing parent_task_id')
    exit()


def get_result(parent_task_id, is_get_url=False):
    start_time = datetime.datetime.now()
    url_download = ''
    is_success = False
    while True:
        if (datetime.datetime.now() - start_time).seconds >= 600:  # 10 minutes timeout
            print('Error: Processing timed out.')
            break

        try:
            response = requests.get(GET_RESULT_ENDPOINT + parent_task_id,
                                    headers=headers)  # Use GET and append parent_task_id to URL

            response_data = response.json()
            if not is_get_url:
                if response_data.get('status') == 'success' and response_data.get('data', {}).get('transcripts', {}):
                    results = response_data['data']

                    for key, result in results.items():
                        if isinstance(result, dict) and key == 'transcripts':
                            for index, transcript in result['data'].items():
                                print(f'slide {index}th: {transcript}')
                    is_success = True
                    break
            else:
                if response_data.get('status') == 'success' and response_data.get('data', {}).get('url_download', {}):
                    url_download = response_data['data']['url_download']
                    print(f'URL Download file {response_data.get("data", {}).get("filename")}: {url_download}')
                    is_success = True
                    break
        except requests.exceptions.RequestException as e:
            print(f'An error occurred while checking task status: {e}')
            break

        time.sleep(5)  # Wait before the next check to avoid flooding the server
    if not is_success:
        print('Error: failed to get the result.')
    return is_success

is_success = get_result(parent_task_id)
if is_success:
    print('Create transcripts successfully')
while True:
    is_update_transcript = input('Do you want to update the transcript? (y/n): ')
    if is_update_transcript.lower() == 'y':
        # UPDATE TRANCRIPTS PART
        # update transcripts settings
        while True:
            transcript_number = input('Please enter the transcript number: ')
            if transcript_number.isdigit():
                break
        transcript_content = input('Please enter the transcript content: ')
        json_data = {
            "task_id": parent_task_id,
            "transcript_number": int(transcript_number),
            "transcript_content": transcript_content,
        }

        try:
            response = requests.post(UPDATE_TRANSCRIPTS_URL, json=json_data,
                                     headers=headers)
            response.raise_for_status()  # Proper error handling

            response_data = response.json()


            if response_data.get('status') == True:
                print(f'Update transcript successfully')
            else:
                print('Failed to get the parent task ID from the response.')
        except requests.exceptions.RequestException as e:
            print(f'An error occurred: {e}')

        is_success = get_result(parent_task_id)

    elif is_update_transcript == 'n':
        break
    else:
        print('Invalid input. Please enter "y" for yes or "n" for no.')

# CREATE VIDEO PART
# create video settings
json_data = {
"task_ids": [parent_task_id],
}

try:
    response = requests.post(CREATE_VIDEO_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {}).get('task_id', {})

    if parent_task_id:
        print(f'Processing... video with Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

is_success = get_result(parent_task_id, is_get_url=True)
if is_success:
    print('Create video successfully')
```


# API V2


# Upload Multiple Files

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# File paths
input_file_path = ['/data/example.docx', '/data/example_2.docx']  # Input file path

# UPLOAD FILE PART
TASK_TYPE = 'document'

form_data = {
    'task_type': TASK_TYPE,
}

# add files to the form data
files = [('files', open(file_path, 'rb')) for file_path in input_file_paths]

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data, files=files,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')
```


# Translate Multiple Document Files

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v2/process"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# File paths
input_file_paths = ['/data/example.docx', '/data/example_2.docx']  # Input file path

# UPLOAD FILE PART
TASK_TYPE = 'document'

form_data = {
    'task_type': TASK_TYPE,
}

# add files to the form data
files = [('files', open(file_path, 'rb')) for file_path in input_file_paths]

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data, files=files,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# TRANSLATE DOCUMENT PART
# Translation settings
original_language = None  # Automatically detect language if not specified
destination_language = 'vi'
process_mode = 'append'
translate_type = 'Professional'
publish_api = True
dictionary = [{"ori_word": "Hello", "des_word": "Chào mừng", "des_lang": "en", "ori_lang": "vi"},
                   {"ori_word": "You", "des_word": "Cậu", "des_lang": "en", "ori_lang": "vi"}]
custom_prompt = None    # Edit the translation as desired. For example, 'Uppercase the nouns in the text.'
tone = 'Serious'
domain_translate_document = 'Legal Documents'

# Corrected variable names according to their declaration at the top
json_data = {
    'task_type': TASK_TYPE,
    'dest_lang': destination_language,
    'process_mode': process_mode,
    'translate_type': translate_type,
    'is_translate_images': False,
    'bilingual_text_style__font': 'Helvetica',
    'bilingual_text_style__color': '#96d35f',
    'meta_files': meta_files,
    "dictionary": dictionary,
    'tone': tone,
    'domain_translate_document': domain_translate_document,
    'custom_prompt': custom_prompt
}

# Corrected file upload part to match the expected key 'file' in the API
try:
    response = requests.post(TRANSLATE_DOCUMENT_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {}).get('task_id')

    if parent_task_id:
        print(f'Parent Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'parent_task_id' not in locals():
    print('Error: missing parent_task_id')
    exit()

timeout = 600  # 10 minutes
start_time = datetime.datetime.now()
url_download = ''

printed_tasks = set()  # Set to store printed task_ids

while True:
    if (datetime.datetime.now() - start_time).seconds >= timeout:
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(f"{GET_RESULT_ENDPOINT}{parent_task_id}", headers=headers)
        response.raise_for_status()  # Ensure HTTP request success
        response_data = response.json()

        # Check all tasks in response
        results = response_data.get('data', {})

        for task_id, result in results.items():
            if isinstance(result, dict) and result.get('status') == 'done' and task_id not in printed_tasks:
                url_download = result.get('url_download')
                if url_download:
                    print(f"URL Download file {result.get('filename')}: {url_download}")
                    printed_tasks.add(task_id)  # Mark this task_id as printed

        # Stop checking if all tasks have been printed
        if len(printed_tasks) == len(results) - 1:  # Ignore the "status": null key
            break

    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Avoid overloading the server

if not url_download:
    print('Error: missing URL for download.')
```


# Text Translation

```python
import requests
import datetime
from time import sleep
import json

# Endpoints
BASE_URL = "https://doctranslate-api.doctranslate.io"
BE_TRANSLATE_URL = f"{BASE_URL}/v2/translate/text"
BE_GET_RESULT_URL = f"{BASE_URL}/v1/result/"
DEST_LANG = 'vi'

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

TEXT = "Hello, my name is Thanh. I am a software engineer."

DICTIONARY = json.dumps(
[
    {
        "ori_lang": "en",
        "des_lang": "vi",
        "ori_word": "hello",
        "des_word": "Tạm biệt",
    },
    {
        "ori_lang": "en",
        "des_lang": "vi",
        "ori_word": "I",
        "des_word": "Tớ",
    },
])

# Function to post translation request
def post_translation(text, dest_lang, token):
    form_data = {
        'original_lang': None,  # Assuming server handles 'None' as auto-detect
        'dest_lang': dest_lang,
        'process_mode': 'replace',
        'translate_type': 'Professional',
        'text': text,
        'dictionary': DICTIONARY
    }
    headers = {'Authorization': f'Bearer {token}'}
    response = requests.post(BE_TRANSLATE_URL, data=form_data, headers=headers)
    return response.json()

# Function to check translation result
def check_translation(task_id, token, timeout=600):
    start_time = datetime.datetime.now()
    while (datetime.datetime.now() - start_time).seconds < timeout:
        response = requests.get(f"{BE_GET_RESULT_URL}{task_id}", headers={'Authorization': f'Bearer {token}'})
        response_data = response.json()
        if response_data['status'] == 'success' and 'data' in response_data and 'url_download' in response_data['data'] and response_data['data']['url_download'] != '':
            return response_data['data']
        sleep(5)
    return None

# Main execution
response_data = post_translation(TEXT, DEST_LANG, auth_token )
if response_data['status'] == 'success':
    task_id = response_data['data']['task_id']
    print(f'Task ID: {task_id}')
    result_data = check_translation(task_id, auth_token)
    if result_data and 'url_download' in result_data:
        print(f"URL Download: {result_data['url_download']}")
        print(f"\nText: {result_data['text']}")
    else:
        print('Error: No download URL found within the given timeout.')
else:
    print('Error: Failed to initiate translation task. Please check your request and try again.')


```


# Document Translation

```python
import requests
import datetime
import time

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_DOCUMENT_URL = f"{BASE_URL}/v2/translate/document"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
CONTENT_TYPE = 'application/docx'

# Translation settings
original_language = None  # Automatically detect language if not specified
destination_language = 'ja'
process_mode = 'append'
translate_type = 'Professional'
publish_api = True

# File paths
input_file_path = '/data/example.docx'  # Input file path
output_folder_path = '/data/translated/'  # Output folder path

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Corrected variable names according to their declaration at the top
form_data = {
    'file_type': CONTENT_TYPE,
    'original_lang': original_language,
    'dest_lang': destination_language,
    'process_mode': process_mode,
    'translate_type': translate_type,
    'bilingual_text_style__font': 'Helvetica',
    'bilingual_text_style__color': '#96d35f'
}

headers = {'Authorization': f'Bearer {auth_token}'}

# Corrected file upload part to match the expected key 'file' in the API
with open(input_file_path, 'rb') as file_to_translate:
    try:
        response = requests.post(TRANSLATE_DOCUMENT_URL, data=form_data, files={'file': file_to_translate}, headers=headers)
        response.raise_for_status()  # Proper error handling
        
        response_data = response.json()
        task_id = response_data.get('data', {}).get('task_id')
        
        if task_id:
            print(f'Task ID: {task_id}')
        else:
            print('Failed to get the task ID from the response.')
    except requests.exceptions.RequestException as e:
        print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'task_id' not in locals():
    print('Error: missing task_id')
    exit()

start_time = datetime.datetime.now()
url_download = ''

while True:
    if (datetime.datetime.now() - start_time).seconds >= 600:  # 10 minutes timeout
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(GET_RESULT_ENDPOINT + task_id, headers=headers)  # Use GET and append task_id to URL
        
        response_data = response.json()
        if response_data.get('status') == 'success' and response_data.get('data', {}).get('status') == 'done':
            url_download = response_data['data']['url_download']
            print(f'URL Download: {url_download}')
            break
    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Wait before the next check to avoid flooding the server

if not url_download:
    print('Error: missing URL for download.')

```


# Image Translation

```python
import datetime
import requests
from time import sleep

# Endpoints
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_IMAGES_ENDPOINT = f"{BASE_URL}/v2/translate/images"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"

# Configuration variables for the request
ORIGINAL_LANG = None  # It's better to use `None` explicitly if a value is optional
DEST_LANG = 'vi'
PROCESS_MODE = 'replace'
TRANSLATE_TYPE = 'Professional'
FILE_PATH = '/path/to/your/file.jpg'  # Use a generic path or explain how to set this
OUTPUT_FOLDER = '/path/to/output/folder/'

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Organize your script into functions to improve readability and reusability
def upload_file_for_translation(file_path, token):
    form_data = {
        'original_lang': ORIGINAL_LANG,
        'dest_lang': DEST_LANG,
        'process_mode': PROCESS_MODE,
        'translate_type': TRANSLATE_TYPE
    }
    
    with open(file_path, 'rb') as file:
        files = {'files': file}
        headers = {'Authorization': f'Bearer {token}'}
        response = requests.post(TRANSLATE_IMAGES_ENDPOINT, data=form_data, files=files, headers=headers)
    return response.json()

def check_translation_status(task_id, token):
    start_time = datetime.datetime.now()
    timeout = 60 * 10  # 10 minutes
    while True:
        elapsed_time = datetime.datetime.now() - start_time
        if elapsed_time.seconds >= timeout:
            print('Error: Process timed out')
            return None

        headers = {'Authorization': f'Bearer {token}'}
        response = requests.get(f"{GET_RESULT_ENDPOINT}{task_id}", headers=headers)
        response_data = response.json()

        if response_data.get('status') == 'success' and response_data.get('data', {}).get('status') == 'done':
            return response_data['data']['url_download']
        sleep(5)

def download_file(url_download, output_folder):
    response = requests.get(url_download)
    filename = url_download.split('/')[-1].split('?')[0]
    output_file_path = f"{output_folder}{filename}"
    with open(output_file_path, 'wb') as file:
        file.write(response.content)
    return output_file_path

# Main execution flow
response_data = upload_file_for_translation(FILE_PATH, auth_token)
if response_data['status'] == 'success':
    task_id = response_data['data']['task_id']
    print(f'Task ID: {task_id}')
    url_download = check_translation_status(task_id, auth_token)
    if url_download:
        output_file = download_file(url_download, OUTPUT_FOLDER)
        print(f'Downloaded file: {output_file}')
    else:
        print('Error: missing url_download')
else:
    print('Error: Failed to initiate translation task')

```


# Audio Translation

```python
import datetime
import requests
from time import sleep

# Endpoints
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_AUDIO_ENDPOINT = f"{BASE_URL}/v2/translate/audio"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"

# Configuration variables for the request
SOURCE_LANG = 'vi'
DEST_LANG = 'vi'
FILE_PATH = '/path/to/your/file.mp3'  # Use a generic path or explain how to set this
OUTPUT_FOLDER = '/path/to/output/folder/'

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Organize your script into functions to improve readability and reusability
def upload_file_for_translation(file_path, token):
    form_data = {
        'source_lang': SOURCE_LANG,
        'dest_lang': DEST_LANG
    }
    
    with open(file_path, 'rb') as file:
        files = {'files': file}
        headers = {'Authorization': f'Bearer {token}'}
        response = requests.post(TRANSLATE_AUDIO_ENDPOINT, data=form_data, files=files, headers=headers)
    return response.json()

def check_translation_status(task_id, token):
    start_time = datetime.datetime.now()
    timeout = 60 * 10  # 10 minutes
    while True:
        elapsed_time = datetime.datetime.now() - start_time
        if elapsed_time.seconds >= timeout:
            print('Error: Process timed out')
            return None, None

        headers = {'Authorization': f'Bearer {token}'}
        response = requests.get(f"{GET_RESULT_ENDPOINT}{task_id}", headers=headers)
        response_data = response.json()

        if response_data.get('status') == 'success' and response_data.get('data', {}).get('status') == 'done':
            return response_data['data']['transcript_urls'], response_data['data']['translated_transcribe_urls']
        sleep(5)

def download_file(url_download, output_folder, filename):
    response = requests.get(url_download)
    _filename = url_download.split('/')[-1].split('?')[0]
    output_file_path = f"{output_folder}{filename}-{_filename}"
    with open(output_file_path, 'wb') as file:
        file.write(response.content)
    return output_file_path

# Main execution flow
response_data = upload_file_for_translation(FILE_PATH, auth_token)
if response_data['status'] == 'success':
    task_id = response_data['data']['task_id']
    print(f'Task ID: {task_id}')
    transcript_urls,translated_transcribe_urls = check_translation_status(task_id, auth_token)
    if transcript_urls and translated_transcribe_urls:
        transcript_file = download_file(transcript_urls, OUTPUT_FOLDER, 'transcript')
        translated_transcribe_file = download_file(translated_transcribe_urls, OUTPUT_FOLDER, 'translated')
        print(f'Transcript file: {transcript_file}')
        print(f'Translated file: {translated_transcribe_file}')
    else:
        print('Error: missing url_download')
else:
    print('Error: Failed to initiate translation task')

```


# Video Translation

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
TRANSLATE_VIDEO_URL = f"{BASE_URL}/v2/process"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# Youtube link
youtube_link = "<YOUR_LINK>"

# UPLOAD FILE PART
TASK_TYPE = 'video'

form_data = {
    'task_type': TASK_TYPE,
    'youtube_link': youtube_link
}

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# TRANSLATE PART
# Translation settings
original_language = 'en'  # Automatically detect language if not specified
destination_language = 'vi'
process_mode = 'append'
translate_type = 'Professional'
publish_api = True
dictionary_data = [{"ori_word": "Hello", "des_word": "Chào mừng", "des_lang": "en", "ori_lang": "vi"},
                   {"ori_word": "You", "des_word": "Cậu", "des_lang": "en", "ori_lang": "vi"}]
custom_prompt = None    # Edit the translation as desired. For example, 'Uppercase the nouns in the text.'

# Corrected variable names according to their declaration at the top
json_data = {
    'task_type': TASK_TYPE,
    'dest_lang': destination_language,
    'process_mode': process_mode,
    'translate_type': translate_type,
    'is_translate_images': False,
    'meta_files': meta_files,
    "dictionary": dictionary_data,
    'custom_prompt': custom_prompt
}

# Corrected file upload part to match the expected key 'file' in the API
try:
    response = requests.post(TRANSLATE_VIDEO_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {}).get('task_id')

    if parent_task_id:
        print(f'Parent Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'parent_task_id' not in locals():
    print('Error: missing parent_task_id')
    exit()

timeout = 600  # 10 minutes
start_time = datetime.datetime.now()
url_download = ''

printed_tasks = set()  # Set to store printed task_ids

while True:
    if (datetime.datetime.now() - start_time).seconds >= timeout:
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(f"{GET_RESULT_ENDPOINT}{parent_task_id}", headers=headers)
        response.raise_for_status()  # Ensure HTTP request success
        response_data = response.json()

        # Check all tasks in response
        results = response_data.get('data', {})

        for task_id, result in results.items():
            if isinstance(result, dict) and result.get('status') == 'done' and task_id not in printed_tasks:
                url_download = result.get('url_download')
                if url_download:
                    print(f"URL Download file {result.get('filename')}: {url_download}")
                    printed_tasks.add(task_id)  # Mark this task_id as printed

        # Stop checking if all tasks have been printed
        if len(printed_tasks) == len(results) - 1:  # Ignore the "status": null key
            break

    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Avoid overloading the server

if not url_download:
    print('Error: missing URL for download.')
```


# Presentation Maker

```python
import requests
import datetime
import time

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
PRESENTATION_MAKER_URL = f"{BASE_URL}/v2/summarization"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"

# summarization settings
FILE_TYPE = "application/docx"
DEST_LANG = 'ja'
SLIDES_NUMBER = "10"
TEMPLATE_PATH="system/New_templates/1.pptx"
IS_IMAGE = True
ORIENTAION = 'presentation'

# File paths
FILE_PATH = '/path/to/your/file.docx'  # Input file path
OUTPUT_FOLDER = '/path/to/output/folder/'  # Output folder path

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

# Corrected variable names according to their declaration at the top
json_data = {
    'file_type': FILE_TYPE,
    'dest_lang': DEST_LANG,
    'slides_number': SLIDES_NUMBER,
    'template_path': TEMPLATE_PATH,
    'is_image': IS_IMAGE,
    'orientation':  ORIENTAION
}

headers = {'Authorization': f'Bearer {auth_token}'}

# Corrected file upload part to match the expected key 'file' in the API
with open(FILE_PATH, 'rb') as file_to_translate:
    try:
        response = requests.post(PRESENTATION_MAKER_URL, json=json_data, files={'file': file_to_translate}, headers=headers)
        response.raise_for_status()  # Proper error handling
        
        response_data = response.json()
        task_id = response_data.get('data', {}).get('task_id')
        
        if task_id:
            print(f'Task ID: {task_id}')
        else:
            print('Failed to get the task ID from the response.')
    except requests.exceptions.RequestException as e:
        print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'task_id' not in locals():
    print('Error: missing task_id')
    exit()

def download_file(url_download, output_folder):
    response = requests.get(url_download)
    filename = url_download.split('/')[-1].split('?')[0]
    output_file_path = f"{output_folder}{filename}"
    with open(output_file_path, 'wb') as file:
        file.write(response.content)
    return output_file_path


start_time = datetime.datetime.now()
url_download = ''

while True:
    if (datetime.datetime.now() - start_time).seconds >= 600:  # 10 minutes timeout
        print('Error: Processing timed out.')
        break

    try:
        response = requests.get(GET_RESULT_ENDPOINT + task_id, headers=headers)  # Use GET and append task_id to URL
        
        response_data = response.json()
        if response_data.get('status') == 'success' and response_data.get('data', {}).get('url_download'):
            url_download = response_data['data']['url_download']
            output_file = download_file(url_download, OUTPUT_FOLDER)
            print(f'Downloaded file: {output_file}')
            break
    except requests.exceptions.RequestException as e:
        print(f'An error occurred while checking task status: {e}')
        break

    time.sleep(5)  # Wait before the next check to avoid flooding the server

if not url_download:
    print('Error: missing URL for download.')

```


# Presentation Video

```python
import requests
import datetime
import time

# Authentication token
auth_token = "<YOUR_API_TOKEN>"

headers = {'Authorization': f'Bearer {auth_token}'}

# Constants for URLs and content type
BASE_URL = "https://doctranslate-api.doctranslate.io"
CREATE_TRANSCRIPTS_URL = f"{BASE_URL}/v2/create/transcripts"
UPDATE_TRANSCRIPTS_URL = f"{BASE_URL}/v2/update/transcripts"
CREATE_VIDEO_URL = f"{BASE_URL}/v2/create/video"
GET_RESULT_ENDPOINT = f"{BASE_URL}/v1/result/"
UPLOAD_FILE_URL = f"{BASE_URL}/v1/upload"

# File paths
input_file_paths = ['Template_2.pptx']  # Input file PPTX, PDF

# UPLOAD FILE PART
TASK_TYPE = 'create_video'

form_data = {
    'task_type': TASK_TYPE,
}

# add files to the form data
files = [('files', open(file_path, 'rb')) for file_path in input_file_paths]

meta_files = []
try:
    response = requests.post(UPLOAD_FILE_URL, data=form_data, files=files,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    meta_files = response_data.get('data', {})
    for metadata in meta_files:
        if metadata["task_id"]:
            print(f'Upload file success Task ID: {metadata["task_id"]}')
        else:
            print('Failed to get the task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# CREATE TRANCRIPTS PART
# create transcripts settings
destination_language = 'vi'
translate_type = 'Professional'
custom_prompt = ""    # Edit the translation as desired. For example, 'Uppercase the nouns in the text.'
voice = 'john'
domain = 'Default'

# Corrected variable names according to their declaration at the top
json_data = {
    'task_type': TASK_TYPE,
    'dest_lang': destination_language,
    'translate_type': translate_type,
    'meta_files': meta_files,
    'custom_prompt': custom_prompt,
    'voice': voice,
    'domain': domain,
}

# Corrected file upload part to match the expected key 'file' in the API
try:
    response = requests.post(CREATE_TRANSCRIPTS_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {})

    if parent_task_id:
        print(f'Processing... create transcript with Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

# Check for task_id before proceeding
if 'parent_task_id' not in locals():
    print('Error: missing parent_task_id')
    exit()


def get_result(parent_task_id, is_get_url=False):
    start_time = datetime.datetime.now()
    url_download = ''
    is_success = False
    while True:
        if (datetime.datetime.now() - start_time).seconds >= 600:  # 10 minutes timeout
            print('Error: Processing timed out.')
            break

        try:
            response = requests.get(GET_RESULT_ENDPOINT + parent_task_id,
                                    headers=headers)  # Use GET and append parent_task_id to URL

            response_data = response.json()
            if not is_get_url:
                if response_data.get('status') == 'success' and response_data.get('data', {}).get('transcripts', {}):
                    results = response_data['data']

                    for key, result in results.items():
                        if isinstance(result, dict) and key == 'transcripts':
                            for index, transcript in result['data'].items():
                                print(f'slide {index}th: {transcript}')
                    is_success = True
                    break
            else:
                if response_data.get('status') == 'success' and response_data.get('data', {}).get('url_download', {}):
                    url_download = response_data['data']['url_download']
                    print(f'URL Download file {response_data.get("data", {}).get("filename")}: {url_download}')
                    is_success = True
                    break
        except requests.exceptions.RequestException as e:
            print(f'An error occurred while checking task status: {e}')
            break

        time.sleep(5)  # Wait before the next check to avoid flooding the server
    if not is_success:
        print('Error: failed to get the result.')
    return is_success

is_success = get_result(parent_task_id)
if is_success:
    print('Create transcripts successfully')
while True:
    is_update_transcript = input('Do you want to update the transcript? (y/n): ')
    if is_update_transcript.lower() == 'y':
        # UPDATE TRANCRIPTS PART
        # update transcripts settings
        while True:
            transcript_number = input('Please enter the transcript number: ')
            if transcript_number.isdigit():
                break
        transcript_content = input('Please enter the transcript content: ')
        json_data = {
            "task_id": parent_task_id,
            "transcript_number": int(transcript_number),
            "transcript_content": transcript_content,
        }

        try:
            response = requests.post(UPDATE_TRANSCRIPTS_URL, json=json_data,
                                     headers=headers)
            response.raise_for_status()  # Proper error handling

            response_data = response.json()


            if response_data.get('status') == True:
                print(f'Update transcript successfully')
            else:
                print('Failed to get the parent task ID from the response.')
        except requests.exceptions.RequestException as e:
            print(f'An error occurred: {e}')

        is_success = get_result(parent_task_id)

    elif is_update_transcript == 'n':
        break
    else:
        print('Invalid input. Please enter "y" for yes or "n" for no.')

# CREATE VIDEO PART
# create video settings
json_data = {
"task_ids": [parent_task_id],
}

try:
    response = requests.post(CREATE_VIDEO_URL, json=json_data,
                             headers=headers)
    response.raise_for_status()  # Proper error handling

    response_data = response.json()
    parent_task_id = response_data.get('data', {}).get('task_id', {})

    if parent_task_id:
        print(f'Processing... video with Task ID: {parent_task_id}')
    else:
        print('Failed to get the parent task ID from the response.')
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

is_success = get_result(parent_task_id, is_get_url=True)
if is_success:
    print('Create video successfully')
```


# Support

How to reach us for troubleshooting and bug reports

For further assistance or to report issues, please contact our support team at <support@doctranslate.io>.

This README provides a concise overview of how to interact with the Doctranslate.io API. For a complete reference, including all endpoints and detailed request/response models, please refer to the full API documentation in corresponding repository.


# Agent Plugin & AI Integration

Connect DocTranslate.io to AI agents and automation platforms. The DocTranslate Agent Plugin exposes the same public REST API as OpenAPI + platform manifests + language SDKs, so an autonomous agent can translate documents, text, images, audio and video, run PDF tools, and fill forms — using a single API key.

## Base URL & Auth

* **Base URL:** `https://doctranslate-api.doctranslate.io`
* **Auth:** header `X-API-Key: <key>` **or** `Authorization: Bearer <key>`
* **Get a key:** DocTranslate app → Settings → API Keys. Keys start with `dtl_`.

## Machine-readable spec (for agents)

Point your agent's tool loader at the OpenAPI spec:

* [**Download the OpenAPI spec** (openapi.yaml)](https://pub-bf5af811d50c430a8fb9e8245625c242.r2.dev/agent-docs/openapi.yaml) — load this into your agent's tool loader.
* [**Agent quick-reference** (markdown)](https://pub-bf5af811d50c430a8fb9e8245625c242.r2.dev/agent-docs/doctranslate-agents.md)

The spec is generator-stamped from the live server, so parameter names, enums and status codes match production exactly.

## Tools

| Tool                 | Endpoint                                           | Notes                                                                                                         |
| -------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `translate_text`     | `POST /v3/translate/text`                          | Returns a `task_id`; poll `get_result`.                                                                       |
| `translate_document` | `POST /v3/translate/document`                      | DOCX/PDF/PPTX/XLSX/XML/HTML. Keeps layout.                                                                    |
| `translate_image`    | `POST /v3/translate/images`                        | Translate text in an image.                                                                                   |
| `translate_media`    | `POST /v4/translate/audio` · `/v4/translate/video` | Subtitle by default; set `export_audio`/`export_video` for a dubbed result (video → dubbed video end-to-end). |
| `pdf_tool`           | `POST /v3/pdf-tools/{tool}`                        | 29 PDF operations (convert, merge, split, rotate, compress…).                                                 |
| `data_entry`         | `POST /v3/data-entry`                              | Extract fields from a document and fill a form/template.                                                      |
| `get_upload_url`     | `POST /v3/upload`                                  | Presigned R2 PUT for large files; then pass the returned `file_key`.                                          |
| `get_result`         | `GET /v3/result/{task_id}`                         | Poll async tasks; returns text + a presigned download URL.                                                    |

### Key parameters

* **Languages:** `dest_lang` (target). Source hint: **`original_lang`** for text/document/image; **`source_lang`** for audio/video. Omit the source to auto-detect.
* **`file_type`:** MIME-style enum, e.g. `application/docx`, `application/pdf`, `application/pptx`, `application/xlsx`.
* **`domain` / `tone`:** exact enum strings (e.g. `"Legal Documents"`, `"Formal"`) — a `422` response lists the valid values.
* **Async contract:** dispatch endpoints return **`200`** with `{ data: { task_id } }`; poll `get_result` until it returns the output + download URL.

### Note-Taker & Presenter (a different base URL)

meeting\_notes (Note-Taker) and presenter (Presentation Video) are served by the main app, not the translation-file host. Use base URL <https://www.doctranslate.io/api/v1/third-party/> with the same X-API-Key.

* Note-Taker: POST /note-taker/audio2dialog (multipart files) -> poll GET /note-taker/audio2dialog/{task\_id} for data.result.dialog\_url; then POST /note-taker/dialog2meeting -> poll GET /note-taker/dialog2meeting/{task\_id} for data.result.markdown and docx\_url.
* Presenter (Presentation Video): POST /v3/upload (task\_type=document, PPTX/PDF) -> POST /v3/create/transcripts -> POST /v3/create/video. These two are not in the OpenAPI spec; a bad key returns 401 INVALID\_API\_KEY.

## Quick start (cURL)

```bash
# 1) submit
curl -s https://doctranslate-api.doctranslate.io/v3/translate/document \
  -H "X-API-Key: dtl_xxx" \
  -F "file=@report.docx" -F "file_type=application/docx" -F "dest_lang=vi"
# -> { "data": { "task_id": "..." } }

# 2) poll
curl -s https://doctranslate-api.doctranslate.io/v3/result/<task_id> \
  -H "X-API-Key: dtl_xxx"
# -> { "data": { "status": "success", "url_download": "https://..." } }
```

## SDKs

* **JavaScript / TypeScript:** `@doctranslate/sdk` — `new DocTranslate({ apiKey }).translateDocument({ file, dest_lang })`
* **Python:** `doctranslate` — `DocTranslate(api_key=...).translate_document(file=..., dest_lang="vi")`

Both wrap the same endpoints and auth. See the plugin repository for full method signatures.

## Supported agent platforms

The plugin ships ready-to-install manifests for:

* **Model Context Protocol (MCP)** — see the [MCP](broken://pages/80d2811c569c38951574c4938d99ea3b4d44ef9f) page.
* **Composio**, **Pi**, and **Custom GPT / OpenAI plugin** — install the manifest, paste your API key, done.

Any platform that accepts an OpenAPI 3 spec can consume the API directly from the OpenAPI URL above.

## Notes

* `Every tool deducts credit per completed task; a bad key returns 401.`
* Enhanced-conversion and billing are unaffected — the plugin only calls the public translation API.


