# Create a script to send data to a webhook

**URL:** <https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514>\
**Category:** Airtable Questions\
**Created:** [April 13, 2023, 11:59pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514 "2023-04-13T23:59:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandonhull](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/brandonhull/32/391_2.png) [@brandonhull](https://air.tableforums.com/u/brandonhull)\
**Post date:** [April 13, 2023, 11:59pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/1 "2023-04-13T23:59:04Z")

</div>

I have an app that gives me a webhook (not Zapier, not Make) I can send data too. I’d like to use a script in an automation that sends data to that webhook when a condition in the base is met.

I know how to create the automation, but don’t know how to write the script. Anyone that can provide help with this? I’d like the script to be editable so I could use the script in different bases, but the webhooks will be different each time.

As an alternative, I would be okay with having the webhook triggered by a formula, but I can’t get Scott’s post from February 2 to work for me in setting this up.

Anyone able to give me a hand?

---

<div class="post-metadata">

**Author:** ![ScottWorld](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/scottworld/32/5_2.png) [@ScottWorld](https://air.tableforums.com/u/ScottWorld)\
**Post date:** [April 14, 2023, 12:55am UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/2 "2023-04-14T00:55:25Z")

</div>

Welcome to the community, @brandonhull!

Which part of [my post](https://air.tableforums.com/t/sending-airtable-data-to-an-external-webhook-such-as-make-com/159) didn’t work for you?

Please post screenshots of your setup.

---

<div class="post-metadata">

**Author:** ![Kuovonne](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/kuovonne/32/17_2.png) [@Kuovonne](https://air.tableforums.com/u/Kuovonne)\
**Post date:** [April 14, 2023, 5:26am UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/3 "2023-04-14T05:26:01Z")

</div>

> [@brandonhull](#):
>
> I have an app that gives me a webhook (not Zapier, not Make) I can send data too.

What format does the app want the data to be in? Does it have documentation? Do you control what the webhook does?

In general, you use a fetch request in JavaScript. But the exact format of the data depends on what the webhook wants.

---

<div class="post-metadata">

**Author:** ![brandonhull](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/brandonhull/32/391_2.png) [@brandonhull](https://air.tableforums.com/u/brandonhull)\
**Post date:** [April 14, 2023, 3:50pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/4 "2023-04-14T15:50:29Z")

</div>

This feature of the app is in beta, coming out in a week or two. It will have some documentation and the format of the data will be JSON. I don’t think I’ll have “control” of what the webhook does, but within the app I’ll be able to select variables that can be used to map data captured in the webhook.

Thanks Kuovonne!

---

<div class="post-metadata">

**Author:** ![brandonhull](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/brandonhull/32/391_2.png) [@brandonhull](https://air.tableforums.com/u/brandonhull)\
**Post date:** [April 14, 2023, 3:51pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/5 "2023-04-14T15:51:50Z")

</div>

I don’t think I’ll be able to append data to the URL sent with the webhook, that’s the piece in question. I’ll post screenshots as soon as the feature officially goes live – it’s in a beta/staging status right now.

Thanks!

---

<div class="post-metadata">

**Author:** ![Kuovonne](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/kuovonne/32/17_2.png) [@Kuovonne](https://air.tableforums.com/u/Kuovonne)\
**Post date:** [April 14, 2023, 4:12pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/6 "2023-04-14T16:12:20Z")

</div>

> [@brandonhull](#):
>
> It will have some documentation and the format of the data will be JSON.

Sounds like you need to do a POST request with a JSON body.

I believe that Scott’s method does a GET request with url parameters.

---

<div class="post-metadata">

**Author:** ![ScottWorld](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/scottworld/32/5_2.png) [@ScottWorld](https://air.tableforums.com/u/ScottWorld)\
**Post date:** [April 14, 2023, 6:58pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/7 "2023-04-14T18:58:45Z")

</div>

Ah, yes, that is correct! My method is for GET requests only.

(I actually don’t have a script on-hand for POST requests since I don’t know Javascript, but I have extensively used Make’s [HTTP module](https://www.make.com/en/integrations/http?pc=scottworld) to make POST requests with JSON bodies.)

---

<div class="post-metadata">

**Author:** ![bfrench](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/bfrench/32/46_2.png) [@bfrench](https://air.tableforums.com/u/bfrench)\
**Post date:** [April 15, 2023, 3:12pm UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/8 "2023-04-15T15:12:05Z")

</div>

> [@brandonhull](#):
>
> the format of the data will be JSON

As @Kuovonne intimated, the HTTP protocol used to call webhooks typically support either POST or GET; generally not both. And POST can support URIEncoded JSON in the command line if the endpoint allows it.

Without docs it’s all guesswork for the developers.

---

<div class="post-metadata">

**Author:** ![dan](https://yyz1.discourse-cdn.com/flex029/user_avatar/air.tableforums.com/dan/32/50_2.png) [@dan](https://air.tableforums.com/u/dan)\
**Post date:** [April 17, 2023, 3:15am UTC](https://air.tableforums.com/t/create-a-script-to-send-data-to-a-webhook/514/9 "2023-04-17T03:15:52Z")

</div>

Here is the basic code you would need. Will need to update the url and body to the webhook url and body you wish to post.

```auto
let url = 'webhook url here'
let body = {
    //post body here as JSON
}
await fetch({
    url,
    method:'POST',
    body: JSON.stringify(body),
    headers:{
        'Content-type':'application/json'
    }
})

```
