> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peedief.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting

> Common issues and solutions for Peedief Template to PDF platform

# Troubleshooting

## Template-Specific Issues

### Template Not Found

<Accordion title="&#x22;Template not found&#x22; Error">
  **Symptoms:** API calls return 404 with "Template not found" message

  **Solutions:**

  1. **Verify Template ID**: Check the exact template ID using the templates list endpoint
  2. **Check Category**: Ensure you're looking in the right template category
  3. **Template Status**: Verify the template is published and active
  4. **Case Sensitivity**: Template IDs are case-sensitive

  **Test Command:**

  ```bash theme={null}
  curl -H "x-api-key: YOUR_API_KEY" \
       "https://peedief.com/api/templates"
  ```
</Accordion>

### Data Validation Errors

<Accordion title="&#x22;Validation failed&#x22; Error">
  **Symptoms:** PDF generation fails with data validation errors

  **Solutions:**

  1. **Check Required Fields**: Ensure all required fields are provided
  2. **Data Types**: Verify data types match template requirements (string, number, date)
  3. **Date Formats**: Use YYYY-MM-DD format for dates
  4. **Field Lengths**: Check maximum length constraints

  **Test Command:**

  ```bash theme={null}
  curl -X POST "https://peedief.com/api/templates/template-id/validate" \
       -H "x-api-key: YOUR_API_KEY" \
       -H "Content-Type: application/json" \
       -d '{"data": {"field": "value"}}'
  ```
</Accordion>

## Common Issues

### Authentication Problems

<Accordion title="&#x22;Invalid API Key&#x22; Error">
  **Symptoms:** API calls return 401 Unauthorized with "Invalid API Key" message

  **Solutions:**

  1. **Check Key**: Ensure you copied the entire API key without extra spaces
  2. **Header Format**: Use exact format: `x-api-key: YOUR_API_KEY`
  3. **Key Status**: Verify key hasn't been revoked in your dashboard
  4. **Regenerate**: Create a new API key if the current one isn't working

  **Test Command:**

  ```bash theme={null}
  curl -H "x-api-key: YOUR_API_KEY" \
       "https://peedief.com/api/user"
  ```
</Accordion>

<Accordion title="&#x22;Unauthorized&#x22; Error">
  **Symptoms:** General 401 errors or "Unauthorized" messages

  **Solutions:**

  1. **Login Status**: Ensure you're logged into your account
  2. **Session Expired**: Log out and log back in to refresh session
  3. **Account Status**: Check if your account is active and in good standing
  4. **Plan Limits**: Verify you haven't exceeded your plan's PDF limit

  **Check Account Status:**
  Visit your dashboard to confirm account status and usage.
</Accordion>

### PDF Generation Issues

<Accordion title="&#x22;HTML content is required&#x22; Error">
  **Symptoms:** API returns error about missing HTML content

  **Solutions:**

  1. **Request Body**: Ensure HTML is provided in the request body
  2. **Content-Type**: Check header is set to `application/json`
  3. **JSON Escape**: Verify HTML is properly escaped in JSON
  4. **Empty Content**: Make sure HTML field isn't empty or null

  **Correct Format:**

  ```json theme={null}
  {
    "html": "<html><body><h1>Content</h1></body></html>",
    "fileName": "document.pdf"
  }
  ```
</Accordion>

<Accordion title="Poor PDF Quality Issues">
  **Symptoms:** Blurry text, missing images, layout problems

  **Solutions:**

  1. **Image Resolution**: Use high-resolution images (300+ DPI)
  2. **Font Issues**: Use web-safe fonts or embed fonts properly
  3. **CSS Problems**: Follow PDF-friendly CSS practices
  4. **Scale Setting**: Try different scale values between 0.8-1.2

  **Quality CSS:**

  ```css theme={null}
  body {
    font-family: Arial, sans-serif;
    font-size: 12pt;
    line-height: 1.4;
  }

  img {
    max-width: 100%;
    image-rendering: optimizeQuality;
  }
  ```
</Accordion>

### Subscription & Billing Issues

<Accordion title="&#x22;Insufficient Balance&#x22; Error">
  **Symptoms:** PDF generation blocked due to plan limits

  **Solutions:**

  1. **Check Usage**: View current usage in your dashboard
  2. **Plan Upgrade**: Consider upgrading to a higher tier
  3. **Billing Issue**: Verify payment method is current
  4. **Usage Reset**: Wait for next billing cycle if near reset

  **Quick Check:**
  Log into dashboard → Usage section → Check remaining balance
