Document Stack
Document Stack
Docs

Getting API Keys

Set up API keys to generate PDFs programmatically from your application.

Why You Need an API Key

While you can preview PDFs in the Studio Editor, the real power of Document Stack is generating PDFs from your application. API keys let you call our generation API from your server, CI pipeline, or any backend system.

Creating an API Key

  1. Open your Project in the dashboard
  2. Go to the API Keys tab
  3. Click Create API Key
  4. Give it a descriptive name (e.g., "Production Server", "Staging", "CI Pipeline")
  5. Copy the key immediately — it will only be shown once

Important

API keys are shown only once when created. Copy and store them securely. If you lose a key, you'll need to create a new one.

API Key Scoping

Each API key is scoped to a specific project. A key for your "Billing" project can only generate PDFs from templates in that project — it cannot access templates in other projects.

This means you can safely give different teams or services their own keys.

Using Your API Key

Include the API key in the Authorization header of your API requests:

Bash
curl -X POST https://api.documentstack.dev/api/v1/generate \
  -H "Authorization: Bearer ds_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"templateId": "tmpl_abc", "data": {"name": "Test"}}'

Or use one of our SDKs:

TypeScript
import { DocumentStack } from "@documentstack/sdk";

const client = new DocumentStack({
  apiKey: "ds_live_your_key_here",
});

Managing API Keys

From the API Keys tab you can:

  • View all active keys for a project (last 4 characters shown)
  • Rename a key to update its description
  • Revoke a key to permanently disable it

Revoking a Key

Revoking an API key is permanent and immediate. Any application using that key will stop working. Create a replacement key before revoking the old one.

Best Practices

  • Never commit API keys to version control — use environment variables
  • Use separate keys for production, staging, and development
  • Rotate keys periodically — create a new key, update your app, then revoke the old one
  • Use descriptive names so you know which key is used where

Setting Up in Your App

Store the API key as an environment variable:

Bash
# .env
DOCUMENTSTACK_API_KEY=ds_live_your_key_here

Then reference it in your code:

TypeScript
const client = new DocumentStack({
  apiKey: process.env.DOCUMENTSTACK_API_KEY!,
});