# Pipedream + Dizo

> Call Dizo from a Pipedream workflow with a Node.js code step or the Send any HTTP Request action, keeping the key in an environment variable.

Type: REST recipe — base URL `https://api.dizo.ai/v1`. No native app needed.

## Steps
1. In Pipedream, add an environment variable named `DIZO_API_KEY` with your `dz_live_...` key.
2. In a workflow, after your trigger, add a **Node.js** code step and paste the code below (or use the **Send any HTTP Request** action for a no-code call).
3. Read the trigger payload from `steps.trigger.event`, send it to Dizo, and use `$.flow.exit()` to stop cleanly when nobody is found.
4. Reference the result in later steps as `steps.dizo_enrich.$return_value` (or the name you gave the step).

## Where to go
In a workflow, add a step: **Send any HTTP Request**, or a Node.js code step.

Open the Pipedream HTTP docs: https://pipedream.com/docs/workflows/building-workflows/http

## Node.js code step
```
import axios from "axios";

export default defineComponent({
  async run({ steps, $ }) {
    const lead = steps.trigger.event.body;
    const res = await axios({
      method: "post",
      url: "https://api.dizo.ai/v1/people/enrich",
      headers: {
        Authorization: `Bearer ${process.env.DIZO_API_KEY}`,
        "Content-Type": "application/json",
        "Idempotency-Key": String(lead.id),
      },
      data: { email: lead.email, include: ["email"], max_credits: 3 },
      validateStatus: () => true,
    });
    if (res.status === 404) return $.flow.exit("No match (not charged)");
    if (res.status >= 400) throw new Error(`${res.data.error.code}: ${res.data.error.fix}`);
    $.export("credits_used", res.data.credits_used);
    return res.data.person;
  },
});
```

## Send any HTTP Request (no code)
```
Method:   POST
URL:      https://api.dizo.ai/v1/companies/enrich
Headers:  Authorization: Bearer {{process.env.DIZO_API_KEY}}
          Content-Type: application/json
Body:     { "domain": "{{steps.trigger.event.body.domain}}", "max_credits": 1 }
```

## Notes
- The Send any HTTP Request action halts the workflow on any failed request, including a free `404` miss. Use the code step when you need to branch on not-found or `402` budget errors.
- Set `Idempotency-Key` from the source record so Pipedream retries within 24 hours are never charged twice.

