# DocSpring

> Fill and generate PDF documents from templates using the DocSpring API.

Source: https://cotera.co/docs/reference/tools/individual-tools/docspring

---

**Authentication Type:** Username/Password\
**Description:** Fill and generate PDF documents from templates using the DocSpring API.

***

## Authentication

To authenticate, you'll need DocSpring API credentials (token ID and secret). Learn how to create them in the [DocSpring API documentation](https://docspring.com/docs/api-guide/authentication/).

***

## Templates

Fill and generate PDF documents from templates.

### Submit Form Data

Fill a DocSpring template with form data and generate a PDF document. Supports custom form fields, metadata, and both test and production submissions.

**Operation Type:** Mutation (Write)

**Parameters:**

* **templateId** `string` (required): The DocSpring template ID to submit data to
* **formData** `array of objects` (nullable): Form field data as key-value pairs
  * **key** `string`: The form field name
  * **value** `string`: The form field value
* **metadata** `array of objects` (nullable): Additional metadata as key-value pairs
  * **key** `string`: The metadata key
  * **value** `string`: The metadata value
* **test** `boolean` (nullable): Whether this is a test submission (default: false)
* **wait** `boolean` (nullable): Wait for submission to be processed before returning (default: true)

**Returns:**

* **id** `string`: The submission ID
* **state** `string`: The submission state (e.g., processed, pending)
* **test** `boolean`: Whether this was a test submission
* **expired** `boolean`: Whether the submission has expired
* **expires\_at** `string` (nullable): When the submission expires
* **processed\_at** `string` (nullable): When the submission was processed
* **download\_url** `string` (nullable): URL to download the generated PDF
* **permanent\_download\_url** `string` (nullable): Permanent URL to download the PDF
* **batch\_id** `string` (nullable): Batch ID if part of a batch submission

**Example Usage:**

```json
{
  "templateId": "tpl_123abc456def",
  "formData": [
    {
      "key": "customer_name",
      "value": "John Smith"
    },
    {
      "key": "customer_email",
      "value": "john.smith@example.com"
    },
    {
      "key": "order_number",
      "value": "ORD-2024-001"
    },
    {
      "key": "order_date",
      "value": "2024-01-15"
    },
    {
      "key": "total_amount",
      "value": "$299.99"
    },
    {
      "key": "shipping_address",
      "value": "123 Main St, Anytown, ST 12345"
    }
  ],
  "metadata": [
    {
      "key": "generated_by",
      "value": "order_system"
    },
    {
      "key": "department",
      "value": "sales"
    }
  ],
  "test": false,
  "wait": true
}
```

***

## Common Use Cases

**Automated Document Generation:**

* Generate invoices, receipts, and billing statements automatically from order and customer data
* Create contracts and agreements by populating templates with client information and terms
* Produce reports and certificates with dynamic content based on database records and calculations

**Customer Communications:**

* Generate personalized welcome packets, onboarding documents, and service agreements for new customers
* Create customized proposals, quotes, and service estimates with client-specific pricing and terms
* Produce shipping labels, packing slips, and delivery confirmations for e-commerce orders

**Compliance and Legal Documentation:**

* Generate compliance reports and regulatory filings with standardized formats and required data fields
* Create legal documents like NDAs, service agreements, and employment contracts with variable terms
* Produce audit reports and financial statements with consistent formatting and automated data population

**Batch Processing and Workflow Integration:**

* Process multiple document generations simultaneously using batch submissions for efficiency
* Integrate document generation into existing workflows with metadata tracking and processing status monitoring
* Create test documents during development and staging phases before production deployment