</Accordion>

<Accordion title="Payment Failed Issues">
  **Symptoms:** Unable to upgrade plan or payment declined

  **Solutions:**

  1. **Card Details**: Check expiration date and CVV code
  2. **Billing Address**: Ensure address matches your card exactly
  3. **International Payments**: Contact bank about international transactions
  4. **Payment Method**: Try different card or PayPal
  5. **Currency Issues**: Verify your bank supports USD transactions
</Accordion>

### Response Times

| Plan        | Support Type   | Response Time |
| ----------- | -------------- | ------------- |
| **Free**    | Community      | Best effort   |
| **Starter** | Email          | 24-48 hours   |
| **Basic**   | Priority Email | 12-24 hours   |
| **Premium** | Email + Phone  | 2-4 hours     |

### How to Contact Support

**Email Support:** [support@peedief.com](mailto:support@peedief.com)

**Include in Your Request:**

* Your account email address
* API key (first 6 characters only)
* Detailed description of the issue
* Steps you've already tried
* Error messages (exact text)
* Sample code or HTML (if relevant)

**Example Support Request:**

```
Subject: PDF Generation Failing - HTML Content Error

Account: user@example.com
API Key: abc123...

Issue: Getting "HTML content is required" error even though HTML is included

Steps Tried:
1. Verified Content-Type header is application/json
2. Tested with simple HTML content
3. Checked for JSON escaping issues

Error Message: 
"HTML content is required"

Sample Request:
{curl command here}
```

### Emergency Contact

For **critical issues** affecting production systems:

* **Email**: [emergency@peedief.com](mailto:emergency@peedief.com) (Premium plans only)
* **Response**: Within 2 hours during business hours
* **Issues**: Service outages, data loss, security concerns

## Advanced Troubleshooting

### Debugging API Calls

Enable detailed logging to diagnose issues:

```javascript theme={null}
async function debugPDFGeneration(html, options) {
  console.log('Request payload:', { html: html.substring(0, 100) + '...', options });
  
  try {
    const response = await fetch('https://peedief.com/api/pdf', {
      method: 'POST',
      headers: {
        'x-api-key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ html, options })
    });
    
    console.log('Response status:', response.status);
    console.log('Response headers:', Object.fromEntries(response.headers));
    
    const result = await response.text();
    console.log('Response body:', result);
    
    return JSON.parse(result);
  } catch (error) {
    console.error('Request failed:', error);
    throw error;
  }
}
```

### Network Issues

**Connection Problems:**

* Check firewall settings for outbound HTTPS
* Verify DNS resolution for peedief.com
* Test from different network/location
* Use ping/traceroute for network diagnostics

**Timeout Issues:**

* Increase request timeout (default: 30 seconds)
* Reduce HTML content size
* Optimize images and CSS
* Try during off-peak hours

### Performance Troubleshooting

<Card title="Slow PDF Generation">
  **Common Causes:**

  * Large images or complex CSS
  * External resources (fonts, images)
  * Heavy HTML content (>1MB)
  * Peak usage times

  **Solutions:**

  * Optimize image sizes
  * Embed resources as data URLs
  * Simplify CSS and layout
  * Generate during off-peak hours
</Card>

### Browser Console Errors

For web-based integrations, check browser console:

**Common Console Errors:**

* **CORS errors**: Use server-side API calls instead
* **Mixed content**: Ensure HTTPS for all resources
* **Network errors**: Check internet connection
* **Authentication**: Verify API key configuration

## Preventive Measures

### Best Practices to Avoid Issues

<CardGroup cols={2}>
  <Card title="API Usage" icon="code">
    * Implement retry logic with backoff
    * Validate HTML before sending
    * Use proper error handling
    * Monitor usage and limits
  </Card>

  <Card title="Content Optimization" icon="optimize">
    * Test HTML in browser first
    * Use web-safe fonts
    * Optimize images for web
    * Keep HTML under 2MB
  </Card>

  <Card title="Security" icon="shield">
    * Store API keys securely
    * Rotate keys periodically
    * Monitor for unusual usage
    * Use HTTPS for all requests
  </Card>

  <Card title="Monitoring" icon="chart-line">
    * Set up usage alerts
    * Monitor error rates
    * Track processing times
    * Review monthly analytics
  </Card>
</CardGroup>