## Related API docs
- [/docs/people-enrich](https://dizo.ai/docs/people-enrich.md)
- [/docs/company-enrich](https://dizo.ai/docs/company-enrich.md)
- [/docs/batch](https://dizo.ai/docs/batch.md)


## What Pipedream is

Pipedream is a workflow platform for developers. A workflow starts with a trigger, such as an HTTP endpoint, a schedule or an event in a connected app, and runs a sequence of steps. Steps can be prebuilt actions, an HTTP request builder, or code in Node.js and other languages. Data flows forward through the `steps` object: the trigger's payload lives at `steps.trigger.event`, and each step's return value is available to the steps after it.

Pipedream gives you three ways to call an outside API, and all three work with Dizo. The **Send any HTTP Request** action is a Postman-like builder for a single request. A **Node.js code step** gives you full control over the request, the response and error handling. And `$.send.http()` fires a request when you do not need the response. This page uses the first two. There is no Dizo app on Pipedream; you call `https://api.dizo.ai/v1` directly.

## Why call Dizo from Pipedream

Pipedream workflows tend to sit between systems: a webhook from your product, a form tool, a billing provider, a CRM. Those events usually carry one identifier, an email or a domain, and the next system wants more. Dizo turns that identifier into a profile. An email becomes a person with title, seniority, department and work history. A domain becomes a company with headcount, revenue band, industry, HQ, funding and technologies.

The billing model fits event-driven work. Nothing is charged per workflow or per seat on the Dizo side. Each call spends credits only when it finds something: [person enrich](/docs/people-enrich) is 2 credits if matched, [company enrich](/docs/company-enrich) is 1 credit if matched, and misses cost nothing. A signup webhook full of personal addresses and typos will not burn your budget on lookups that return nobody.

## What you can build

The same request pattern covers most jobs. Change the URL and body, keep the headers:

- Enrich each product signup with title and seniority, then post high-seniority signups to a sales channel.
- Turn a new account's domain into a company profile with `POST /v1/companies/enrich` and write headcount and industry to your CRM.
- Find a work email from a name and domain captured at an event with `POST /v1/email/find`, 1 credit only if found.
- Re-identify bounced contacts with `POST /v1/people/enrich` and `POST /v1/email/find`, at 2 credits per match and 1 credit per email found, and suppress the ones that come back empty.
- Receive Dizo's signed webhooks, such as `batch.completed` or `signal.job_change`, on a Pipedream HTTP trigger and route them onward.
- Run a nightly scheduled workflow that sends the day's new records to `POST /v1/batch` as one async job.
- Add unsubscribes to Dizo's suppression list so those contacts are never returned again.

## Setting up the code step

First, store the key. In Pipedream, add an environment variable named `DIZO_API_KEY` and paste your key. Pipedream recommends environment variables for API keys that are not managed through a connected account, and code reads them with `process.env.DIZO_API_KEY`. Keeping the key there means it never appears in workflow code you share or fork.

Add a Node.js step after your trigger and paste the code from the recipe above. It reads the lead from `steps.trigger.event.body`, posts to the person enrich endpoint with three headers, and sets `validateStatus` so that axios hands back every response instead of throwing on 4xx. That lets the step branch: a `404` means nobody was matched and nothing was charged, so the step ends the workflow quietly with `$.flow.exit()`. Any other error throws with Dizo's `error.code` and `error.fix` in the message, which shows up clearly in the workflow's event log.

On success the step uses `$.export` to publish `credits_used` and returns the person object. Later steps read it as `steps.dizo_enrich.$return_value`, using whatever name you gave the step. Deploy, send one test event with a known email, and inspect the result before you point real traffic at it.

Anyone can [sign up](/signup) for a live key, and work email signups get 250 free credits with no card. A `dz_test_` key returns synthetic data for free, so you can build and test the whole workflow now. Switch to the live key by changing the environment variable, not the code, and nothing else in the workflow needs to change.

## When to use the HTTP Request action instead

The **Send any HTTP Request** action is quicker for a one-off call where every request is expected to succeed. Set the method, URL, headers and body in the builder, and reference the key with `process.env.DIZO_API_KEY` in the Authorization header, as Pipedream's own examples do. The second recipe block above shows a company enrich call in this form.

Be aware of how the action handles failure. Pipedream documents that it always sends its request and halts the workflow if the request fails, with no fallback step. For Dizo, a free not-found result is a `404`, so with the action a miss stops the workflow. That is fine when a miss genuinely means there is nothing more to do. When you need to treat a miss as normal and continue, or react to a `402` budget error differently from a `400` bad request, use the code step.

## Controlling spend

Use three layers. On each request, send `max_credits` as a ceiling: the recipe sets 3, which covers a 2-credit match plus a 1-credit email. On the key, create one just for Pipedream through [API keys](/docs/keys), with `data:read` scope, daily and monthly credit caps, a per-request ceiling and an endpoint allow-list. On the account, set a monthly USD cap through [spend limits](/docs/billing-limits). When it is reached, calls return `402 monthly_cap_reached`, and auto-refill never goes past it.

A hypothetical month: 1,200 signups, 700 of them matched to a person, 650 of those with an email found. That is 700 × 2 + 650 × 1 = 2,050 credits. At the $0.025 pay-as-you-go rate it is $51.25. Bought as part of a $500 purchase at the $0.021 Builder rate, the same usage is $43.05. The 500 signups that matched nobody cost nothing. Before turning on a high-volume trigger, send the same request with `"dry_run": true` to see the exact cost of a call without spending anything.

## Example workflows

**Signup to sales alert.** HTTP trigger from your product, code step calling person enrich, then a filter on `seniority` in `c_level` or `vp`, then a message to your sales channel. Low-seniority and unmatched signups simply end. Cost per matched signup is 2 to 3 credits.

**Nightly batch.** A schedule trigger, a code step that collects the day's new records from your database, and one call to `POST /v1/batch` with up to 10,000 lookups. A second workflow with an HTTP trigger receives the `batch.completed` webhook and downloads the results file. Batch items cost the same as single calls, and misses are still free. Verify the `Dizo-Signature` header in the receiving step before trusting the payload.

**Job-change router.** Register a webhook for `signal.job_change` pointing at a Pipedream HTTP trigger. Each event, charged at 1 credit per change detected, updates the contact in your CRM and creates a follow-up task for the account owner.

## Troubleshooting

A `401` usually means the environment variable name in code does not match the one you saved, or the header is missing the `Bearer ` prefix. A `402` is a spend cap, not a bug: decide whether to raise the cap rather than retry. For other errors, branch on `error.code` and retry only when `error.retryable` is true, after `error.retry_after` seconds.

If Pipedream retries a step, duplicate charges are the risk. The recipe sends an `Idempotency-Key` built from the source record id, and retries with the same key within 24 hours are never charged twice. If you reference results downstream and get an undefined error, check that the step name in `steps.STEP_NAME.$return_value` exactly matches the step you return from. Step names are easy to change in the editor and the reference does not follow the rename, so a renamed step is the usual cause.

## Security practices

Keep the key in an environment variable, never in code or in a step's props that you might share. Use separate keys for development and production workflows so you can rotate one without breaking the other, and use `dz_test_` keys in any workflow you publish or hand to someone else.

Never grant the Pipedream key `billing:write` or `keys:write`. For inbound Dizo webhooks, verify the HMAC signature with your signing secret, stored as another environment variable, before acting on an event. See [webhooks](/docs/webhooks) for the signature format.

## FAQ

### Is there a Dizo app in Pipedream?
No. There is no native Dizo app or listing. You call the Dizo REST API from a Node.js code step or the Send any HTTP Request action, with your key in an environment variable.

### Code step or HTTP Request action?
Use the action for simple calls where a failure should stop the workflow. Use a code step when you need to treat a free `404` miss as normal, handle `402` budget errors, or retry selectively.

### How do I avoid paying twice when Pipedream retries?
Send an `Idempotency-Key` header built from the source record id. Dizo never charges twice for a retry with the same key within 24 hours.

### Can Pipedream receive Dizo webhooks?
Yes. Point a Dizo webhook at a Pipedream HTTP trigger URL and read the payload from `steps.trigger.event`. Verify the `Dizo-Signature` header with your signing secret before you act on it.

### What does an enrichment workflow cost?
Person enrich is 2 credits if matched, plus 1 if an email is found. Credits cost $0.025 down to $0.010 depending on purchase size, and lookups that find nobody are free.

### Can I test without spending credits?
Yes. Use a `dz_test_` key, which returns synthetic data and is always free, or add `"dry_run": true` to any request for an exact quote.
