> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# exec

> Run a script with the Base44 SDK pre-authenticated

Run a TypeScript or JavaScript script with the Base44 SDK pre-authenticated as the current user. The SDK is available as a global `base44` variable. Scripts are executed locally using Deno.

For a full walkthrough, use cases, and prerequisites, see the [Standalone scripts](https://docs.base44.com/developers/backend/overview/run-scripts.md) guide.

## Usage

Pipe a script file to exec:

```bash theme={null}
cat ./script.ts | base44 exec
```

Or pass inline code:

```bash theme={null}
echo "console.log(await base44.entities.Tasks.list())" | base44 exec
```

By default `exec` targets the app linked in the current project's `.app.jsonc`. To run a script against any other app on your account, pass `--app-id` or set the `BASE44_APP_ID` environment variable. This works from anywhere on your machine, including against apps you built in the Base44 online app editor and never linked locally.

```bash theme={null}
echo "console.log(await base44.entities.Tasks.list())" | base44 exec --app-id <your-app-id>
```

## Flags

| Flag | Description |
| - | - |
| `--app-id <id>` | Target the specified app. Defaults to the app linked in the current project. See [Select a target app](https://docs.base44.com/developers/references/cli/commands/introduction.md#select-a-target-app). |
| `--local` | Run the script against a local [`base44 dev`](https://docs.base44.com/developers/references/cli/commands/dev) server instead of the deployed app. The dev server must already be running. |
| `--port <number>` | Port the local dev server is on. Use with `--local`. Defaults to `4400`. |
| `--privileged` | Run with admin privileges, bypassing row-level security. Requires the app owner or editor role. |
| `--data-env <environment>` | Data environment to run against, such as `dev` or `prod`. |

## See also

* [Standalone scripts](https://docs.base44.com/developers/backend/overview/run-scripts.md): Full guide with use cases and prerequisites
* [`api fetch`](https://docs.base44.com/developers/references/cli/commands/api-fetch): Call a Base44 API operation directly, without writing a script


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.