Wunderdocs API Documentation

website·Indexed 30 days ago

https://docs.wunderdocs.io/

API for automating PDF workflows, including the ability to create templates, fill PDF templates with data to generate documents, and manage PDF creation and sending.

Tokens
2.9K
Snippets
19
Records
25
Agent score
49%

What's inside Wunderdocs

  1. Set up a PDF template in wunderdocs

    Before using the API to fill PDFs, you must first set up a template in the wunderdocs dashboard:

    1. Create an account at wunderdocs.io.
    2. Upload a PDF template using the "Add new template" button.
    3. Enter the template editor by clicking "Edit" on the template row to mark the input fields that the API will target.
  2. Map data to PDF template fields

    To fill a PDF template, you must provide a JSON object where the keys exactly match the keys of the template fields. If keys do not match or the data type is incorrect (e.g., providing a string for a field defined as a number), the field will not be filled. You can retrieve the required field keys and types using the 'Retrieve template fields' endpoint.
    // Example of template field definitions
    {
      "fields": [
        { "label": "First Name", "key": "firstName", "type": "string" },
        { "label": "Age", "key": "age", "type": "number" }
      ]
    }
    
    // Corresponding data object to fill those fields
    {
      "firstName": "John",
      "age": 42
    }
  3. Get started with the wunderdocs API

    To begin using the wunderdocs API for automating PDF workflows (creating, filling, and sending PDFs), you must first create an account and retrieve your API key from the account settings page. Once authenticated, you can use the wunderdocs editor to mark PDFs with input fields, declare input types, and fill those fields via HTTP API requests.
  4. Paginate wunderdocs API responses using limit and offset

    The wunderdocs API uses offset-based pagination for all responses that return a list of objects. By default, responses are limited to 25 results. You can increase this limit up to a maximum of 100 using the limit parameter. To skip a specific number of objects and retrieve a subsequent page, use the offset parameter.
    curl -G https://api.wunderdocs.io/v1/documents \
      -H "X-API-KEY: {api-key}" \
      -d limit=10 \
      -d offset=2
  5. Generate a wunderdocs API key

    To authenticate requests to the wunderdocs API, you must generate a unique API key via the wunderdocs dashboard. Navigate to the settings page (https://app.wunderdocs.io/settings), scroll to the bottom, and click 'Add new API key'. You will be prompted to provide a name for the key before the key is revealed. API keys provide access to data only and cannot be used to log in to the dashboard.
  6. Handle 429 Too Many Requests and Free Tier limits

    A 429 Too Many Requests error occurs when you have exceeded the rate limit for your account or the limits of the free tier.

    • Free Tier Limit Exceeded: Indicated by the message freeTierLimitExceeded. To resolve this, upgrade your account to a paid version.
    • Rate Limit Exceeded: If you are already on a paid plan and receive this error, contact wunderdocs support.

    Example Free Tier Limit Response:

    {
      "status": 429,
      "error": "invalid_request",
      "message": "freeTierLimitExceeded"
    }

    Example General Rate Limit Response:

    {
      "status": 429,
      "error": "invalid_request",
      "message": "Too Many Requests"
    }
  7. Fill a PDF template with data

    To fill a PDF template, send a POST request to the /v1/templates/{uid} endpoint. The request body must be a JSON object containing the keys and values for the fields you wish to populate. The response provides a downloadUrl to access the generated PDF.
    curl https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK \
      -H "X-API-KEY: {api-key}" \
      -d '{
        "firstName": "John",
        "lastName": "Doe"
      }'
  8. Retrieve a specific template by UID

    Fetch the full details of a specific template using its unique identifier (uid).
    curl https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK \
      -H "X-API-KEY: {api-key}" 
  9. List all templates

    Retrieve a paginated list of all templates. By default, the API returns a maximum of 25 templates per page.

    Query Parameters:

    • limit (integer): Limit the number of templates returned.
    • offset (integer): The offset for pagination.
    curl -G https://api.wunderdocs.io/v1/templates \
      -H "X-API-KEY: {api-key}" \
      -d limit=10 \
      -d offset=0 
  10. Delete a template and its documents

    Permanently delete a template from Wunderdocs. Warning: Deleting a template will also delete all documents that were generated using that specific template.
    curl -X DELETE https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK \
      -H "X-API-KEY: {api-key}" 
  11. Retrieve only the fields of a template

    Retrieve just the input fields of a template. This is specifically useful for dynamically building forms to fill a template based on its uid.
    curl https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK/fields \
      -H "X-API-KEY: {api-key}" 
  12. Interpret wunderdocs API status codes and error types

    The wunderdocs API uses standard HTTP status codes to indicate the success or failure of a request. When a request fails, the API returns a JSON response containing a status code, an error type, and a descriptive message.

    Status Code Categories:

    • 2xx: Successful response.
    • 4xx: Client error (the request contains an error or cannot be served).
    • 5xx: Server error.

    Error Types:

    • invalid_request: A client-side error. Check your request parameters and code.
    • api_error: A server-side error (rare).

    Example Error Response:

    {
      "status": 500,
      "error": "api_error",
      "message": "Internal Server Error"
    }