# Call a pipe from JavaScript (PipeScripts)

> Run a pipe API call from your page JavaScript with TB.triggerPipe: copy the snippet from the Pipescripts tab, pass parameters and handle the response.

Source: https://tadabase.com/docs/developers/pipescripts  
Status: Verified Nov 17, 2026. Checked against the current product

PipeScripts let your own JavaScript run a pipe's API call on the server and get the response back in the browser. Use them when a button, a calculation or a page event in your custom code needs data from another service, without putting that service's keys in the page.

## Before you start

- You need a pipe with at least one API call. See [Adding Pipes](https://tadabase.com/docs/pipes/adding-pipes).
- Your plan must include JavaScript in pipes. Without it, the **Pipescripts** tab is not shown and calls from JavaScript are refused.
- The **Pipescripts** tab is not shown on a private pipe, whose setup the publisher keeps hidden.

## Copy the code for an API call

1. **Open the pipe** Click **Pipes** in the builder's left menu and open the pipe.
2. **Choose the API call** Go to the **API Calls** tab and click the call you want to run.
3. **Open the Pipescripts tab** Click **Pipescripts**. The editor shows the JavaScript for this call.
4. **Limit who can run it (optional)** Under **Logged in User Conditions**, click **Add New Condition** and set the conditions the logged-in user must meet. With a condition set, only signed-in users who match can run the call; everyone else gets `Not Authorized`.
5. **Copy the code** Click **Copy Code**. The same button is on the call's **Overview** tab.
6. **Paste it into your page** Paste the code into the **Javascript** tab of the page or layout where it should run, and **Save**.

![A pipe's API call with the Pipescripts tab open, showing the generated TB.triggerPipe code, Logged in User Conditions and the Copy Code button](https://tadabase.com/docs-shots/developers-pipescripts-tab.webp)

> **Warning:** Without a condition, any visitor who can open the page can run the call. Add a condition whenever the call changes data or costs money.

## What the code looks like

```javascript
var tbAbc123 = 'eyJpdiI6...';

TB.triggerPipe(tbAbc123,
    {city: 'Boston', units: 'imperial'},
    function (type, response, xhrRespone) {
        console.log('pipe response', type, response, xhrRespone);
    }
);
```

| Argument | What it is |
| --- | --- |
| First: the call ID | The value in the first line of the copied code. It names this pipe and this API call; copy it as it is. |
| Second: parameters | An object with one entry per parameter of the call, keyed by the parameter's slug (or its name if it has no slug), filled with its default value. Replace the values with your own. Parameters of type **Logged In User Value** are left out: the server fills them from the signed-in user. |
| Third: callback | Your function. It receives `type` (`success` or `error`), `response` (the JSON the call returned) and the raw request object. |

## Call the pipe from your page

Most often you run the call when something happens on the page, then put the result on the screen. This example runs a call when a Details component loads and shows the result in an alert.

```javascript
var weatherCall = 'eyJpdiI6...'; // from Copy Code

TB.render('component_5', function (data) {
    TB.triggerPipe(weatherCall, {city: data.record.field_12}, function (type, response) {
        if (type !== 'success' || response.type === 'error') {
            TB.showAlert('Could not load the weather', 'error');
            return;
        }
        TB.showAlert('Weather loaded', 'success');
        console.log(response);
    });
});
```

> **Note:** Check both values. `type` is `error` when the request itself failed. When the pipe refuses the call (a required parameter is missing, or the logged-in user doesn't meet the conditions), `type` can be `success` while `response.type` is `error` and `response.msg` says why, such as `Invalid parameters` or `Not Authorized`.

## Limits

- Each call runs the pipe on Tadabase's servers, the same as a pipe on a form or a workflow.
- Calls can be rate limited. When a limit is reached the callback gets `type` `error` and the request status is `429`; wait before you try again.
- Don't call a pipe in a loop or on a timer that fires every few seconds. Call it once per user action and keep the result.
