Document Conversion API
Convert PDF, Word, PowerPoint, Excel, and OpenDocument files with one POST request — including turning a PDF back into an editable DOCX or XLSX.
curl -X POST \ .../api/v1/convert.php \ -H "Authorization: Bearer ..." \ -F "category=document" \ -F "target=PDF" \ -F "file=@report.docx" \ -o output.pdf
https://transconvert.com/api/v1/convert.php
Parameters
| Field | Description |
|---|---|
Authorization | Required. "Bearer tc_live_...". |
category | Set to "document". |
target | Required. Output format code, e.g. "PDF", "DOCX", "XLSX". |
file | Required. The document to convert. |
Examples
curl -X POST \ https://transconvert.com/api/v1/convert.php \ -H "Authorization: Bearer tc_live_your_key_here" \ -F "category=document" \ -F "target=PDF" \ -F "file=@report.docx" \ -o output.pdf
<?php $ch = curl_init('https://transconvert.com/api/v1/convert.php'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer tc_live_your_key_here'], CURLOPT_POSTFIELDS => [ 'category' => 'document', 'target' => 'PDF', 'file' => new CURLFile('report.docx'), ], ]); $response = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($status === 200) { file_put_contents('output.pdf', $response); } else { $error = json_decode($response, true); echo $error['error']['message']; }
const form = new FormData(); form.append('category', 'document'); form.append('target', 'PDF'); form.append('file', new Blob([fs.readFileSync('report.docx')]), 'report.docx'); const res = await fetch('https://transconvert.com/api/v1/convert.php', { method: 'POST', headers: { Authorization: 'Bearer tc_live_your_key_here' }, body: form, }); if (res.ok) { fs.writeFileSync('output.pdf', Buffer.from(await res.arrayBuffer())); } else { const { error } = await res.json(); console.error(error.message); }
import requests with open('report.docx', 'rb') as f: response = requests.post( 'https://transconvert.com/api/v1/convert.php', headers={'Authorization': 'Bearer tc_live_your_key_here'}, data={'category': 'document', 'target': 'PDF'}, files={'file': f}, ) if response.status_code == 200: with open('output.pdf', 'wb') as out: out.write(response.content) else: print(response.json()['error']['message'])
# gem install multipart-post require 'net/http' require 'net/http/post/multipart' url = URI('https://transconvert.com/api/v1/convert.php') File.open('report.docx') do |file| req = Net::HTTP::Post::Multipart.new url, 'category' => 'document', 'target' => 'PDF', 'file' => UploadIO.new(file, 'application/octet-stream', 'report.docx') req['Authorization'] = 'Bearer tc_live_your_key_here' res = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http| http.request(req) end if res.code == '200' File.write('output.pdf', res.body) else puts JSON.parse(res.body)['error']['message'] end end
// Gradle: implementation("com.squareup.okhttp3:okhttp:4.+") OkHttpClient client = new OkHttpClient(); RequestBody body = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("category", "document") .addFormDataPart("target", "PDF") .addFormDataPart("file", "report.docx", RequestBody.create(new File("report.docx"), MediaType.parse("application/octet-stream"))) .build(); Request request = new Request.Builder() .url("https://transconvert.com/api/v1/convert.php") .header("Authorization", "Bearer tc_live_your_key_here") .post(body) .build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { Files.write(Paths.get("output.pdf"), response.body().bytes()); } else { System.err.println(response.body().string()); } }
Response
On success (200): the converted file's raw bytes, with Content-Type and Content-Disposition headers set for it. On failure: a JSON body shaped {"error": {"code": "...", "message": "..."}} with a matching HTTP status code — see Errors below.
| Header | Value |
|---|---|
Content-Type | The converted file's real MIME type (e.g. image/png, application/pdf). |
Content-Disposition | attachment; filename="..." — a suggested filename, same as any file download. |
Content-Length | Size of the response body in bytes. |
Every error follows the same JSON shape, for example a quota being exceeded:
{
"error": {
"code": "quota_exceeded",
"message": "Monthly API allowance of 5000 conversion-minutes reached.",
"limit": 5000,
"used": 5000
}
}
Errors
Every failure returns a JSON error envelope with a "code" your code can branch on, plus a human-readable "message". Some errors include extra fields (quota_exceeded includes "limit" and "used", for example).
| Status & code | When it happens |
|---|---|
401 missing_key | No Authorization header was sent. |
401 invalid_key | The key doesn't exist, or has been revoked. |
403 account_suspended | The account owning this key is suspended. |
403 plan_required | The account is on the Free plan — API access needs Basic, Lite, Pro, or Team. |
400 invalid_category | "category" wasn't "image" or "document". |
400 missing_target | "target" was empty. |
400 no_file | No file was sent, or the upload failed — the field must be named "file". |
413 file_too_large | The file exceeds your plan's max upload size. |
429 quota_exceeded | The plan's monthly conversion-minutes allowance is used up. Resets at the start of the next calendar month. |
429 concurrency_limit | Too many conversions already running at once for this account (shared with the website) — wait for one to finish and retry. |
422 conversion_failed | The file itself couldn't be converted — "message" explains why. The status code varies with the reason: 400/415/422 mean the file or target won't work no matter how many times you retry; 500/503 mean a server-side problem, and 503 specifically is worth a short retry. |
Supported formats
Accepted as source:
PDF, DOCX, DOC, PPTX, PPT, XLSX, XLS, RTF, ODT, ODP, ODS, HTML
Available as target:
PDF, DOCX, DOC, PPTX, PPT, XLSX, XLS, RTF, ODT, ODP, ODS