Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.pixcraft.es/llms.txt

Use this file to discover all available pages before exploring further.

Zapier Integration

This guide shows how to set up a Zapier automation that automatically generates a pattern PDF when a new order arrives in your store.

Example workflow

Trigger: New WooCommerce order Action: Generate pattern PDF with PixCraft API Action: Email PDF to the customer

Step 1: Create a new Zap

  1. Log in to zapier.com
  2. Click Create Zap
  3. Choose your trigger app (WooCommerce, Shopify, or any app that provides orders)

Step 2: Configure the trigger

For WooCommerce:
  • App: WooCommerce
  • Event: New Order
  • Account: Connect your WooCommerce store
  • Test: Fetch a sample order to use in the next steps

Step 3: Add PixCraft API action

  1. Click + to add a new step
  2. Choose Webhooks by Zapier
  3. Select Custom Request
  4. Configure:
FieldValue
MethodPOST
URLhttps://www.pixcraft.es/api/v1/generate
HeadersAuthorization: Bearer px_live_your_key and Content-Type: application/json
BodySee below

Request body

{
  "image_url": "{{order_item_image_url}}",
  "niche": "mosaics",
  "width_cm": 100,
  "height_cm": 100,
  "max_colors": 8
}
Replace {{order_item_image_url}} with the actual Zapier field from your trigger.

Step 4: Generate PDF (optional)

Add another Webhooks step:
FieldValue
MethodPOST
URLhttps://www.pixcraft.es/api/v1/generate/pdf
HeadersSame as above
BodySame as above
The response will be a PDF binary. You can:
  • Save it to Google Drive or Dropbox
  • Attach it to an email

Step 5: Email the result

Add a final step:
  1. Choose Gmail or Email by Zapier
  2. Set the recipient to the customer’s email from the order
  3. Include pattern details from Step 3 in the email body:
Your pattern has been generated!

Grid: {{dimensions.cols}} × {{dimensions.rows}}
Total units: {{dimensions.total_units}}
Colors used: {{materials.length}}

Materials needed:
{{#each materials}}
- {{color_name}}: {{quantity}} units ({{percentage}}%)
{{/each}}

Alternative: Use Code by Zapier

For more control, use the Code by Zapier action (JavaScript):
const response = await fetch('https://www.pixcraft.es/api/v1/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + inputData.apiKey,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    image_url: inputData.imageUrl,
    niche: inputData.niche || 'mosaics',
    width_cm: parseInt(inputData.width) || 100,
    height_cm: parseInt(inputData.height) || 100,
  }),
});

const data = await response.json();

output = [{
  totalUnits: data.dimensions.total_units,
  colorsUsed: data.materials.length,
  materialsSummary: data.materials.map(m => `${m.color_name}: ${m.quantity}`).join('\n'),
}];

Tips

  • Check usage before processing: Call GET /api/v1/usage at the start of your Zap to verify you have credits remaining
  • Validate first: Use POST /api/v1/validate to check image quality before spending a generation credit
  • Handle errors: Add a Zapier Paths step to handle API errors gracefully (send a notification instead of failing silently)