API Overview
Introduction to the Document Stack REST API for programmatic document generation.
Introduction
The Document Stack API is a RESTful API that lets you generate, manage, and retrieve PDF documents programmatically. Every feature available in the dashboard can be accessed through the API.
Base URL
text
https://api.documentstack.dev/api/v1Authentication
All API requests require authentication via an API key passed as a Bearer token in the Authorization header:
cURL Example
curl -X POST https://api.documentstack.dev/api/v1/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"templateId": "tmpl_abc123", "data": {"name": "Alice"}}'Keep Keys Secret
Never expose your API key in client-side code. Always make API calls from your server or trusted backend.Request Format
All request bodies must be JSON (set Content-Type: application/json). The API accepts standard HTTP methods:
| Method | Usage |
|---|---|
GET | Retrieve resources |
POST | Create resources or trigger generation |
PUT | Update resources |
DELETE | Remove resources |
Response Format
All responses return JSON with a consistent structure:
Success Response
{
"success": true,
"data": {
"id": "doc_abc123",
"url": "https://api.documentstack.dev/files/doc_abc123.pdf",
"createdAt": "2025-01-15T10:30:00Z"
}
}Error Response
{
"success": false,
"error": "Template not found"
}Available Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/v1/generate | POST | Generate a PDF from a template |
/api/v1/templates | GET | List all templates |
/api/v1/templates/:id | GET | Get a specific template |
/api/v1/projects | GET | List all projects |
/api/v1/projects/:id | GET | Get a specific project |
Content Types
When generating documents, the API can return:
- JSON — Metadata with a URL to the generated PDF
- Binary (PDF) — Direct PDF binary stream when
Accept: application/pdfis set
Next Steps
- API Keys — Create and manage API keys
- Generate API — Generate PDFs via the API
- Error Handling — Error codes and troubleshooting
- Rate Limits — Request limits and quotas