Often-used API Methods with Examples
- 1 API method examples
- 1.1 Creating a project via the API
- 1.1.1 Creating a project without a project template
- 1.1.1.1 What details are required?
- 1.1.1.2 Running the method in Postman
- 1.1.1.3 cURL for the method
- 1.1.2 Creating a project using a template
- 1.1.2.1 What details are required?
- 1.1.2.2 Running the method in Postman
- 1.1.2.3 cURL for the method
- 1.1.1 Creating a project without a project template
- 1.2 Generating a target file
- 1.2.1 Generating target files for all jobs in a project
- 1.2.1.1 What details are required?
- 1.2.1.2 Running the method in Postman
- 1.2.1.3 cURL for the method
- 1.2.2 Generating target files for an individual job in a project
- 1.2.2.1 What details are required?
- 1.2.2.2 Running the method in Postman
- 1.2.2.3 cURL for the method
- 1.2.1 Generating target files for all jobs in a project
- 1.3 Obtaining the status of generated files
- 1.3.1 Using a file ID
- 1.3.1.1 What details are required?
- 1.3.1.2 Running the method in Postman
- 1.3.1.3 cURL for the method
- 1.3.2 Without a file ID
- 1.3.2.1 What details are required?
- 1.3.2.2 Running the method in Postman
- 1.3.2.3 cURL for the method
- 1.3.1 Using a file ID
- 1.4 Downloading a generated file
- 1.4.1 Using a file ID
- 1.4.1.1 What details are required?
- 1.4.1.2 Running the method in Postman
- 1.4.1.3 cURL for the method
- 1.4.2 Without a file ID
- 1.4.2.1 What details are required?
- 1.4.2.2 Running the method in Postman
- 1.4.2.3 cURL for the method
- 1.4.1 Using a file ID
- 1.5 Obtaining the project analysis status
- 1.6 Obtaining a project status
- 1.7 Linguist assignment via the API
- 1.8 Starting a project workflow via the API
- 1.8.1 What details are required?
- 1.8.2 Running the method in Postman
- 1.8.2.1 cURL for the method
- 1.9 Uploading a new source file to an existing project
- 1.1 Creating a project via the API
- 2 Useful tips for prompt engineering
- 2.1 What is cURL?
- 2.2 Why is cURL useful?
- 2.3 How does cURL helps with prompt automation?
- 2.4 Using cURL examples with AI tools
- 2.4.1 How it works
- 2.4.2 Example use case with AI prompting
- 2.4.3 Why this matters
- 2.5 How can I obtain the cURL for my method from Postman?
- 2.6 Tips for prompt engineering with AI tools
- 2.7 Guidelines for safe and effective AI integration
API method examples
IMPORTANT!
In the examples below, we have omitted token generation and authentication. For details of how to generate a Basic token, see the Running your first API method article.
Links to the API documentation are provided for the Cloud instance. If you are using another instance, use the URLs for that instance. For more details, see the Understanding the API Documentation.
Creating a project via the API
This section will guide you through the process for creating a simple project via the API.
Link to the documentation for the method: https://api.xtm-cloud.com/project-manager-api-rest/#tag/Project/operation/createProject.
You can see that the XTM API documentation for the project creation method does not describe required fields in the body. This is not 100% accurate, as some fields are required, but depend on whether a project template is specified during project creation. Consequently, two examples are provided below: one without a project template, and one with a project template. Both examples will also have a file attached, even though it is not required when a project is created via the API.
Creating a project without a project template
What details are required?
Customer ID → XTM Cloud customer for which the project will be created:
Workflow definition name → Workflow definition that will be used in the project. (Instead of a workflow definition name, an
IDcan be used, with theworkflowIdparameter.):
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
POST.
Apply the Header parameter with the authentication token.
Change the body type to
form-data.
Fill the following body parameters:
name → Project name that will be used.
customerId → Customer for which the project will be created.
workflowName → Workflow definition name. This workflow will be applied in the project.
sourceLanguage → Source language code that will be used in the project. Available language codes can be found in the API documentation.
targetLanguages → Target language codes that will be used in the project.
translationFiles[0].file → Not required: attach source file to the project. Remember to change the field type to File, from the default Text.
Click the Send button and run the request.
The project should be created correctly and be visible in XTM Cloud.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects' \
-H 'Authorization: XTM-Basic $TOKEN' \ # Basic token obtained from the auth method
-F 'name="My first project"' \ # Name of your project
-F 'customerId="$CUSTOMERID"' \ # ID of a customer you will be using
-F 'workflowName="translate"' \ # Name of the workflow that the project will have
-F 'sourceLanguage="en_US"' \ # Source language code
-F 'targetLanguages="de_DE"' \ # Target language code, can be multiple divided by a comma
-F 'translationFiles[0].file=@"$PATH"' # Path to uploaded fileCreating a project using a template
What details are required?
Customer ID → XTM Cloud customer for which the project will be created:
Template ID → ID of the project template that the project will use:
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
POST.
Apply the Header parameter with the authentication token.
Change the body type to form-data.
Fill the following body parameters:
name → Project name that will be used.
customerId → Customer for which the project will be created.
templateId → Template that will be used in the project.
translationFiles[0].file → Not required: attach source file to the project. Remember to change the field type to ‘File’, from the default ‘Text’.
Click the Send button and run the request.
The project should be created and available in XTM Cloud.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects' \
-H 'Authorization: XTM-Basic $TOKEN' \ # Basic token obtained from the auth method
-F 'name="My first project"' \ # Name of your project
-F 'customerId="$CUSTOMERID"' \ # ID of a customer you will be using
-F 'templateId="$TEMPLATEID"' \ # ID of the template. Languages and workflows will be taken from the template unless present in the request
-F 'translationFiles[0].file=@"$PATH"' # Path to uploaded fileGenerating a target file
This guide describes how to generate target files for an XTM Cloud project. If required, the procedure below can be modified easily, to enable other types of file to be generated.
Link to the API documentation for the method: https://api.xtm-cloud.com/rest-api/#tag/Project-files/operation/generateFiles.
Generating target files for all jobs in a project
What details are required?
Project ID → ID of the XTM Cloud project for which you want to generate the target files.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
POST.
Change the
{projectId}part in the URL to the project ID of the project for which you want to generate target files.
Apply the Header parameter with the authentication token.
Fill in the following query parameter:
fileType → TARGET
Click the Send button and run the request.
You will obtain the file ID in the response. In the XTM Cloud UI, target file generation will start for all jobs in the project.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/files/generate' \ # ID of the project needs to be replaced
-H 'Authorization: XTM-Basic $TOKEN' \ # Your basic token
-F 'fileType="TARGET"' # File typeGenerating target files for an individual job in a project
What details are required?
Project ID → ID of the XTM Cloud project for which you want to generate the target files.
Job ID → ID of the job for which you want to generate a target file.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
POST.
Change the
{projectId}part in the URL to the project ID of the project for which you want to generate target files.
Apply the Header parameter with the authentication token.
Fill in the following query parameters:
fileType→ TARGET.jobIds→ Job ID of the job for which you want to generate a target file.
Click the Send button and run the request.
You will obtain the file ID in the response and target file generation will start, but only for the job specified in the request.
If you wish, you can enter multiple job IDs in this request, to generate multiple target files at once.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/files/generate' \ # ID of the project needs to be replaced
-H 'Authorization: XTM-Basic $TOKEN' \ # Your basic token
-F 'fileType="TARGET"' \ # File type
-F 'jobIds="$JOBID"' # IDs of the job Obtaining the status of generated files
This section describes how to check whether a file has finished generating in XTM Cloud.
Link to the Documentation for this method: https://api.xtm-cloud.com/rest-api/#tag/Project-files/operation/filesStatus
Using a file ID
What details are required?
Project ID → ID of an XTM Cloud project for which files have been generated.
File ID – ID of a previously generated file, obtained using the generate file API request.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
GET.
Change the
{projectId}part in the URL to the project ID of the project in which you want to check the status of target files.
Apply the Header parameter with the authentication token.
Fill in the following query parameters:
fileIds → File ID of the file whose status you want to check.
Click the Send button and run the request.
You will obtain the status of the file generation in the response. Usually, the response is IN_PROGRESS, meaning that a file is still being generated, or FINISHED, when the file has finished being generated and is ready for download
If you wish, you can enter multiple file IDs in this request, to check multiple files at once.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/files/status?fileIds=$FILEIDS' \ # Fill in your project ID and files IDs
-H 'Authorization: XTM-Basic $TOKEN' # Your basic tokenWithout a file ID
What details are required?
Project ID → ID of an XTM Cloud project for which the target files have been generated.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
GET.
Change the
{projectId}part in the URL with the project ID of the project in which you want to check the status of target files.
Apply the Header parameter with the authentication token.
Fill in the following query parameters:
fileType → Type of the file you want to check (TARGET, in this example).
fileScope → Enter JOB to check the status of individual jobs or PROJECT to check the status of all the files in the project.
Click the Send button and run the request.
You will obtain the status of the file generation in the response. Usually, the response is IN_PROGRESS, meaning that a file is still being generated, or FINISHED, when the file has finished being generated and is ready for download
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/files/status?fileType=TARGET&fileScope=JOB' \ # Replace project ID with an ID of your project
-H 'Authorization: XTM-Basic $TOKEN' # Your basic tokenDownloading a generated file
Use this method to download previously-generated files.
Link to the Documentation for this method: https://api.xtm-cloud.com/rest-api/#tag/Project-files/operation/downloadFile or https://api.xtm-cloud.com/rest-api/#tag/Project-files/operation/downloadFiles
In the examples below, the second method – Download project files – is used.
Using a file ID
What details are required?
Project ID → ID of an XTM Cloud project from which you want to download files.
File ID → ID of a previously-generated file, obtained using the generate file API request.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
GET.
Change the
{projectId}part in the URL to the project ID of the project from which you want to download the target files.
Apply the Header parameter with the authentication token.
Fill in the following query parameters:
fileIds → File ID of the file you want to download.
fileType → Type of file you will attempt to download. In this example: TARGET.
Click the Send button and run the request.
You will obtain the generated files in the response. To download the generated files to your computer, select the Save response to a file button.
The downloaded target files are saved in a ZIP file, which you can open to access them.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/files/status?fileType=TARGET&fileIds=$FILEIDS' \ # Replace project ID with an ID of your project and FILEIDS with IDs of the files from the generation method
-H 'Authorization: XTM-Basic $TOKEN' # Your basic tokenWithout a file ID
What details are required?
Project ID → ID of an XTM Cloud project from which you want to download files.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
GET.
Change the
{projectId}part in the URL to the project ID of the project from which you want to download the target files.
Apply the Header parameter with the authentication token.
Fill in the following query parameters:
fileScope → Scope of the files that are to be downloaded. Enter JOB to download the files for individual jobs or PROJECT to download the files for all project jobs.
fileType → Type of file you will attempt to download.
TARGETin this example.jobIds → Only required if the fileScope setting is
JOB.
Click the Send button and run the request.
You will obtain the generated files in the response. To download the generated files to your computer, select the Save response to a file button.
The downloaded target files are saved in a ZIP file, which you can open to access them.
cURL for the method
curl -L 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/files/download?fileType=TARGET&fileScope=PROJECT' \ # Insert your project id into the URL
-H 'Authorization: XTM-Basic $TOKEN' # Your Basic tokenObtaining the project analysis status
This method can be used to check if the project is still being analyzed.
Link to documentation for this method: https://api.xtm-cloud.com/rest-api/#tag/Project-states/operation/checkProjectAnalysisCompletion.
What details are required?
Project ID → ID of an XTM Cloud project whose analysis status you want to check.
Running the method in Postman
POST.GET.
Change the
{projectId}part in the URL to the project ID of the project whose analysis status you want to check.
Apply the Header parameter with the authentication token.
OPTIONAL: Fill in the following query parameters:
fetchLevel →Specify
JOBSto see the analysis status of all individual jobs. If you run the method withoutJOBS, you will just see the status for the entire project.
Click the Send button and run the request.
Look for the Status in the response for the analysis status for this project. IN_PROGRESS means that it is still being analyzed. FINISHED means that the project is ready for further action.
cURL for the method
curl -L -g 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/analysis' \ # Insert your project id into the URL
-H 'Authorization: XTM-Basic $TOKEN' # Your basic tokenObtaining a project status
This method can be used to check a project’s overall status.
Link to documentation for this method: https://api.xtm-cloud.com/rest-api/#tag/Project-states/operation/checkProjectStatuses.
What details are required?
Project ID – ID of an XTM Cloud project whose status you want to find out.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
GET.
Change the
{projectId}part in the URL to the project ID of the project whose overall status you want to check.
Apply the Header parameter with the authentication token.
OPTIONAL: Fill in the following query parameters:
fetchLevel →
JOBS/STEPS/BUNDLES– set one of these settings to get much more detail about jobs, steps or bundles, in the method.
Click the Send button and run the request.
You will see the status of the project according to the specifiedfetchLevel.
cURL for the method
curl -L -g 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/status?fetchLevel=STEPS' \ # Insert your project id into the URL
-H 'Authorization: XTM-Basic $TOKEN' # Your basic tokenLinguist assignment via the API
This method can be used to assign users to an XTM Cloud project.
Link to documentation for this method: https://api.xtm-cloud.com/rest-api/#tag/Project-workflows/operation/assignUser
What details are required?
Project ID → ID of an XTM Cloud project to which you want to assign Linguists.
User ID → ID of the user that you want to assign.
(Optional) Job ID → Specify this if you want to assign the user to a specific job, not the entire project.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
POST.
Change the
{projectId}part in the URL to the project ID of the project to which you want to assign Linguists.
Apply the Header parameter with the authentication token.
Copy the json sample request from the documentation and paste it into the Body (Raw → Json).
In the body, edit the content so that it contains the data you require.
If you are sending a request without jobIds, assigning a Linguist to every step in the entire project, make sure that the Linguist has the necessary language and step permission set beforehand. If the permissions are not correct, the API response will return an error message to inform you.
Click the Send button and run the request.
A message will inform you about whether the job has been assigned successfully. The assignment should change in the UI.
cURL for the method
curl -L -g 'https://api.xtm-cloud.com/project-manager-api-rest/projects/$PROJECTID/workflow/assign' \ # Insert your project id into the URL
-H 'Authorization: XTM-Basic $TOKEN' \ # Your basic token
-H 'Content-Type: application/json' \
-d '[
{
"user": {
"id": $USERID,
"type": "INTERNAL_USER"
},
"jobIds": [
$JOBID
]
}
]'Starting a project workflow via the API
This method can be used to start a project or selected jobs within it.
Link to documentation for this method: https://api.xtm-cloud.com/rest-api/#tag/Project-workflows/operation/startWorkflow.
What details are required?
Project ID → ID of an XTM Cloud project in which you want to start the workflow.
(Optional) Job ID → To start a specific job, you need its ID.
Running the method in Postman
Copy the URL from the documentation and paste it in. Change the method type to
POST.
Change the
{projectId}part in the URL to the project ID of the project in which you want to start the workflow.
Apply the Header parameter with the authentication token.