# Zapier

> Call any tool with Webhooks by Zapier (Custom Request) and use the results in later steps.

Webhooks by Zapier sends the request. Zapier lists it as a premium app, so it needs a paid Zapier plan.

<Callout title="Before you start">
  You need an API key (it starts with `af_live_`). [Sign up](/login) with your email and you get
  2,000 free credits.
</Callout>

## 1. Add the action [#1-add-the-action]

Add an action step, pick Webhooks by Zapier and choose the Custom Request event.

## 2. Fill in the request [#2-fill-in-the-request]

Method: POST. URL:

```text title="URL"
https://pullwire.dev/api/v1/tools/youtube-transcripts/runs
```

## 3. Send the input [#3-send-the-input]

Paste the input into Data as raw JSON. Zapier sends it exactly as typed, so keep it valid JSON. Map fields from earlier steps into it.

```json title="Data"
{
  "videos": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxResults": 3
}
```

## 4. Add the headers [#4-add-the-headers]

Under Headers add `x-api-key` with your key and `Content-Type` with `application/json`. Without the content type the request is not read as JSON.

## 5. Test and use the results [#5-test-and-use-the-results]

Test the step. The answer shows the run and its `results`; map them into later steps, or add Looping by Zapier to handle each result on its own.

```json title="Answer (SAMPLE)"
{
  "run": {
    "id": "…",
    "status": "succeeded",
    "resultsCount": 1,
    "creditsUsed": 1,
    "error": null
  },
  "results": [
    {
      "…": "one object per result, fields depend on the tool"
    }
  ]
}
```

The values above are a SAMPLE: real answers carry real IDs and all fields of the tool.

## 6. Bigger jobs [#6-bigger-jobs]

Add `?async=1` to the URL, then Delay by Zapier, then a Webhooks GET step to `/api/v1/runs/{run id}/results` with the same `x-api-key` header.

## Good to know [#good-to-know]

- The call waits up to 25 seconds for the results. For bigger jobs add `?async=1` to the URL: you get a run id back right away and fetch the results a bit later.
- Errors come back with a code, e.g. `INSUFFICIENT_CREDITS` (402) or `INVALID_INPUT` (400).
