Document Stack
Document Stack
Docs

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/v1

Authentication

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:

MethodUsage
GETRetrieve resources
POSTCreate resources or trigger generation
PUTUpdate resources
DELETERemove 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

EndpointMethodDescription
/api/v1/generatePOSTGenerate a PDF from a template
/api/v1/templatesGETList all templates
/api/v1/templates/:idGETGet a specific template
/api/v1/projectsGETList all projects
/api/v1/projects/:idGETGet 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/pdf is set

Next Steps