Memsource REST API

Using Memsource APIs

This is a simple API scenario with sample API calls and instructions on how to chain them together to complete a simple action using only Memsource APIs. Options that can be set via the APIs are extensive. Consult the respective sections of our REST API documentation to find out more about all available options.

Scenario

Authentication:

The user will authenticate themselves to be able to perform the following action (the API equivalent of logging in).

Creation:

The creation of a simple project, uploading of jobs, and assignment of a Linguist, including sending an email notification.

Translation:

The actual translation work will be performed outside of the API scenario (in any of the Editors).

API Function:

Once the assignment is finished (marked as Completed by Linguist),

the project's status is set to Completed and the finished document is downloaded from the project.

Methodology

Each individual REST API call has an appropriate method listed. Using an incorrect method (e.g. GET instead of POST in the project creation call) results in an unsuccessful API call.

Step 1: Authentication

There are two authentication methods:

  1. Authentication API call:

    This call generates an authentication token that is valid for 24 hours. The token then needs to be inserted into all the following APIs. This validates the users and allows them to perform any other actions in the account.

  2. oAuth 2.0:

    oAuth 2.0 allows users to validate a certain application in Memsource, which consequently allows its continuous communication with Memsource without the need for further authentication.

For the scenario, the first method will be used. The generated token is required for all following API calls and will not be listed in example parameters.

Use the Login API for authentication with required parameters. In this case, username and password are required.

  • Method

    POST

  • Request URL

    https://cloud.memsource.com/web/api2/v1/auth/login

  • Request body:

    { "userName":"username", "password":"password"}
  • Response

    Authentication token.

Step 2: Project Creation, Import, and Assignment

Project Creation

Useg the Projects API call to create a project with the mandatory parameters name, sourceLang, and targetLangs.

  • Method

    POST

  • Request URL

    https://cloud.memsource.com/web/api2/v1/projects?token=Authentication token

  • Request body

    { "name":"My project", "sourceLang":"en", "targetLangs":[ "de","fr" ]}
  • Response

    Project UID (e.g. KmtNyVlz1skQd2aMVEipp7)

Job Creation

With the UID from the last call, new jobs can be added directly into the newly created project using Create Job.

The expression {projectUid} serves as a placeholder in the request URL where the obtained Project UID is inserted. With the Create Job API call, the Headers of the request must be changed to match the ones required by Memsource (in other calls, Postman automatically adds appropriate headers to the request).

All the import parameters need to be inserted into a custom Memsource header.

The Content-Disposition header must include the filename in a pre-defined format in order for Memsource to correctly process the import request.

To import a source file, go to the body, select binary and the Select File option appears.

  • Method

    POST

  • Request URL

    https://cloud.memsource.com/web/api2/v1/projects/KmtNyVlz1skQd2aMVEipp7/jobs?token=Authentication token

  • (Header) Content-Disposition

    filename*=UTF-8''file.txt

  • (Header) Memsource

    {"targetLangs":["de","fr"]}

  • (Header) Content-Type

    application/octet-stream

  • Response

    Job UID (e.g. dOYgeXzAdAbj4xFjuEVZP2)

  • AsyncRequest UID

Use /api2/v1/async/{asyncRequestId} to check that the job was successfully created and that it can be worked with.

To assign providers to the job (unless assigned directly in the Create job call) use /api2/v1/projects/{projectUid}/jobs/{jobUid} endpoint.

The ID of the Provider that is inserted in the call can be obtained in two ways:

To retrieve the ID from the Memsource application, follow these steps:

  1. From the Setup Setup_gear.png page, scroll down to the Administration section and click on Users or click Users in the sidebar.

    The Users page opens.

  2. Click on the and copy the URL from the browser.

  3. Use this URL as the ID for that user.

Use the List users API call.

This API call does not require any specific parameters, and it will return a list of all users in the account. The response contains both usernames and IDs. An optional parameter, userName, can be added to the query allowing you to list only users with specific usernames.

Notify Assigned Users

The job UID can then be used as an optional parameter in /api2/v1/projects/{projectUid}/jobs/notifyAssigned along with the emailTemplate parameter representing the ID of the email template to be used. This can be obtained from the Memsource UI or by using /api2/v1/emailTemplates.

  • Request URL

    https://cloud.memsource.com/web/api2/v1/projects/KmtNyVlz1skQd2aMVEipp7/jobs/notifyAssigned?token=Authentication token

  • Response

    Empty

This is where the translator would start to work in their account just as if the Memsource UI was being used. After the job is finished, the PM in charge receives a notification, and the next part of the scenario is initiated. A callback can be intercepted via webhooks to automatically start the next part of the scenario but this will not be addressed in this example.

Part 3: Download Translated File, Set Project to Completed

The API call /api2/v1/projects/{projectUid}/jobs/{jobUid}/targetFile with the parameter jobUid can be used to retrieve the translated content.

  • Method

    GET

  • Request URL

    https://cloud.memsource.com/web/api2/v1/projects/KmtNyVlz1skQd2aMVEipp7/jobs/dOYgeXzAdAbj4xFjuEVZP2/targetFile?token=Authentication token

  • Response

    Binary response with the completed file itself

Once the job in the project is completed, use the /api2/v1/projects/{projectUid}/setStatus with the mandatory parameters project and status to change the status of the entire project to Completed. This change is a manual one, but if Project Status Automation is used, the status will be changed automatically. It is also possible to wait for a webhook and initiate other actions based on the callback received.

  • Method

    POST

  • Request URL

    https://cloud.memsource.com/web/api2/v1/projects/KmtNyVlz1skQd2aMVEipp7/setStatus?token=Authentication token

  • Request body

    { "status": "COMPLETED"}
  • Response

    Empty

Was this article helpful?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question you can leave a public comment below or Submit a request to our Support team.
Thank you for your feedback.

Comments

0 comments

Article is closed for comments.