API
Reference
Complete API documentation for SwishDocs. Build powerful document automation workflows with our REST API.
Base URL
https://api.swishdocs.comAll API requests should be made to this base URL. We use HTTPS for all communications to ensure your data is secure.
Authentication
Authorization: Bearer YOUR_API_KEYInclude your API key in the Authorization header of every request. You can find your API key in your dashboard settings.
API Endpoints
Complete reference for all available API endpoints.
POST
/generateRequired100/min
Generate a PDF from a Google Docs template
GET
/templatesRequired100/min
List all available templates
POST
/templatesRequired50/min
Create a new template
GET
/usageRequired100/min
Get usage statistics
GET
/healthzNone1000/min
Health check endpoint
Code Examples
Real-world examples to help you integrate with SwishDocs.
Generate PDF
curlcurl -X POST https://api.swishdocs.com/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": {
"type": "gdoc",
"id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
},
"data": {
"name": "John Doe",
"amount": "$1,500.00",
"due_date": "2024-01-15"
},
"pdfName": "Invoice_John_Doe"
}'List Templates
curlcurl -X GET https://api.swishdocs.com/templates \
-H "Authorization: Bearer YOUR_API_KEY"JavaScript SDK
javascriptimport SwishDocs from '@swishdocs/sdk';
const client = new SwishDocs({
apiKey: 'YOUR_API_KEY'
});
// Generate PDF
const result = await client.generate({
template: {
type: 'gdoc',
id: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
},
data: {
name: 'John Doe',
amount: '$1,500.00',
due_date: '2024-01-15'
},
pdfName: 'Invoice_John_Doe'
});
console.log('PDF Link:', result.link);Python SDK
pythonfrom swishdocs import SwishDocs
client = SwishDocs(api_key='YOUR_API_KEY')
# Generate PDF
result = client.generate(
template={
'type': 'gdoc',
'id': '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
},
data={
'name': 'John Doe',
'amount': '$1,500.00',
'due_date': '2024-01-15'
},
pdf_name='Invoice_John_Doe'
)
print(f"PDF Link: {result['link']}")Response Examples
Examples of API responses for different scenarios.
Success Response
{
"success": true,
"pdfId": "pdf_abc123def456",
"link": "https://files.swishdocs.com/p/abc123",
"expiresAt": "2024-02-15T10:30:00Z",
"generatedAt": "2024-01-15T10:30:00Z"
}Error Response
{
"success": false,
"error": "invalid_template_id",
"message": "The specified template ID does not exist or is not accessible",
"code": 404
}Ready to Start Building?
Get your API key and start automating document generation today.