API
Reference

Complete API documentation for SwishDocs. Build powerful document automation workflows with our REST API.

Base URL

https://api.swishdocs.com

All 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_KEY

Include 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/generate
Required100/min

Generate a PDF from a Google Docs template

GET/templates
Required100/min

List all available templates

POST/templates
Required50/min

Create a new template

GET/usage
Required100/min

Get usage statistics

GET/healthz
None1000/min

Health check endpoint

Code Examples

Real-world examples to help you integrate with SwishDocs.

Generate PDF

curl
curl -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

curl
curl -X GET https://api.swishdocs.com/templates \
  -H "Authorization: Bearer YOUR_API_KEY"

JavaScript SDK

javascript
import 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

python
from 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
}

Official SDKs

Use our official SDKs to integrate SwishDocs into your favorite programming language.

Ready to Start Building?

Get your API key and start automating document generation today.