# Pipedream e-signature integration

Pipedream suits docuinked well, because its code steps can verify our webhook signature properly. Use an HTTP request or a Node.js step today. A registered app is coming soon.

## What works today

| Route | Status |
|---|---|
| Node.js or Python code step | Works now |
| HTTP request action | Works now |
| HTTP trigger for webhooks | Works now |
| docuinked app in the Pipedream registry | Coming soon |

## Recipe: send from a Node.js step

Store your key as an environment variable named `DOCUINKED_API_KEY`.

```js
export default defineComponent({
  async run({ steps }) {
    const res = await fetch("https://docuinked.com/v1/documents", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.DOCUINKED_API_KEY}`,
        "Content-Type": "application/json",
        "Idempotency-Key": `order-${steps.trigger.event.id}`,
      },
      body: JSON.stringify({
        title: "Order form",
        pdf_url: steps.trigger.event.pdf_url,
        signers: [{ name: steps.trigger.event.name, email: steps.trigger.event.email }],
        send: true,
      }),
    });
    if (!res.ok) throw new Error(await res.text());
    return (await res.json()).data;
  },
});
```

## Recipe: verify a webhook

Use an **HTTP trigger** set to give you the raw body, and register its URL with `create_webhook`. Then run the `verify` function from the [webhooks page](/docs/webhooks) in a code step, with your secret from an environment variable. Stop the workflow if it returns false. This gives you a receiver you can trust without running a server.

## Common questions

### Does Pipedream need anything from docuinked to connect?

Only an API key. A registered app would add a connect button and prebuilt actions. Until then, the API call is a few lines.

### Can I run this on a schedule to check status?

Yes. A scheduled workflow can call `list_documents` with a status filter. A webhook is quicker and cheaper if you only care about changes.

### Where should the API key live?

In a Pipedream environment variable. Keep it out of the code step, where anyone who can see the workflow could read it.
