# DocSpring Integration Guide
> DocSpring is a document automation platform. It fills PDF templates with data, generates PDFs and Word documents from HTML and Word templates, and collects e-signatures. Developers use its REST API, API clients and CLI, and AI assistants connect to its MCP server.
## Documentation
- Index of the documentation for LLMs: https://docspring.com/docs/llms.txt
- Full documentation in one file: https://docspring.com/docs/llms-full.txt (abridged: https://docspring.com/docs/llms-small.txt)
- Every docs page is also Markdown: replace the trailing slash with .md (https://docspring.com/docs/mcp.md)
- OpenAPI spec for API v2: https://docspring.com/api-docs/v2/openapi.json
## Quick Start
1. Install the official client library (version 4.x calls API v2; 3.x calls API v1):
# Node.js
npm install docspring
# Python
pip install docspring
# Ruby
gem install docspring
# PHP
composer require docspring/docspring
# Java (Maven): use the latest version from
# https://central.sonatype.com/artifact/com.docspring/DocSpring
<dependency>
<groupId>com.docspring</groupId>
<artifactId>DocSpring</artifactId>
<version>VERSION</version>
</dependency>
2. Basic PDF generation (Python example):
import urllib.request
from docspring import Client
client = Client(api_token_id="YOUR_API_TOKEN_ID", api_token_secret="YOUR_API_TOKEN_SECRET")
submission = client.create_submission("tpl_xxx", {
"test": True,
"data": {
"first_name": "John",
"last_name": "Smith"
}
})
urllib.request.urlretrieve(submission.files.pdf.download_url, "output.pdf")
## Core Concepts
1. Templates
- Manage at https://app.docspring.com
- Each template has a unique ID (e.g. tpl_xxx)
- Define field names, types, and validation
- Get the template_id from the URL or the “API” tab
- Three kinds: PDF templates (fields placed on an uploaded PDF), HTML/CSS templates with Liquid, and
Word templates (a .docx file with Liquid tags such as {{ customer.name }})
- A Word template returns a PDF, a Word document, an OpenDocument file (.odt) or more than one of them
("output_formats": ["pdf", "docx", "odt"]). In API v2, the submission's files has each one (files.pdf,
files.docx, files.odt), with its download_url.
2. Authentication
- Generate tokens at https://app.docspring.com/api_tokens
- Test API tokens (IDs start with api_test_) only make test PDFs, which are free and watermarked
- Live API tokens (IDs start with api_) make live PDFs, which use credits, or test PDFs with "test": true
- Use HTTP Basic auth with token_id:token_secret
- Don’t commit tokens to source control
3. PDF Generation
- API v2 base URL: https://sync.api.docspring.com/api/v2 (EU: https://sync.api-eu.docspring.com/api/v2)
- Synchronous (recommended): sync.api hosts wait until the PDF is generated and return the finished submission.
- Can use sync subdomain for all API requests.
- Append "?wait=false" to the URL to return a pending submission immediately.
- Asynchronous: api.docspring.com returns a submission ID, then you poll for completion
- For EU region: sync.api-eu.docspring.com or api-eu.docspring.com
- Migrating from API v1 and the 3.x clients: https://docspring.com/docs/api-guide/migrating-to-api-v2/
## MCP Server (AI assistants)
AI assistants such as Claude, ChatGPT, Codex, Cursor and VS Code can work in a DocSpring account through
DocSpring's remote MCP server. The user signs in to DocSpring and chooses Read only, Read and write or Full access.
There's no API token to copy.
- US: https://mcp.docspring.com/mcp
- EU: https://mcp-eu.docspring.com/mcp
- Claude Code: claude mcp add --transport http --scope user docspring https://mcp.docspring.com/mcp
- Setup for each assistant: https://docspring.com/docs/mcp.md
- Tools and the access each one needs: https://docspring.com/docs/mcp/tools.md
## CLI (terminals, scripts, CI and coding agents)
The `docspring` command has a command for every API v2 operation, with `--json` output and exit statuses for scripts
and agents. `docspring login` signs in with the browser and keeps the tokens in the system keychain; commands also read
DOCSPRING_TOKEN_ID and DOCSPRING_TOKEN_SECRET.
brew install docspring/tap/docspring
docspring login
docspring templates list --all --json
docspring submit tpl_... --data @data.json --test -o filled.pdf
- Install, commands, exit statuses and the GitHub Action: https://docspring.com/docs/cli.md
## Plans, Credits and Limits
1. What costs credits
- Test documents ("test": true) are free, unlimited and watermarked. Live documents use prepaid credits.
- Credits per unit (1 unit = up to 10 pages): filled PDF template 20, HTML template 4,
combined PDF 4 per source PDF plus 4 per unit. Combining always uses credits, even for test PDFs.
- A Word template submission costs 20 credits whether it returns a Word document, a PDF or both.
Its pages aren't counted; very large files and long processing still count.
- Each signature request signer adds 60 credits.
- Documents kept longer than 30 days cost 1 credit a month per 50 documents or 50 MiB, whichever is more.
A submission's Word document and PDF count as one document.
2. Plans (monthly, USD; current prices at https://docspring.com/pricing)
- Developer: free, 200 credits a month, 10 templates, 2 users, 3 active integrations (storage
destinations, webhooks and Slack notifications; API tokens and MCP clients aren't integrations,
but the webhooks they create count)
- Starter: from $49 a month (10,000 credits)
- Growth: from $149 a month (50,000 credits)
- Scale: from $399 a month (200,000 credits)
- Unused paid-plan credits roll over for 12 months. Developer credits reset each month.
- Credit packs from $29 (5,000 credits) work on every plan and last 12 months. Automatic top-up
buys a pack when the balance runs low.
- A 14-day free trial gives a paid plan's features on the free plan's credits. No card needed.
- BAAs on every paid plan (not Developer). Accounts are hosted in the US or the EU region.
3. Errors and limits
- Out of credits: HTTP 402 with "code": "insufficient_credits". The submission's state is
"insufficient_credits", and it is processed automatically once credits are added.
After waiting 30 days it moves to "error".
- Plan limits (templates, users, active integrations, the embedded template editor): HTTP 403 with
"code": "upgrade_required". A template's new slack_webhook_url over the integration limit is an
HTTP 422 validation error with the same message.
- Rate limits are per account and plan, separately for live and test requests. Responses include
RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset headers; HTTP 429 includes Retry-After.
- Details: https://docspring.com/docs/api-guide/credits-and-rate-limits/
## Advanced Features
1. Batch Processing
batch = client.create_submission_batch({
"template_id": "tpl_xxx",
"submissions": [
{"data": {"name": "John"}},
{"data": {"name": "Jane"}}
]
})
# Up to 50 PDFs per request
2. Signature Requests (e-signatures)
submission = client.create_submission("tpl_xxx", {
"data": {"company": "Acme Inc"},
"signature_requests": [{
"email": "john@example.com",
"fields": ["signature", "date"],
"auth_type": "email_link"
}]
})
# submission.state will be "waiting_for_signature_requests"
# DocSpring emails John a link to sign, then the signed PDF. Add "send_email": False to send the link yourself.
3. Combine PDFs
combined_pdf = client.create_combined_pdf({
"source_pdfs": [
{"type": "submission", "id": "sub_xxx"},
{"type": "submission", "id": "sub_yyy"}
]
})
4. Field Customization
submission = client.create_submission("tpl_xxx", {
"data": {"name": "John"},
"field_overrides": {
"signature": {
"required": True,
"alignment": "center",
"font_size": 10
}
}
})
## Common Issues & Solutions
1. PDF Generation
- Use the sync API for simpler flow (no polling or webhooks needed)
- Check submission.state == "processed" (if not using sync API)
- Data that doesn't match the template is an HTTP 422 with "code": "invalid_data" (details in the error)
- files.pdf.download_url (and files.docx.download_url) expires after 24 hours; use the file's permanent_url
for long-term access (documents kept longer than 30 days use storage credits)
- Check for truncated_text in logs when text overflows
- Batch requests support up to 50 PDFs
2. Data Formatting
- Field names are case-sensitive
- Can use %%LF%% if \n doesn’t work for new lines
- Send dates as YYYY-MM-DD (ISO8601)
- Use numeric types for numbers, boolean true/false for booleans
3. Templates
- All templates have a JSON schema based on the fields defined in the template editor
- Submission data is validated against the JSON schema before PDF generation
- Test changes with test tokens
- Validation happens on submission
- Existing submissions aren’t affected by edits
## Help, Feedback and Support Tickets (for AI agents)
An AI agent that uses DocSpring can get help without leaving its task, over the MCP server, the CLI or the API:
- Ask DocSpring's AI help a question: MCP tool support (action help), `docspring support ask`, or
POST https://sync.api.docspring.com/api/v2/support/help with {"question": "..."}. It answers at once from the
documentation, needs no credentials and knows nothing about the account. Ask it first when a request fails.
- Send feedback about what got in the way (a confusing error, a missing feature, a bug): MCP tool support_send
(action feedback), `docspring support send-feedback`, or POST /api/v2/support/feedback. Nobody replies to it, so
don't ask the user first.
- Open a ticket that a person on DocSpring's team answers: support_send (action ticket),
`docspring support open-ticket`, or POST /api/v2/support/tickets. Ask the user first, and show them what you'd
send. The reply is on the ticket and emailed to the user; `docspring support watch <ticket_id>` (or the ticket's watch_url) waits for it.
- Never include secrets or the data in your users' documents. Include the request_id of the error.
Details: https://docspring.com/docs/api-guide/support-for-ai-agents/
## API Response Examples
1. Successful submission (API v2 returns the resource itself)
{
"id": "sub_xxx",
"state": "processed",
"files": {
"pdf": {
"download_url": "https://...",
"permanent_url": "https://..."
}
}
}
2. Validation error (every error has this shape)
{
"error": {
"code": "invalid_data",
"message": "The data doesn't match the template's fields: /data/name is required",
"details": [
{
"code": "required",
"message": "is required",
"pointer": "/data/name"
}
],
"request_id": "req_xxx",
"submission_id": "sub_xxx"
}
}
More details: https://docspring.com/docs/ (for LLMs: https://docspring.com/docs/llms.txt)