> ## 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.

# Text translations v2

> Translates the text content utilizing Phrase Language AI capabilities. Can identify the source language, if 
not provided, and translate the text to the target language. If language identification is requested, system
needs to have at least 50 characters.




## OpenAPI

````yaml /openapi/phrase-language-ai.json post /v2/textTranslations
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:
  /v2/textTranslations:
    summary: Text translations v2
    post:
      tags:
        - Text translations
      summary: Text translations v2
      description: >
        Translates the text content utilizing Phrase Language AI capabilities.
        Can identify the source language, if 

        not provided, and translate the text to the target language. If language
        identification is requested, system

        needs to have at least 50 characters.
      operationId: postTextTranslationsV2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextTranslationsRequestV2'
            examples:
              withSourceLang:
                summary: Example request with source language
                value:
                  sourceLang:
                    code: en
                  sourceTexts:
                    - key: key1
                      source: Hello, world!
                  targetLang:
                    code: cs
                  mtSettings:
                    profile:
                      uid: CFUki8ptanoz1WAIYoXSH4
                  consumerId: consumer1
              withoutSourceLang:
                summary: Example request without source language.
                value:
                  sourceTexts:
                    - key: key1
                      source: >-
                        Hello, world! This is a test sentence to ensure it has
                        more than fifty characters.
                  targetLang:
                    code: cs
                  mtSettings:
                    profile:
                      uid: CFUki8ptanoz1WAIYoXSH4
                  consumerId: consumer1
              withoutProfile:
                summary: Example request without custom profile.
                value:
                  sourceTexts:
                    - key: key1
                      source: Hello, world!
                  sourceLang:
                    code: en
                  targetLang:
                    code: cs
                  consumerId: consumer1
      responses:
        '200':
          description: Response with translations
          headers:
            Memsource-Action-Id:
              $ref: '#/components/headers/MemsourceActionId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TextTranslationsResponseV2'
              examples:
                happyTranslation:
                  summary: Sample translation
                  value:
                    sourceLang:
                      code: en
                    translatedTexts:
                      - key: key1
                        target: Ahoj, světe!
                    targetLang:
                      code: cs
                    consumerId: consumer1
        '400':
          $ref: '#/components/responses/Tms400'
        '401':
          $ref: '#/components/responses/Tms401'
components:
  schemas:
    TextTranslationsRequestV2:
      properties:
        sourceLang:
          $ref: '#/components/schemas/LanguageV1'
        sourceTexts:
          type: array
          minItems: 1
          maxItems: 6
          items:
            $ref: '#/components/schemas/SourceTextRequestV2'
        targetLang:
          $ref: '#/components/schemas/LanguageV1'
        mtSettings:
          $ref: '#/components/schemas/MtSettingSimplifiedV1'
        consumerId:
          $ref: '#/components/schemas/ConsumerIdV2'
      required:
        - sourceTexts
        - targetLang
        - consumerId
    TextTranslationsResponseV2:
      type: object
      properties:
        translatedTexts:
          type: array
          items:
            $ref: '#/components/schemas/TranslatedTextResponseV2'
        sourceLang:
          $ref: '#/components/schemas/LanguageV1'
        targetLang:
          $ref: '#/components/schemas/LanguageV1'
        consumerId:
          $ref: '#/components/schemas/ConsumerIdV2'
      required:
        - translatedText
        - sourceLang
        - targetLang
        - consumerId
    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
    SourceTextRequestV2:
      type: object
      properties:
        key:
          type: string
          description: >-
            The key of the source text. This is used to identify the source text
            in the response. Must be unique.
          minLength: 1
          maxLength: 50
        source:
          type: string
          description: The source text to be translated.
          minLength: 1
          maxLength: 2000
      required:
        - key
        - source
    MtSettingSimplifiedV1:
      type: object
      properties:
        profile:
          $ref: '#/components/schemas/TranslationProfileRequestV1'
    ConsumerIdV2:
      type: string
      minLength: 1
      maxLength: 50
      description: >-
        Use short descriptive ID that represents the calling integration. E.g.
        JIRA_INTEGRATION, GDRIVE_SYNC, SHOPIFY_EXT:v1.2 etc.
    TranslatedTextResponseV2:
      type: object
      properties:
        key:
          type: string
        target:
          type: string
    TranslationProfileRequestV1:
      type: object
      required:
        - uid
      properties:
        uid:
          type: string
          description: UID for the translation profile
          example: CFUki8ptanoz1WAIYoXSH4
  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'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Provide `Authorization` header with token obtained through
        [Login](/en/api/language-ai/authentication/login) operation.

````