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

# File translations

> Creates a new file translations request based on multipart/form-data. The translation state can be fetched 
utilizing a returned UID in the response and a [Metadata](/en/api/language-ai/file-translations/file-processing-metadata) endpoint. It is also 
possible to download the translated file using the [Get file](/en/api/language-ai/file-translations/action-result) endpoint once the 
translation is complete (`action.status == OK`). 




## OpenAPI

````yaml /openapi/phrase-language-ai.json post /v1/fileTranslations
openapi: 3.0.2
info:
  title: Phrase Language AI via API
  description: >
    ### Machine translation powered by [Phrase](https://phrase.com) allows the
    translation of content utilizing  a unique AI powered feature to pick the
    best available translation engine for that content.
  version: 1.0.0
  termsOfService: https://phrase.com/terms/
  contact:
    url: https://phrase.com
servers:
  - url: https://eu.phrase.com/smt/api/
    description: The API server for EU data center.
  - url: https://us.phrase.com/smt/api/
    description: The API server for US data center.
security:
  - BearerAuth: []
tags:
  - name: File translations
    description: >-
      Allows the processing files asynchronously with the file being uploaded
      and stored in Phrase.  Files can be either stored or translated by the
      best available MT engine. File TTL is limited to 24 hours  after which the
      file is deleted from storage.
  - name: Authentication
    description: >
      Allows the authentication of a user and to get the token to be used in the
      Authorization header.
  - name: Text translations
    description: >
      Allows the translation of text content utilizing Phrase Language AI
      capabilities. APIs are synchronous, 

      designed for quick turnaround and are limited in size of the request.
paths:
  /v1/fileTranslations:
    summary: File processing
    post:
      tags:
        - File translations
      summary: File translations
      description: >
        Creates a new file translations request based on multipart/form-data.
        The translation state can be fetched 

        utilizing a returned UID in the response and a
        [Metadata](/en/api/language-ai/file-translations/file-processing-metadata)
        endpoint. It is also 

        possible to download the translated file using the [Get
        file](/en/api/language-ai/file-translations/action-result) endpoint once
        the 

        translation is complete (`action.status == OK`). 
      operationId: postFileTranslationsV1
      requestBody:
        description: >
          Source file with the metadata used for the translation process. 

          Multipart request with `metadata` and `file` parts.

          Metadata accepts the following `actionTypes`:


          <table style="font-size: .8rem; font-family: Roboto, sans-serif;">
            <thead>
              <th>Action Type</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>FILE_IMPORT</td>
                <td>Imports the file into the system</td>
              </tr>
              <tr>
               <td>CONVERTER_IMPORT</td>
               <td>Extracts the translatable texts out of the file</td>
              </tr>
              <tr>
                <td>MT_GENERIC_PRETRANSLATE</td>
                <td>Translates the extracted text</td>
              </tr>
              <tr>
                <td>QUALITY_ESTIMATION</td>
                <td>Returns Phrase Quality Performance Score (QPS)</td>
              </tr>
            </tbody>
          </table>


          Note that only action type `MT_GENERIC_PRETRANSLATE` is needed when
          user wants to translate the 

          file. Or only action type `QUALITY_ESTIMATION` is needed when user
          wants to translate the file and

          to get the quality estimation
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                metadata:
                  $ref: '#/components/schemas/FileTranslationsMetadataV1'
                file:
                  type: string
                  format: binary
                  x-constraints: '@ValidFileFormat'
              required:
                - metadata
                - file
            examples:
              translation-request:
                value: >
                  --Boundary_1_1453803947_1691603987728

                  Content-Type: application/octet-stream

                  Content-Disposition: form-data; name="file";
                  filename="test.txt"

                  Text for translation


                  --Boundary_1_1453803947_1691603987728

                  Content-Type: application/json

                  Content-Disposition: form-data; name="metadata"


                  {"sourceLang":{"code":"en"},"targetLangs":[{"code":"cs"}],"actionTypes":["MT_GENERIC_PRETRANSLATE"],"callbackUrl":"https://your-server.com/send/data/here"}

                  --Boundary_1_1453803947_1691603987728--
              storage-request:
                value: >
                  --Boundary_1_1453803947_1691603987728

                  Content-Type: application/octet-stream

                  Content-Disposition: form-data; name="file";
                  filename="test.txt"

                  Text for translation


                  --Boundary_1_1453803947_1691603987728

                  Content-Type: application/json

                  Content-Disposition: form-data; name="metadata"


                  {"sourceLang":{"code":"en"},"targetLangs":[{"code":"cs"}],"actionTypes":["FILE_IMPORT"],"callbackUrl":"https://your-server.com/send/data/here"}

                  --Boundary_1_1453803947_1691603987728--
            encoding:
              file:
                contentType: application/octet-stream
              metadata:
                contentType: application/json
      responses:
        '200':
          description: Response with UID of the file translations request.
          headers:
            Memsource-Action-Id:
              $ref: '#/components/headers/MemsourceActionId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileTranslationsResponseV1'
        '400':
          $ref: '#/components/responses/Tms400'
        '401':
          $ref: '#/components/responses/Tms401'
        '403':
          $ref: '#/components/responses/Tms403'
        '404':
          $ref: '#/components/responses/Tms404'
        '405':
          $ref: '#/components/responses/Tms405'
        '408':
          $ref: '#/components/responses/Tms408'
        '410':
          $ref: '#/components/responses/Tms410'
        '415':
          $ref: '#/components/responses/Tms415'
        '429':
          $ref: '#/components/responses/Tms429'
        '500':
          $ref: '#/components/responses/Tms500'
        '501':
          $ref: '#/components/responses/Tms501'
      callbacks:
        translationsFinished:
          '{$request.body#/metadata/callbackUrl}':
            post:
              summary: File Translations Callback
              description: >-
                Callback response with UID of the file translations operation
                and status describing how operation finished.
              operationId: sendUidV1
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/FileTranslationsResponseV1'
              responses:
                '200':
                  description: >-
                    Your server should return this HTTP status code if the
                    request was received successfully.
              method: post
              type: path
            path: '{$request.body#/metadata/callbackUrl}'
