{
	"info": {
		"_postman_id": "62d5dbbe-acc5-44ee-aa21-46b5f8fb0778",
		"name": "Smartling API - Job Batches V2",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "38623011"
	},
	"item": [
		{
			"name": "Authenticate",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"pm.environment.set(\"accessToken\", jsonData.response.data.accessToken);",
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"userIdentifier\": \"{{userIdentifier}}\",\n    \"userSecret\": \"{{userSecret}}\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://api.smartling.com/auth-api/v2/authenticate",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"auth-api",
						"v2",
						"authenticate"
					]
				}
			},
			"response": []
		},
		{
			"name": "Create Job",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"postman.setEnvironmentVariable(\"translationJobUid\", jsonData.response.data.translationJobUid);"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{accessToken}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"jobName\": \"example html version 2\",\n    \"targetLocaleIds\": [\"de-BE\",\"fr-CA\"],\n    \"description\": \"Description is optional\",\n    \"dueDate\": \"2026-11-21T01:51:17Z\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://api.smartling.com/jobs-api/v3/projects/{{projectId}}/jobs",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"jobs-api",
						"v3",
						"projects",
						"{{projectId}}",
						"jobs"
					]
				}
			},
			"response": []
		},
		{
			"name": "Create Batch",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"postman.setEnvironmentVariable(\"batchUid\", jsonData.response.data.batchUid);"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{accessToken}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"authorize\": \"false\",\n    \"translationJobUid\": \"{{translationJobUid}}\",\n    \"fileUris\": [\"{{fileUri}}\"]\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://api.smartling.com/job-batches-api/v2/projects/{{projectId}}/batches",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"job-batches-api",
						"v2",
						"projects",
						"{{projectId}}",
						"batches"
					]
				}
			},
			"response": []
		},
		{
			"name": "Upload File to Batch",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{accessToken}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "fileUri",
							"value": "{{fileUri}}",
							"type": "text"
						},
						{
							"key": "file",
							"type": "file",
							"src": []
						},
						{
							"key": "fileType",
							"value": "json",
							"type": "text"
						},
						{
							"key": "localeIdsToAuthorize[]",
							"value": "fr-CA",
							"type": "text"
						},
						{
							"key": "localeIdsToAuthorize[]",
							"value": "de-BE",
							"type": "text"
						},
						{
							"key": "smartling.string_format_paths",
							"value": "html: *",
							"type": "text",
							"disabled": true
						},
						{
							"key": "smartling.translate_paths",
							"value": "[{\"key\": \"{*}\", \"path\": \"*\"}]",
							"type": "text",
							"disabled": true
						},
						{
							"key": "callbackUrl",
							"value": "https://webhook.site/df8a92df-83ba-4424-ab00-fd77d02150e5",
							"type": "text",
							"disabled": true
						},
						{
							"key": "smartling.namespace",
							"value": "testFile.json",
							"type": "text"
						}
					]
				},
				"url": {
					"raw": "https://api.smartling.com/jobs-batch-api/v2/projects/{{projectId}}/batches/{{batchUid}}/file",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"jobs-batch-api",
						"v2",
						"projects",
						"{{projectId}}",
						"batches",
						"{{batchUid}}",
						"file"
					],
					"query": [
						{
							"key": "contextUid",
							"value": "",
							"disabled": true
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "Batch Status",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{accessToken}}",
							"type": "string"
						}
					]
				},
				"method": "GET",
				"header": [],
				"url": {
					"raw": "https://api.smartling.com/jobs-batch-api/v2/projects/{{projectId}}/batches/{{batchUid}}",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"jobs-batch-api",
						"v2",
						"projects",
						"{{projectId}}",
						"batches",
						"{{batchUid}}"
					]
				}
			},
			"response": []
		},
		{
			"name": "Upload HTML Context",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = pm.response.json();",
							"var contextUid = jsonData.response.data.contextUid;",
							"console.log(contextUid)",
							"pm.environment.set(\"contextUid\", contextUid);    ",
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Authorization",
						"value": "Bearer {{accessToken}}",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/x-www-form-urlencoded",
						"type": "text"
					}
				],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "content",
							"type": "file",
							"src": "/Users/gerardmangan/Desktop/context_example.html"
						},
						{
							"key": "name",
							"value": "https://www.example.com/examplepath",
							"type": "text"
						}
					]
				},
				"url": {
					"raw": "https://api.smartling.com/context-api/v2/projects/{{projectId}}/contexts",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"context-api",
						"v2",
						"projects",
						"{{projectId}}",
						"contexts"
					],
					"query": [
						{
							"key": "",
							"value": "",
							"disabled": true
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "Run Automatic Matching",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Authorization",
						"value": "Bearer {{accessToken}}",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"overrideContextOlderThanDays\": 0,\n    \"contentFileUri\": \"example_batch_file_1.json\"\n}"
				},
				"url": {
					"raw": "https://api.smartling.com/context-api/v2/projects/{{projectId}}/contexts/{{contextUid}}/match/async",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"context-api",
						"v2",
						"projects",
						"{{projectId}}",
						"contexts",
						"{{contextUid}}",
						"match",
						"async"
					]
				}
			},
			"response": []
		},
		{
			"name": "GET Status Locale",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{accessToken}}",
							"type": "string"
						}
					]
				},
				"method": "GET",
				"header": [],
				"url": {
					"raw": "https://api.smartling.com/files-api/v2/projects/{{projectId}}/locales/fr-FR/file/status?fileUri=example_batch_file_dec_1.json",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"files-api",
						"v2",
						"projects",
						"{{projectId}}",
						"locales",
						"fr-FR",
						"file",
						"status"
					],
					"query": [
						{
							"key": "fileUri",
							"value": "example_batch_file_dec_1.json"
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "GET Translated File",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{accessToken}}",
							"type": "string"
						}
					]
				},
				"method": "GET",
				"header": [],
				"url": {
					"raw": "https://api.smartling.com/files-api/v2/projects/{{projectId}}/locales/fr-FR/file?fileUri=example_batch_file_1.json&retrievalType=published",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"files-api",
						"v2",
						"projects",
						"{{projectId}}",
						"locales",
						"fr-FR",
						"file"
					],
					"query": [
						{
							"key": "fileUri",
							"value": "example_batch_file_1.json"
						},
						{
							"key": "retrievalType",
							"value": "published"
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "GET Recent",
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "https://api.smartling.com/published-files-api/v2/projects/{{projectId}}/files/list/recently-published?publishedAfter=2024-04-09T11:51:17Z",
					"protocol": "https",
					"host": [
						"api",
						"smartling",
						"com"
					],
					"path": [
						"published-files-api",
						"v2",
						"projects",
						"{{projectId}}",
						"files",
						"list",
						"recently-published"
					],
					"query": [
						{
							"key": "publishedAfter",
							"value": "2024-04-09T11:51:17Z"
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "Authenticate admin user",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"let responseData = pm.response.json();\r",
							"//console.log(responseData.response.data.accessToken);\r",
							"pm.collectionVariables.set(\"sltoken\", responseData.response.data.accessToken);\r",
							"pm.collectionVariables.set(\"accessToken\", responseData.response.data.accessToken);"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "Authorization",
						"value": "",
						"type": "text",
						"disabled": true
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\"userIdentifier\":\"{{admin_user}}\", \"userSecret\":\"{{admin_password}}\"}"
				},
				"url": {
					"raw": "https://{{api.host}}/auth-api/v2/authenticate/user",
					"protocol": "https",
					"host": [
						"{{api.host}}"
					],
					"path": [
						"auth-api",
						"v2",
						"authenticate",
						"user"
					]
				},
				"description": "Authenticate user"
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "locales",
			"value": "\"fr-CA\",\"de-BE\"",
			"type": "string"
		},
		{
			"key": "fileUri",
			"value": "/path2/wordtest.docx",
			"type": "string"
		},
		{
			"key": "projectId",
			"value": "",
			"type": "default"
		},
		{
			"key": "sltoken",
			"value": ""
		},
		{
			"key": "accessToken",
			"value": ""
		}
	]
}