Upload and Manage Source Files via the API
Use this API to upload new source files, replace outdated ones, track translation progress, and download completed translations.
Whether you’re managing a single file or automating a continuous localization workflow, this API gives you full control over the content you send for translation and how you receive the translations.
API Quick Links
How the PTC API Identifies and Organizes Source Files
The PTC API uses a flexible system based on file tags and file paths. These parameters work together to ensure every file you upload, update, or request is clearly defined and easy to manage.
File Tags
File tags are a flexible way to group and organize source files in translation projects. You can use them like categories to match your workflow needs. For example, file tags can show:
- Version control:
v1.0,beta,production - Feature branches:
user-auth,dashboard-redesign - Application context:
mobile-app,admin-panel,marketing - Team ownership:
frontend-team,content-team - Workflow state:
approved,pending-review,priority-high
File tag names are optional in most API operations. However, every source file always has at least one tag. A default file tag is automatically created and assigned when a project is set up. This default behavior keeps projects organized even in simple setups, while still allowing you to build more advanced tagging structures when needed.
File Tag Name + File Path
Each source file is uniquely identified by the combination of its file tag name and file path.
- If you do not provide a custom file tag when uploading or processing a file, the default tag will be assigned automatically.
- A file’s tag name + path together define its identity. This combination ensures each file is unique within your project, even if different versions or contexts share the same file path.
Query Parameters
When retrieving a specific file, related endpoints can accept query parameters such as:
file_tag_name– The tag associated with the filefile_path– The path to the file
These parameters allow you to precisely locate and retrieve the correct files from your project.
List All Source Files in the Project
Lists all the source files in your project, with options to filter, sort, and paginate the results. This is useful when you want to browse your files, check their status, or find specific files based on tag, path, or upload method.
HTTP Request
GET https://app.ptc.wpml.org/api/v1/source_filesParameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
page |
integer | No | 1 |
The page number for pagination. Must be greater than 0. |
per_page |
integer | No | 50 |
The number of items per page. Must be greater than 0. |
order_by |
string | No | created_at |
The field to sort by. Allowed values: id, created_at, updated_at. |
sort |
string | No | desc |
The direction of sorting. Allowed values: asc, desc. |
file_path |
string | No | – | Filters by exact file path. |
upload_origin |
string | No | – | Filters by how the file was uploaded. Allowed values include: git, manual, api. |
Responses
Success Response
{
"source_files": [
{
"id": 123,
"file_path": "locales/en.po",
"translation_path": "locales/{{lang}}.po",
"additional_translation_files": ["locales/{{lang}}.mo"],
"status": "completed",
"upload_origin": "git",
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T14:20:00.000Z",
"file_tag": {
"id": 456,
"name": "frontend"
},
"download_url": "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=locales/en.po&file_tag_name=frontend"
}
],
"pagination": {
"page": 1,
"per_page": 50,
"total": 150,
"total_pages": 3,
"has_next_page": true,
"has_previous_page": false
}
}Response Schema
Source File Object:
| Field | Type | Description |
|---|---|---|
id |
integer | The unique identifier for the source file. |
file_path |
string | The path to the source file within the project. |
translation_path |
string | The pattern for where translated files should be saved. |
additional_translation_files |
array[string] | The paths for any additional output files. |
status |
string | The current processing status of the source file. |
upload_origin |
string | How the file was uploaded (git, manual, api). |
created_at |
string | An ISO 8601 timestamp indicating when the source file was originally created. |
updated_at |
string | An ISO 8601 timestamp indicating when the source file was last updated. |
file_tag |
object | Information about the file tag. |
file_tag.id |
integer | The file tag identifier. |
file_tag.name |
string | The file tag name. |
download_url |
string | The URL to download translations for this source file. |
Pagination Object:
| Field | Type | Description |
|---|---|---|
page |
integer | The current page number. |
per_page |
integer | The number of items per page. |
total |
integer | The total number of source files. |
total_pages |
integer | The total number of pages. |
has_next_page |
boolean | Whether there is a next page available. |
has_previous_page |
boolean | Whether there is a previous page available. |
Error Responses
Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Invalid Parameters
{
"error": "Invalid parameters provided."
}Example Requests
Basic request:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"Filtered request:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files?file_tag_name=frontend&page=1&per_page=25&order_by=updated_at&sort=desc" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"Code Examples
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files?file_tag_name=frontend&page=1&per_page=25" \
-H "Authorization: Bearer YOUR_API_TOKEN"require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files')
uri.query = URI.encode_www_form(file_tag_name: 'frontend', page: 1, per_page: 25)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
response = http.request(request)
puts response.bodyimport requests
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
params = {
'file_tag_name': 'frontend',
'page': 1,
'per_page': 25
}
response = requests.get('https://app.ptc.wpml.org/api/v1/source_files',
headers=headers, params=params)
print(response.json())<?php
$params = http_build_query([
'file_tag_name' => 'frontend',
'page' => 1,
'per_page' => 25
]);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.ptc.wpml.org/api/v1/source_files?{$params}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
curl_close($curl);
print_r(json_decode($response, true));
?>import okhttp3.*;
OkHttpClient client = new OkHttpClient();
HttpUrl url = HttpUrl.parse("https://app.ptc.wpml.org/api/v1/source_files")
.newBuilder()
.addQueryParameter("file_tag_name", "frontend")
.addQueryParameter("page", "1")
.addQueryParameter("per_page", "25")
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://app.ptc.wpml.org/api/v1/source_files", nil)
q := req.URL.Query()
q.Add("file_tag_name", "frontend")
q.Add("page", "1")
q.Add("per_page", "25")
req.URL.RawQuery = q.Encode()
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var response = await client.GetAsync("https://app.ptc.wpml.org/api/v1/source_files?file_tag_name=frontend&page=1&per_page=25");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);const axios = require('axios');
const response = await axios.get('https://app.ptc.wpml.org/api/v1/source_files', {
headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' },
params: {
file_tag_name: 'frontend',
page: 1,
per_page: 25
}
});
console.log(response.data);Get Translation Strings
Retrieves all translatable strings from a specific source file, along with their existing translations in all target languages.
This endpoint is useful for fetching content that needs to be translated or has already been translated. The source file is identified by file_path and file_tag_name.
HTTP Request
GET https://app.ptc.wpml.org/api/v1/source_files/translation_stringsParameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file_path |
string | Yes | – | The path to the source file within the project. |
file_tag_name |
string | No | – | The file tag name. If not provided, the project’s default tag is used. |
page |
integer | No | 1 |
The page number for pagination (used as a cursor). Must be greater than 0. |
q |
string | No | – | The search query to filter translation strings by their source text. |
Responses
Success Response
{
"total_strings_count": 1250,
"translation_strings": [
{
"source": "Welcome to our application",
"translations": {
"es": "Bienvenido a nuestra aplicación",
"fr": "Bienvenue dans notre application",
"de": "Willkommen in unserer Anwendung"
}
},
{
"source": "Login",
"translations": {
"es": "Iniciar sesión",
"fr": "Connexion",
"de": "Anmelden"
}
}
],
"cursor": 1
}Response Schema
| Field | Type | Description |
|---|---|---|
total_strings_count |
integer | The total number of translatable strings in the source file. |
translation_strings |
array[object] | The array of translation string objects (paginated, max 500 per page). |
translation_strings[].source |
string | The original source text to be translated. |
translation_strings[].translations |
object | A hash of translations where the keys are language ISO codes and the values are the translated text. |
cursor |
integer | The current page cursor used for pagination. |
Error Responses
Source File Not Found
{
"error": "Source file not found"
}Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Invalid Parameters
{
"error": "Invalid parameters provided."
}Example Requests
Basic request:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_strings?file_path=locales/en.po" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"A request with file tag:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_strings?file_path=locales/en.po&file_tag_name=frontend" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"A request with pagination and search:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_strings?file_path=locales/en.po&file_tag_name=frontend&page=2&q=welcome" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"Code Examples
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_strings?file_path=locales/en.po&file_tag_name=frontend&page=1&q=login" \
-H "Authorization: Bearer YOUR_API_TOKEN"require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files/translation_strings')
uri.query = URI.encode_www_form(file_path: 'locales/en.po', file_tag_name: 'frontend', page: 1, q: 'login')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
response = http.request(request)
puts response.bodyimport requests
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
params = {
'file_path': 'locales/en.po',
'file_tag_name': 'frontend',
'page': 1,
'q': 'login'
}
response = requests.get('https://app.ptc.wpml.org/api/v1/source_files/translation_strings',
headers=headers, params=params)
print(response.json())<?php
$params = http_build_query([
'file_path' => 'locales/en.po',
'file_tag_name' => 'frontend',
'page' => 1,
'q' => 'login'
]);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.ptc.wpml.org/api/v1/source_files/translation_strings?{$params}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
curl_close($curl);
print_r(json_decode($response, true));
?>import okhttp3.*;
OkHttpClient client = new OkHttpClient();
HttpUrl url = HttpUrl.parse("https://app.ptc.wpml.org/api/v1/source_files/translation_strings")
.newBuilder()
.addQueryParameter("file_path", "locales/en.po")
.addQueryParameter("file_tag_name", "frontend")
.addQueryParameter("page", "1")
.addQueryParameter("q", "login")
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://app.ptc.wpml.org/api/v1/source_files/translation_strings", nil)
q := req.URL.Query()
q.Add("file_path", "locales/en.po")
q.Add("file_tag_name", "frontend")
q.Add("page", "1")
q.Add("q", "login")
req.URL.RawQuery = q.Encode()
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var response = await client.GetAsync("https://app.ptc.wpml.org/api/v1/source_files/translation_strings?file_path=locales/en.po&file_tag_name=frontend&page=1&q=login");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);const axios = require('axios');
const response = await axios.get('https://app.ptc.wpml.org/api/v1/source_files/translation_strings', {
headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' },
params: {
file_path: 'locales/en.po',
file_tag_name: 'frontend',
page: 1,
q: 'login'
}
});
console.log(response.data);Create the Source File
Registers a new source file in your project so it’s ready for translation.
This endpoint creates the file entry and sets up its translation configuration, but does not attach the actual file content.
After creating the file, you’ll need to use the Process the Source File endpoint to upload the content and start the translation process.
HTTP Request
POST https://app.ptc.wpml.org/api/v1/source_filesParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
string | Yes | The path where the source file should be stored in the project. Must have a supported extension. |
output_file_path |
string | Yes | The output path pattern for translated files. Use {{lang}} as a placeholder for the language code. |
translations |
array[object] | No | The pre-existing translation files to upload alongside the source file. These files will be stored as provided, and their strings will not be re-translated by PTC. Note that providing existing translations is not recommended, as PTC produces better results when it can use your project’s full context and translate from scratch. |
translations[].target_language_iso |
string | Yes | The ISO code of the target language for this translation. You can find the full list of supported languages and their ISO codes in the List All Target Languages endpoint. |
translations[].file |
file | Yes | The translation file to upload. |
additional_translation_files |
array[object] | No | Additional output file configurations for specific formats. To see which formats support additional output files, refer to the List Supported File Formats endpoint. For unsupported formats, this field will be ignored. |
additional_translation_files[].type |
string | Yes | See supported file formats for more details. |
additional_translation_files[].path |
string | Yes | The path pattern for the file. |
Responses
Success Response
{
"source_file": {
"id": 123,
"file_path": "src/locales/en.json",
"created_at": "2024-01-15T10:30:00.000Z",
"file_tag": {
"id": 456,
"name": "frontend"
}
}
}Response Schema
| Field | Type | Description |
|---|---|---|
source_file.id |
integer | The unique identifier for the created source file. |
source_file.file_path |
string | The path of the source file within the project. |
source_file.created_at |
string | An ISO 8601 timestamp indicating when the source file was originally created. |
source_file.file_tag.id |
integer | The file tag identifier. |
source_file.file_tag.name |
string | The file tag name. |
Error Responses
Validation Failed
{
"success": false,
"error": "Source file creation failed"
}Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Example Requests
Basic source file creation:
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file_path=src/locales/en.json" \
-F "output_file_path=src/locales/{lang}.json" \
-F "file_tag_name=frontend"Request with callback URL:
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file_path=src/locales/messages.po" \
-F "output_file_path=locales/{lang}/messages.po" \
-F "callback_url=https://your-app.com/webhooks/translation-complete"Request with pre-existing translations:
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file_path=src/messages.json" \
-F "output_file_path=locales/{lang}/messages.json" \
-F "translations[0][target_language_iso]=es" \
-F "translations[0][file]=@spanish_translations.json" \
-F "translations[1][target_language_iso]=fr" \
-F "translations[1][file]=@french_translations.json"Request with additional output files:
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file_path=src/messages.po" \
-F "output_file_path=locales/{lang}/messages.po" \
-F "additional_translation_files[mo]=locales/{lang}/messages.mo" \
-F "additional_translation_files[json]=locales/{lang}/messages.json"Code Examples
- JavaScript (FormData)
- Python (requests)
- PHP (cURL)
- Node.js (axios)
- Callback Request Body
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file_path=src/locales/en.json" \
-F "output_file_path=src/locales/{lang}.json"require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.set_form_data(
'file_path' => 'src/locales/en.json',
'output_file_path' => 'src/locales/{lang}.json'
)
response = http.request(request)
puts response.bodyimport requests
headers = {'Authorization': 'Bearer YOUR_API_TOKEN'}
data = {
'file_path': 'src/locales/en.json',
'output_file_path': 'src/locales/{lang}.json'
}
response = requests.post('https://app.ptc.wpml.org/api/v1/source_files', headers=headers, data=data)
print(response.json())<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://app.ptc.wpml.org/api/v1/source_files',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query([
'file_path' => 'src/locales/en.json',
'output_file_path' => 'src/locales/{lang}.json'
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
curl_close($curl);
print_r(json_decode($response, true));
?>import okhttp3.*;
OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("file_path", "src/locales/en.json")
.add("output_file_path", "src/locales/{lang}.json")
.build();
Request request = new Request.Builder()
.url("https://app.ptc.wpml.org/api/v1/source_files")
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.post(body)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());package main
import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
)
func main() {
form := url.Values{}
form.Set("file_path", "src/locales/en.json")
form.Set("output_file_path", "src/locales/{lang}.json")
req, _ := http.NewRequest("POST", "https://app.ptc.wpml.org/api/v1/source_files", strings.NewReader(form.Encode()))
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var form = new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "file_path", "src/locales/en.json" },
{ "output_file_path", "src/locales/{lang}.json" }
});
var response = await client.PostAsync("https://app.ptc.wpml.org/api/v1/source_files", form);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);const axios = require('axios');
const params = new URLSearchParams();
params.append('file_path', 'src/locales/en.json');
params.append('output_file_path', 'src/locales/{lang}.json');
const response = await axios.post('https://app.ptc.wpml.org/api/v1/source_files', params, {
headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' }
});
console.log(response.data);{
"source_file_id": 123,
"status": "completed",
"file_tag_name": "frontend",
"download_url": "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=src/locales/en.json&file_tag_name=frontend",
"file_path": "src/locales/en.json"
}Process the Source File
Uploads content to an existing source file and starts the translation process.
This endpoint replaces the file’s current content, updates the stored translatable strings, and starts automatic translation.
To use this endpoint, the source file must already exist in the project. If you haven’t created it yet, see Create the Source File.
HTTP Request
PUT https://app.ptc.wpml.org/api/v1/source_files/processParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
file | Yes | The source file to upload. The file content is validated to ensure it matches its declared extension. For example, if the file extension is .json, the uploaded content must be valid JSON. |
file_path |
string | Yes | The path to the existing source file in the project that should be updated. |
file_tag_name |
string | No | The name of the file tag associated with the source file. If not provided, the project’s default file tag is used. |
callback_url |
string | No | The URL that receives webhook notifications when file processing is complete. |
Responses
Success Response
{
"source_file": {
"id": 123,
"file_path": "src/locales/en.json",
"created_at": "2024-01-15T10:30:00.000Z",
"file_tag": {
"id": 456,
"name": "frontend"
}
}
}Response Schema
| Field | Type | Description |
|---|---|---|
source_file.id |
integer | The unique identifier for the processed source file. |
source_file.file_path |
string | The path of the source file within the project. |
source_file.created_at |
string | An ISO 8601 timestamp indicating when the source file was originally created. |
source_file.file_tag.id |
integer | The file tag identifier. |
source_file.file_tag.name |
string | The file tag name. |
Error Responses
Source File Not Found
{
"errors": {
"file": ["File format is invalid or not supported"]
}
}Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Workflow
- Prerequisite: The source file must already be created via Create the Source File.
- File Upload: New content is uploaded and replaces the existing file content.
- Processing: The new translatable strings are extracted and automatically translated.
- Callback: An optional webhook notification is sent when processing finishes.
Webhook Callback
When a callback_url is provided, PTC will send a POST request to that URL when processing completes.
Callback request body:
{
"source_file_id": 123,
"status": "completed",
"file_tag_name": "frontend",
"download_url": "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=src/locales/en.json&file_tag_name=frontend",
"file_path": "src/locales/en.json"
}Example Requests
Basic file processing:
curl -X PUT "https://app.ptc.wpml.org/api/v1/source_files/process" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file=@updated_translations.json" \
-F "file_path=src/locales/en.json" \
-F "file_tag_name=frontend"Request with callback URL:
curl -X PUT "https://app.ptc.wpml.org/api/v1/source_files/process" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file=@messages.po" \
-F "file_path=locales/messages.po" \
-F "callback_url=https://your-app.com/webhooks/translation-complete"Code Examples
curl -X PUT "https://app.ptc.wpml.org/api/v1/source_files/process" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "file=@updated_translations.json" \
-F "file_path=src/locales/en.json" \
-F "file_tag_name=frontend" \
-F "callback_url=https://your-app.com/webhooks/complete"require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files/process')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.set_form(
[
['file', File.open('updated_translations.json')],
['file_path', 'src/locales/en.json'],
['file_tag_name', 'frontend'],
['callback_url', 'https://your-app.com/webhooks/complete']
],
'multipart/form-data'
)
response = http.request(request)
puts response.bodyimport requests
headers = {'Authorization': 'Bearer YOUR_API_TOKEN'}
files = {'file': open('updated_translations.json', 'rb')}
data = {
'file_path': 'src/locales/en.json',
'file_tag_name': 'frontend',
'callback_url': 'https://your-app.com/webhooks/complete'
}
response = requests.put('https://app.ptc.wpml.org/api/v1/source_files/process',
headers=headers, files=files, data=data)
print(response.json())<?php
$post_data = [
'file' => new CURLFile('updated_translations.json'),
'file_path' => 'src/locales/en.json',
'file_tag_name' => 'frontend',
'callback_url' => 'https://your-app.com/webhooks/complete'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://app.ptc.wpml.org/api/v1/source_files/process',
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
curl_close($curl);
print_r(json_decode($response, true));
?>import okhttp3.*;
import java.io.File;
OkHttpClient client = new OkHttpClient();
MultipartBody body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", "updated_translations.json",
RequestBody.create(new File("updated_translations.json"), MediaType.parse("application/octet-stream")))
.addFormDataPart("file_path", "src/locales/en.json")
.addFormDataPart("file_tag_name", "frontend")
.addFormDataPart("callback_url", "https://your-app.com/webhooks/complete")
.build();
Request request = new Request.Builder()
.url("https://app.ptc.wpml.org/api/v1/source_files/process")
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.put(body)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
var buf bytes.Buffer
w := multipart.NewWriter(&buf)
file, _ := os.Open("updated_translations.json")
defer file.Close()
fw, _ := w.CreateFormFile("file", "updated_translations.json")
io.Copy(fw, file)
w.WriteField("file_path", "src/locales/en.json")
w.WriteField("file_tag_name", "frontend")
w.WriteField("callback_url", "https://your-app.com/webhooks/complete")
w.Close()
req, _ := http.NewRequest("PUT", "https://app.ptc.wpml.org/api/v1/source_files/process", &buf)
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
req.Header.Add("Content-Type", w.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var form = new MultipartFormDataContent();
form.Add(new StreamContent(File.OpenRead("updated_translations.json")), "file", "updated_translations.json");
form.Add(new StringContent("src/locales/en.json"), "file_path");
form.Add(new StringContent("frontend"), "file_tag_name");
form.Add(new StringContent("https://your-app.com/webhooks/complete"), "callback_url");
var response = await client.PutAsync("https://app.ptc.wpml.org/api/v1/source_files/process", form);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('file', fs.createReadStream('updated_translations.json'));
form.append('file_path', 'src/locales/en.json');
form.append('file_tag_name', 'frontend');
form.append('callback_url', 'https://your-app.com/webhooks/complete');
const response = await axios.put('https://app.ptc.wpml.org/api/v1/source_files/process', form, {
headers: {
...form.getHeaders(),
'Authorization': 'Bearer YOUR_API_TOKEN'
}
});
console.log(response.data);Supported File Formats
The endpoint supports various translatable file formats including JSON, PO/POT, XLIFF, and Properties files, among others. File format validation occurs during upload to ensure compatibility.
Use the List Supported File Formats endpoint to get the full list of supported formats.
Get the Translation Status
Retrieves the current translation progress for a specific source file, including how much is completed and its overall processing status.
This is useful for:
- Progress monitoring – Tracking translation progress for long-running jobs
- UI updates – Displaying completion percentages in your application
- Workflow integration – Triggering actions when translation reaches a defined threshold
HTTP Request
GET https://app.ptc.wpml.org/api/v1/source_files/translation_statusParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
string | Yes | The path to the source file within the project. |
file_tag_name |
string | No | The file tag name. If not provided, the project’s default file tag is used. |
Responses
Success Response
{
"translation_status": {
"status": "completed",
"completeness": 100
}
}Response Schema
| Field | Type | Description |
|---|---|---|
translation_status.status |
string | The current processing status of the source file. See status values below. |
translation_status.completeness |
number | The percentage of translated strings (0–100). Calculated as (completed_translatable_strings / total_translatable_strings) × 100. |
Status Values
The status field can contain the following values:
| Status | Description |
|---|---|
pending |
The source file is waiting to be processed. |
processing |
The translation is currently in progress. |
completed |
All translations have been completed. |
failed |
The translation process ran into errors. |
Error Responses
Source File Not Found
{
"error": "Source file not found"
}Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Invalid Parameters
{
"error": "Invalid parameters provided."
}Example Requests
Basic request:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_status?file_path=locales/en.po" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"Request with file tag:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_status?file_path=locales/en.po&file_tag_name=frontend" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"Code Examples
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/translation_status?file_path=locales/en.po&file_tag_name=frontend" \
-H "Authorization: Bearer YOUR_API_TOKEN"require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files/translation_status')
uri.query = URI.encode_www_form(file_path: 'locales/en.po', file_tag_name: 'frontend')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
response = http.request(request)
require 'json'
data = JSON.parse(response.body)
puts "Translation #{data['translation_status']['completeness']}% complete"import requests
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
params = {
'file_path': 'locales/en.po',
'file_tag_name': 'frontend'
}
response = requests.get('https://app.ptc.wpml.org/api/v1/source_files/translation_status',
headers=headers, params=params)
data = response.json()
print(f"Translation {data['translation_status']['completeness']}% complete")<?php
$params = http_build_query([
'file_path' => 'locales/en.po',
'file_tag_name' => 'frontend'
]);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.ptc.wpml.org/api/v1/source_files/translation_status?{$params}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response, true);
echo "Translation " . $data['translation_status']['completeness'] . "% complete";
?>import okhttp3.*;
OkHttpClient client = new OkHttpClient();
HttpUrl url = HttpUrl.parse("https://app.ptc.wpml.org/api/v1/source_files/translation_status")
.newBuilder()
.addQueryParameter("file_path", "locales/en.po")
.addQueryParameter("file_tag_name", "frontend")
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://app.ptc.wpml.org/api/v1/source_files/translation_status", nil)
q := req.URL.Query()
q.Add("file_path", "locales/en.po")
q.Add("file_tag_name", "frontend")
req.URL.RawQuery = q.Encode()
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var response = await client.GetAsync("https://app.ptc.wpml.org/api/v1/source_files/translation_status?file_path=locales/en.po&file_tag_name=frontend");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);const axios = require('axios');
const response = await axios.get('https://app.ptc.wpml.org/api/v1/source_files/translation_status', {
headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' },
params: {
file_path: 'locales/en.po',
file_tag_name: 'frontend'
}
});
console.log(`Translation ${response.data.translation_status.completeness}% complete`);Download All Translations
Downloads all translated files for a specific source file as a ZIP archive.
This endpoint creates and returns a compressed archive containing all translation files in the target languages for the specified source file.
If no translations are available for the file, the request will return a 404 Not Found error.
HTTP Request
GET https://app.ptc.wpml.org/api/v1/source_files/download_translationsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
string | Yes | The path to the source file within the project. |
file_tag_name |
string | No | The file tag name. If not provided, the project’s default file tag is used. A source file is uniquely identified by the combination of file_path and file_tag_name. |
Responses
Success Response
{
"status": "processing",
"message": "Translations are still in progress. Please retry after the specified delay.",
"retry_after": 30
}PTC processes translations asynchronously. There’s usually a short wait between uploading a source file and having translations available to download.
When this happens, wait the number of seconds specified in Retry-After.
Error Responses
Source File Not Found
{
"error": "Source file not found"
}No Translations Available
{
"error": "No translations are available for this source file"
}Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Invalid Parameters
{
"error": "Invalid parameters provided."
}Example Requests
Basic request:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=locales/en.po" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-o translations.zipRequest with file tag:
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=locales/en.po&file_tag_name=frontend" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-o frontend-translations.zipCode Examples
curl -X GET "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=locales/en.po&file_tag_name=frontend" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-o translations.zip
# 200 -> saves the zip; 202 -> {"status":"processing","retry_after":N} (retry later);
# 404 -> {"error":"No translations are available for this source file"}require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files/download_translations')
uri.query = URI.encode_www_form(file_path: 'locales/en.po', file_tag_name: 'frontend')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
response = http.request(request)
if response.code == '200'
File.binwrite('translations.zip', response.body)
puts 'Translations downloaded successfully'
elsif response.code == '202'
puts 'Translations are still processing — retry after the Retry-After interval'
elsif response.code == '404'
puts 'No translations are available for this source file yet'
endimport requests
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
params = {
'file_path': 'locales/en.po',
'file_tag_name': 'frontend'
}
response = requests.get('https://app.ptc.wpml.org/api/v1/source_files/download_translations',
headers=headers, params=params)
if response.status_code == 200:
with open('translations.zip', 'wb') as f:
f.write(response.content)
print('Translations downloaded successfully')
elif response.status_code == 202:
print('Translations are still processing — retry after the Retry-After interval')
elif response.status_code == 404:
print('No translations are available for this source file yet')<?php
$params = http_build_query([
'file_path' => 'locales/en.po',
'file_tag_name' => 'frontend'
]);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.ptc.wpml.org/api/v1/source_files/download_translations?{$params}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode === 200) {
file_put_contents('translations.zip', $response);
echo 'Translations downloaded successfully';
} elseif ($httpCode === 202) {
echo 'Translations are still processing — retry after the Retry-After interval';
} elseif ($httpCode === 404) {
echo 'No translations are available for this source file yet';
}
?>import okhttp3.*;
import java.nio.file.*;
OkHttpClient client = new OkHttpClient();
HttpUrl url = HttpUrl.parse("https://app.ptc.wpml.org/api/v1/source_files/download_translations")
.newBuilder()
.addQueryParameter("file_path", "locales/en.po")
.addQueryParameter("file_tag_name", "frontend")
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.build();
Response response = client.newCall(request).execute();
if (response.code() == 200) {
Files.write(Paths.get("translations.zip"), response.body().bytes());
System.out.println("Translations downloaded successfully");
} else if (response.code() == 202) {
System.out.println("Translations are still processing — retry after the Retry-After interval");
} else if (response.code() == 404) {
System.out.println("No translations are available for this source file yet");
}package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://app.ptc.wpml.org/api/v1/source_files/download_translations", nil)
q := req.URL.Query()
q.Add("file_path", "locales/en.po")
q.Add("file_tag_name", "frontend")
req.URL.RawQuery = q.Encode()
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
if resp.StatusCode == 200 {
body, _ := io.ReadAll(resp.Body)
os.WriteFile("translations.zip", body, 0644)
fmt.Println("Translations downloaded successfully")
} else if resp.StatusCode == 202 {
fmt.Println("Translations are still processing — retry after the Retry-After interval")
} else if resp.StatusCode == 404 {
fmt.Println("No translations are available for this source file yet")
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var response = await client.GetAsync("https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=locales/en.po&file_tag_name=frontend");
if ((int)response.StatusCode == 200) {
var bytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("translations.zip", bytes);
Console.WriteLine("Translations downloaded successfully");
} else if ((int)response.StatusCode == 202) {
Console.WriteLine("Translations are still processing — retry after the Retry-After interval");
} else if ((int)response.StatusCode == 404) {
Console.WriteLine("No translations are available for this source file yet");
}const axios = require('axios');
const fs = require('fs');
const response = await axios.get('https://app.ptc.wpml.org/api/v1/source_files/download_translations', {
headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' },
responseType: 'stream',
validateStatus: (s) => s === 200 || s === 202 || s === 404
});
if (response.status === 200) {
response.data.pipe(fs.createWriteStream('translations.zip'));
console.log('Translations downloaded successfully');
} else if (response.status === 202) {
console.log('Translations are still processing — retry after the Retry-After interval');
} else if (response.status === 404) {
console.log('No translations are available for this source file yet');
}Upload Source Files in Bulk
Uploads a ZIP archive containing multiple translatable files. Each file in the archive is extracted, validated, and processed. Supported formats are identified automatically.
This is the batch version of Process the Source File, designed to speed up large-scale updates.
Additional Information
- If a file matches an existing source file, it is updated with the new content, and translations are triggered again.
- If a file is supported but does not match any existing source file, it is added to the
not_found_fileslist and ignored. - Files with unsupported formats are listed under
unsupported_filesand ignored. - Files with invalid content are also listed under
unsupported_filesand ignored. - Large archives may take longer to process. Files are processed one by one to manage resources, so it is best to split very large uploads (more than 100 files) into smaller batches. All files in the archive are set to translate automatically.
- The uploaded ZIP must be valid and readable. All files inside must be in a supported format. File names should not include special characters that could cause path issues.
- If a
callback_urlis provided, aPOSTrequest is sent for each processed source file with its results.
HTTP Request
POST https://app.ptc.wpml.org/api/v1/source_files/bulkParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
zip_file |
file | Yes | A ZIP archive containing the source files to upload. It must be a valid ZIP file. |
file_tag_name |
string | No | The file tag name to associate with all source files in the archive. If not specified, the project’s default file tag is used. Each source file is uniquely identified by the combination of file_path and file_tag_name. |
callback_url |
string | No | The URL that receives webhook notifications when each file is processed. |
Expected ZIP File Structure
The ZIP file can contain source files in any directory structure. The directory structure is preserved, and files are processed recursively.
Example ZIP Structure:
source-files.zip
├── locales/
│ ├── messages-en.po
│ ├── validation-en.po
│ └── admin-en.po
├── frontend/
│ ├── components-en.json
│ └── pages-en.json
│ └── not-found-en.json
├── app-strings-en.properties
└── readme.txt (will be ignored)
Supported File Types:
- JSON:
.jsonfiles - Gettext:
.po,.potfiles - Properties:
.propertiesfiles - YAML:
.yml,.yamlfiles - XML:
.xmlfiles - Strings:
.stringsfiles - XLIFF:
.xliff,.xlffiles - CSV:
.csvfiles - PHP:
.phpfiles
Responses
Success Response
{
"success": true,
"file_tag": {
"id": 456,
"name": "backend"
},
"processed_files": [
{
"id": 123,
"file_path": "locales/messages-en.po",
"created_at": "2024-01-15T10:30:00.000Z",
"file_tag": {
"id": 456,
"name": "backend"
}
},
{
"id": 124,
"file_path": "locales/validation-en.po",
"created_at": "2024-01-15T10:30:05.000Z",
"file_tag": {
"id": 456,
"name": "backend"
}
}
],
"unsupported_files": [
"readme.txt",
"config.ini"
],
"not_found_files": ["frontend/not-found-en.json"]
}Response Schema
| Field | Type | Description |
|---|---|---|
success |
boolean | Whether the bulk upload operation was successful. |
file_tag |
object | The file tag information. |
file_tag.id |
integer | The file tag identifier. |
file_tag.name |
string | The file tag name. |
processed_files |
array[object] | An array of source files that were successfully processed. |
processed_files[].id |
integer | The unique identifier for the created source file. |
processed_files[].file_path |
string | The path of the source file, preserving the original ZIP structure. |
processed_files[].created_at |
string | An ISO 8601 timestamp indicating when the source file was created. |
processed_files[].file_tag |
object | The file tag information. |
processed_files[].file_tag.id |
integer | The file tag identifier. |
processed_files[].file_tag.name |
string | The file tag name. |
unsupported_files |
array[string] | An array of file names that are not in a supported format. |
not_found_files |
array[string] | An array of supported files that did not match any existing source file and were ignored. |
Error Responses
Invalid ZIP File
{
"success": false,
"error": "File format is invalid",
"processed_files": [],
"unsupported_files": []
}Processing Failed
{
"success": false,
"error": "Failed to process ZIP archive",
"processed_files": [],
"unsupported_files": []
}Unauthorized
{
"error": "Unauthorized access. Please provide a valid API token."
}Forbidden
{
"error": "Access denied. Insufficient permissions."
}Webhook Callback
When a callback_url is provided, a POST request is sent for each processed file.
Callback request body (per file):
{
"source_file_id": 123,
"status": "completed",
"file_tag_name": "backend",
"download_url": "https://app.ptc.wpml.org/api/v1/source_files/download_translations?file_path=locales/messages-en.po&file_tag_name=backend",
"file_path": "locales/messages-en.po"
}Example Requests
Basic bulk upload:
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files/bulk" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "zip_file=@source-files.zip" \
-F "file_tag_name=backend"Request with callback URL:
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files/bulk" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "zip_file=@translations.zip" \
-F "file_tag_name=localization" \
-F "callback_url=https://your-app.com/webhooks/bulk-complete"Code Examples
curl -X POST "https://app.ptc.wpml.org/api/v1/source_files/bulk" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "zip_file=@source-files.zip" \
-F "file_tag_name=backend" \
-F "callback_url=https://your-app.com/webhooks/complete"require 'net/http'
require 'uri'
uri = URI('https://app.ptc.wpml.org/api/v1/source_files/bulk')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.set_form(
[
['zip_file', File.open('source-files.zip')],
['file_tag_name', 'backend'],
['callback_url', 'https://your-app.com/webhooks/complete']
],
'multipart/form-data'
)
response = http.request(request)
puts response.bodyimport requests
headers = {'Authorization': 'Bearer YOUR_API_TOKEN'}
files = {'zip_file': open('source-files.zip', 'rb')}
data = {
'file_tag_name': 'backend',
'callback_url': 'https://your-app.com/webhooks/complete'
}
response = requests.post('https://app.ptc.wpml.org/api/v1/source_files/bulk',
headers=headers, files=files, data=data)
print(response.json())<?php
$post_data = [
'zip_file' => new CURLFile('source-files.zip'),
'file_tag_name' => 'backend',
'callback_url' => 'https://your-app.com/webhooks/complete'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://app.ptc.wpml.org/api/v1/source_files/bulk',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
]);
$response = curl_exec($curl);
curl_close($curl);
print_r(json_decode($response, true));
?>import okhttp3.*;
import java.io.File;
OkHttpClient client = new OkHttpClient();
MultipartBody body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("zip_file", "source-files.zip",
RequestBody.create(new File("source-files.zip"), MediaType.parse("application/octet-stream")))
.addFormDataPart("file_tag_name", "backend")
.addFormDataPart("callback_url", "https://your-app.com/webhooks/complete")
.build();
Request request = new Request.Builder()
.url("https://app.ptc.wpml.org/api/v1/source_files/bulk")
.addHeader("Authorization", "Bearer YOUR_API_TOKEN")
.post(body)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
var buf bytes.Buffer
w := multipart.NewWriter(&buf)
file, _ := os.Open("source-files.zip")
defer file.Close()
fw, _ := w.CreateFormFile("zip_file", "source-files.zip")
io.Copy(fw, file)
w.WriteField("file_tag_name", "backend")
w.WriteField("callback_url", "https://your-app.com/webhooks/complete")
w.Close()
req, _ := http.NewRequest("POST", "https://app.ptc.wpml.org/api/v1/source_files/bulk", &buf)
req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")
req.Header.Add("Content-Type", w.FormDataContentType())
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "YOUR_API_TOKEN");
var form = new MultipartFormDataContent();
form.Add(new StreamContent(File.OpenRead("source-files.zip")), "zip_file", "source-files.zip");
form.Add(new StringContent("backend"), "file_tag_name");
form.Add(new StringContent("https://your-app.com/webhooks/complete"), "callback_url");
var response = await client.PostAsync("https://app.ptc.wpml.org/api/v1/source_files/bulk", form);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('zip_file', fs.createReadStream('source-files.zip'));
form.append('file_tag_name', 'backend');
form.append('callback_url', 'https://your-app.com/webhooks/complete');
const response = await axios.post('https://app.ptc.wpml.org/api/v1/source_files/bulk', form, {
headers: {
...form.getHeaders(),
'Authorization': 'Bearer YOUR_API_TOKEN'
}
});
console.log(response.data);Next:
Find supported file formats and target languages via the API →