TenTags REST API Reference
Generate styled HTML, XLSX (Excel), PDF, and DOCX (Word) documents programmatically from your backend, microservices, or CLI using your TENTAGS_API_TOKEN.
🔑 Authentication
Bearer AuthThe TenTags API uses Bearer Tokens to authenticate HTTP requests. You can generate and manage your TENTAGS_API_TOKEN directly in your User Profile.
How to pass your API Token:
Include your token in the Authorization header or X-TenTags-Api-Key header of all API requests:
Authorization: Bearer tt_live_8f3d...32charshere
X-TenTags-Api-Key: tt_live_8f3d...32charshere
TENTAGS_API_TOKEN in client-side code, public repositories, or frontend bundles. Always send requests from a secure backend environment.
Generate Document
Compiles TenTags layout code into a downloadable file stream in your chosen format (HTML, XLSX, PDF, or DOCX).
Request Headers
| Header | Type | Description |
|---|---|---|
| Authorization* | string | Bearer tt_live_... formatted API token. |
| Content-Type* | string | Must be application/json. |
JSON Request Body Parameters
| Parameter | Type | Description |
|---|---|---|
| style_csv | string | Raw style TenTags CSV string. Required if template_id is not provided. |
| data_csv | string | Raw data TenTags CSV string. Required if template_id is not provided. |
| template_id | integer | ID of a saved template from your library. Replaces manual style_csv and data_csv. |
| format | string | Output format: "html", "xlsx", "pdf", "docx". Default is "html". |
| orientation | string | Page orientation: "auto", "portrait", "landscape". Applicable for PDF/DOCX. |
| page_size | string | Page geometry: "auto", "a4", "a3", "letter". Applicable for PDF/DOCX. |
💻 Code Examples & SDK Integration
Select your programming language to see complete working examples for generating documents using /api/generate:
curl -X POST https://tentags.org/api/generate \
-H "Authorization: Bearer YOUR_TENTAGS_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"style_csv": "<bg=#0f172a><color=#ffffff><center></center></color></bg>;",
"data_csv": "Sales Report 2026;",
"format": "pdf",
"orientation": "auto"
}' \
--output report.pdf
import requests
url = "https://tentags.org/api/generate"
headers = {
"Authorization": "Bearer YOUR_TENTAGS_API_TOKEN",
"Content-Type": "application/json"
}
payload = {
"style_csv": "<bg=#0f172a><color=#ffffff><center></center></color></bg>;",
"data_csv": "Sales Report 2026;",
"format": "docx",
"orientation": "portrait"
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
with open("report.docx", "wb") as f:
f.write(response.content)
print("✅ Document created successfully: report.docx")
else:
print(f"❌ Error {response.status_code}: {response.json()}")
const fs = require('fs');
async function generateDocument() {
const response = await fetch('https://tentags.org/api/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TENTAGS_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
style_csv: '<bg=#0f172a><color=#ffffff><center></center></color></bg>;',
data_csv: 'Sales Report 2026;',
format: 'xlsx'
})
});
if (response.ok) {
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('spreadsheet.xlsx', buffer);
console.log('✅ Spreadsheet generated successfully!');
} else {
const err = await response.json();
console.error('❌ Generation error:', err);
}
}
generateDocument();
<?php
$url = "https://tentags.org/api/generate";
$token = "YOUR_TENTAGS_API_TOKEN";
$data = [
"style_csv" => "<bg=#0f172a><color=#ffffff><center></center></color></bg>;",
"data_csv" => "Sales Report 2026;",
"format" => "html"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $token",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>
package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func main() {
payload := map[string]string{
"style_csv": "<bg=#0f172a><color=#ffffff><center></center></color></bg>;",
"data_csv": "Sales Report 2026;",
"format": "pdf",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://tentags.org/api/generate", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_TENTAGS_API_TOKEN")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil || resp.StatusCode != 200 {
panic("Failed to generate document")
}
defer resp.Body.Close()
out, _ := os.Create("report.pdf")
defer out.Close()
io.Copy(out, resp.Body)
}
📊 Quotas & Subscription Limits
API quotas are enforced per monthly billing cycle based on your active subscription plan:
| Plan Tier | Monthly API Requests | Allowed Formats | Price |
|---|---|---|---|
| Free Plan | 20 requests / mo | HTML, XLSX | $0 |
| Starter Plan | 500 requests / mo | HTML, XLSX, PDF, DOCX | $2.00 / mo |
| Pro Plan | 10,000 requests / mo | HTML, XLSX, PDF, DOCX | $40.00 / mo |
| Advanced Plan | 100,000 requests / mo | HTML, XLSX, PDF, DOCX | $120.00 / mo |
⚠️ Error Handling
The TenTags API uses standard HTTP response status codes to indicate the success or failure of an API request:
| Status Code | Meaning | Description |
|---|---|---|
| 200 OK | Success | Document generated and returned successfully. |
| 401 Unauthorized | Invalid Token | Missing or invalid TENTAGS_API_TOKEN. |
| 403 Forbidden | Format Restricted | Requested export format (e.g. PDF/DOCX) is not available on Free tier. |
| 429 Limit Exceeded | Quota Exceeded | Monthly API request limit reached for your plan. |