components:
  schemas:
    FileTranslationsMetadataV1:
      type: object
      properties:
        sourceLang:
          $ref: '#/components/schemas/LanguageV1'
        targetLangs:
          type: array
          items:
            $ref: '#/components/schemas/LanguageV1'
          uniqueItems: true
          minItems: 1
        actionTypes:
          type: array
          items:
            $ref: '#/components/schemas/ActionTypeEnumV1'
          uniqueItems: true
          minItems: 1
        callbackUrl:
          type: string
          description: >-
            URI in [RFC 2396](https://datatracker.ietf.org/doc/html/rfc2396)
            format.
          format: uri
        mtSettings:
          $ref: '#/components/schemas/MtSettingsV1'
        transMemoriesConfig:
          type: array
          items:
            $ref: '#/components/schemas/TranslationMemoriesConfigV1'
      required:
        - sourceLang
        - targetLangs
        - actionTypes
    FileTranslationsResponseV1:
      type: object
      properties:
        uid:
          description: UID of the operation. UID can be used to query the result.
          type: string
          example: random-uid
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionV1'
          uniqueItems: true
          minItems: 1
        metadata:
          $ref: '#/components/schemas/FileTranslationsMetadataV1'
      required:
        - uid
        - actions
        - metadata
    LanguageV1:
      type: object
      properties:
        code:
          type: string
          description: >-
            Language code, using a two-letter language code from ISO 639-1,
            e.g., `cs`.  Optionally, a region subtag based on a two-letter
            country code from ISO 3166-1 alpha-2,  e.g., `cs_cz`, or a
            three-digit code from UN M.49, e.g., `es_419`, separated by an
            underscore.  Both the two-letter language code and the two-letter
            country code need to be lower case.

            Note that the Phrase Language AI setup dictates whether the region
            subtag is optional or not.  If the only models deployed to a profile
            explicitly specify or are customized with a target locale,  then a
            region subtag is mandatory.
          example: cs
          x-constraints: '@ValidLocale'
      required:
        - code
    ActionTypeEnumV1:
      type: string
      enum:
        - CONVERTER_IMPORT
        - FILE_IMPORT
        - MT_GENERIC_PRETRANSLATE
        - QUALITY_ESTIMATION
      example: MT_GENERIC_PRETRANSLATE
    MtSettingsV1:
      type: object
      properties:
        usePhraseMTSettings:
          type: boolean
          default: false
          description: Use Language AI to apply Machine Translation
          example: true
        profile:
          $ref: '#/components/schemas/TranslationProfileRequestV1'
    TranslationMemoriesConfigV1:
      type: object
      properties:
        targetLang:
          $ref: '#/components/schemas/LanguageV1'
        transMemories:
          type: array
          items:
            $ref: '#/components/schemas/TranslationMemoryRequestV1'
    ActionV1:
      type: object
      description: >-
        Actions performed with the file. Each of the actions gets unique
        identifier to query the result.
      properties:
        actionType:
          $ref: '#/components/schemas/ActionTypeEnumV1'
        results:
          type: array
          items:
            $ref: '#/components/schemas/ActionResultV1'
          uniqueItems: true
          minItems: 1
      required:
        - actionType
        - results
    TranslationProfileRequestV1:
      type: object
      required:
        - uid
      properties:
        uid:
          type: string
          description: UID for the translation profile
          example: CFUki8ptanoz1WAIYoXSH4
    TranslationMemoryRequestV1:
      type: object
      properties:
        transMemory:
          type: object
          properties:
            uid:
              type: string
              description: Unique identifier of the translation memory
        tmSourceLocale:
          $ref: '#/components/schemas/LanguageV1'
        tmTargetLocale:
          $ref: '#/components/schemas/LanguageV1'
    ActionResultV1:
      type: object
      properties:
        id:
          type: string
          example: random-uid
        sourceLang:
          type: string
          example: en
        targetLang:
          type: string
          example: cs
        status:
          $ref: '#/components/schemas/ActionStatusEnumV1'
      required:
        - id
        - sourceLang
        - targetLang
        - status
    ActionStatusEnumV1:
      type: string
      enum:
        - ERROR
        - OK
        - RUNNING
      example: OK
  headers:
    MemsourceActionId:
      description: Memsource action identifier used for tracking request across services.
      schema:
        type: string
  responses:
    Tms400:
      description: Bad request
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms401:
      description: Not authorized
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms403:
      description: Forbidden
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms404:
      description: Resource not found
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms405:
      description: Method not allowed
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms408:
      description: Timeout
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms410:
      description: Gone
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms415:
      description: Unsupported media type
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms429:
      description: Too many requests
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms500:
      description: Internal server error
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
    Tms501:
      description: Not implemented
      headers:
        Memsource-Action-Id:
          $ref: '#/components/headers/MemsourceActionId'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Provide `Authorization` header with token obtained through
        [Login](/en/api/language-ai/authentication/login) operation.

````