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

# Calling the API from Zapier

> Learn how to integrate Doozy API with Zapier

<Warning>
  The Doozy API is currently in **closed beta**. To request access, please email [hello@doozy.live](mailto:hello@doozy.live).
</Warning>

This guide walks you through calling the Doozy API from [Zapier](https://zapier.com) to automate your reporting workflows.

## Prerequisites

Before you begin, ensure you have:

* A Doozy account with API access enabled (see [Authentication](/api/authentication))
* A Doozy API key
* A Zapier account (Professional plan or higher recommended for Webhooks)

## Using Webhooks by Zapier

Since there isn't a native Doozy app in Zapier, you'll use **Webhooks by Zapier** to make API requests.

<Steps>
  <Step title="Create a New Zap">
    Log in to Zapier and click **Create Zap**.
  </Step>

  <Step title="Add a Trigger">
    Choose any trigger that suits your workflow (e.g., **Schedule by Zapier** for periodic reports).
  </Step>

  <Step title="Add Webhooks by Zapier Action">
    Click **+** to add an action, search for **Webhooks by Zapier**, and select **Custom Request**.
  </Step>

  <Step title="Configure the Request">
    Set up the webhook with the following settings:

    | Field       | Value                               |
    | ----------- | ----------------------------------- |
    | **Method**  | `GET`                               |
    | **URL**     | `https://api.doozy.live/v1/quizzes` |
    | **Headers** | `x-api-key \| your-api-key`         |

    <Note>
      In Zapier, headers use the format `Header-Name | Header-Value`. Enter your API key as:

      ```
      x-api-key | dzy_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      ```
    </Note>
  </Step>

  <Step title="Test the Action">
    Click **Test action** to verify the connection. You should see your quiz data in the response.
  </Step>
</Steps>

## Example: Fetching a Quiz Report

To fetch detailed results for a specific quiz:

| Field       | Value                                               |
| ----------- | --------------------------------------------------- |
| **Method**  | `GET`                                               |
| **URL**     | `https://api.doozy.live/v1/quizzes/{quizId}/report` |
| **Headers** | `x-api-key \| your-api-key`                         |

Replace `{quizId}` with the actual quiz ID from your Doozy dashboard.

## Parsing the Response

The API returns JSON data. To use specific fields in subsequent Zap steps:

<Steps>
  <Step title="Access Response Data">
    After testing the webhook, Zapier automatically parses the JSON response.
  </Step>

  <Step title="Use Fields in Later Steps">
    In subsequent actions, you can reference specific fields from the response, such as:

    * `quiz.title` - The quiz title
    * `summary.totalParticipants` - Number of participants
    * `summary.averageScore` - Average quiz score
  </Step>
</Steps>

## Handling Pagination

For endpoints returning multiple items:

1. Make the initial request with a `limit` parameter in the URL:
   ```
   https://api.doozy.live/v1/quizzes?limit=100
   ```

2. Use Zapier's **Looping by Zapier** or **Paths** to handle pagination if you need more than 100 items.

## Example Workflow: Daily Quiz Summary to Slack

<Steps>
  <Step title="Schedule Trigger">
    Use **Schedule by Zapier** to run daily at your preferred time.
  </Step>

  <Step title="Fetch Quiz Report">
    Add **Webhooks by Zapier** → **Custom Request** to fetch `/v1/quizzes/{quizId}/report`.
  </Step>

  <Step title="Format the Message">
    Use **Formatter by Zapier** to create a summary message with the quiz results.
  </Step>

  <Step title="Send to Slack">
    Add **Slack** → **Send Channel Message** to post the summary.
  </Step>
</Steps>

## Example Workflow: Export Quiz Results to Google Sheets

<Steps>
  <Step title="Schedule Trigger">
    Use **Schedule by Zapier** to run weekly.
  </Step>

  <Step title="Fetch Quiz Data">
    Use **Webhooks by Zapier** to fetch quiz report data.
  </Step>

  <Step title="Add to Spreadsheet">
    Use **Google Sheets** → **Create Spreadsheet Row** to log the results.
  </Step>
</Steps>

## Error Handling

Zapier will mark a Zap step as failed if it receives a non-2xx response. Common errors:

| Error                     | Cause                  | Solution                       |
| ------------------------- | ---------------------- | ------------------------------ |
| **401 Unauthorized**      | Invalid API key        | Verify your API key is correct |
| **404 Not Found**         | Resource doesn't exist | Check the quiz ID              |
| **429 Too Many Requests** | Rate limit exceeded    | Reduce frequency or add delays |

<Tip>
  Use Zapier's built-in **Error Handling** feature to add retry logic or send notifications when errors occur.
</Tip>

See [Error Handling](/api/errors) for a complete list of error codes.

## Security Best Practices

<Warning>
  Never share your Zap publicly if it contains your API key. Anyone with access to the Zap could view your key.
</Warning>

* Keep your Zaps private
* Regularly rotate your API keys (see [Authentication](/api/authentication#rotating-api-keys))
* Monitor your Zap history for unexpected errors
