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

# Translate Message

> Auto-translates the provided message.

The caller must have access to the room that contains the message.
If the caller is not a room member (or otherwise cannot access it), the endpoint returns `403 Forbidden` and no translation is performed.

### Changelog
| Version      | Description |
| ---------------- | ------------|
|1.3.0          | Added       |
|8.5.0          | Added room-access check. |

## OpenAPI

````json POST /api/v1/autotranslate.translateMessage
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Messaging"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Chat"
    },
    {
      "name": "DM"
    },
    {
      "name": "Auto-Translate"
    }
  ],
  "paths": {
    "/api/v1/autotranslate.translateMessage": {
      "post": {
        "tags": [
          "Auto-Translate"
        ],
        "summary": "Translate Message",
        "description": "Auto-translates the provided message.\n\nThe caller must have access to the room that contains the message.\nIf the caller is not a room member (or otherwise cannot access it), the endpoint returns `403 Forbidden` and no translation is performed.\n\n### Changelog\n| Version      | Description |\n| ---------------- | ------------|\n|1.3.0          | Added       |\n|8.5.0          | Added room-access check. |",
        "operationId": "post-api-v1-autotranslate.translateMessage",
        "parameters": [
          {
            "$ref": "#/components/parameters/Auth-Token"
          },
          {
            "$ref": "#/components/parameters/UserId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "messageId": {
                    "type": "string",
                    "description": "The message's id to be translated."
                  },
                  "targetLanguage": {
                    "type": "string",
                    "description": "The target language that the message will be translated."
                  }
                },
                "required": [
                  "messageId"
                ]
              },
              "examples": {
                "Example": {
                  "value": {
                    "messageId": "Fq7sQNSnDEfzj8qoS",
                    "targetLanguage": "en"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object",
                      "properties": {
                        "_id": {
                          "type": "string"
                        },
                        "rid": {
                          "type": "string"
                        },
                        "msg": {
                          "type": "string"
                        },
                        "ts": {
                          "type": "string"
                        },
                        "u": {
                          "type": "object",
                          "properties": {
                            "_id": {
                              "type": "string"
                            },
                            "username": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            }
                          }
                        },
                        "_updatedAt": {
                          "type": "string"
                        },
                        "mentions": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "channels": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "translations": {
                          "type": "object",
                          "properties": {
                            "en": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success": {
                    "value": {
                      "message": {
                        "_id": "Fq7sQNSnDEfzj8qoS",
                        "rid": "GENERAL",
                        "msg": "Isso é um teste",
                        "ts": "2019-06-27T15:35:20.753Z",
                        "u": {
                          "_id": "pC6Z2N2ijivxdsYSu",
                          "username": "marcos",
                          "name": "marcos"
                        },
                        "_updatedAt": "2019-06-27T15:47:01.486Z",
                        "mentions": [],
                        "channels": [],
                        "translations": {
                          "en": "This is a test"
                        }
                      },
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "errorType": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "Invalid Params": {
                    "value": {
                      "success": "false",
                      "error": "Invalid request body. [error-invalid-params]",
                      "errorType": "error-invalid-params"
                    }
                  },
                  "Message Not Found": {
                    "value": {
                      "success": "false",
                      "error": "Message not found."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        "false"
                      ]
                    },
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "error"
                  ]
                },
                "examples": {
                  "Permission Error": {
                    "value": {
                      "success": "false",
                      "error": "unauthorized"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Auth-Token": {
        "name": "X-Auth-Token",
        "in": "header",
        "description": "The `authToken` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
      },
      "UserId": {
        "name": "X-User-Id",
        "in": "header",
        "description": "The `userId` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "rbAXPnMktTFbNpwtJ"
      }
    },
    "responses": {
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

