# `jadpo call`

Run one query or action on your machine.

Runs one query or action against the database on this machine (area 17), its arguments from --input, one JSON object of the parameters by name, and prints what it answers as JSON: the value, or the failure's envelope as a route would send it. --as <user id> signs in as that user through the same principal a route builds; without it the caller isn't signed in. Policy always applies, so what works here works through a route. --rollback runs an action and rolls it back, leaving the database as it was. The database is found as `jadpo seed` finds it and must be on this machine: one anywhere else may be production, and is refused before anything runs. Every call is kept in `jadpo dev`'s timelines, so `jadpo trace` and `jadpo why` read it.

```text
jadpo call <name>
```

## Arguments

- `name`: The query or action, with its domain when two share a name

## Flags

- `--as <user-id>`: Sign in as this user, by their id
- `--input <json>`: The arguments, one JSON object
- `--rollback`: Roll back what an action writes
- `--url <url>`: The database to run against, on this machine

## On every command

- `--json`: Print data for tools instead of text
- `--full`: Show everything a report shortens
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo call --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"call"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# Run a query as a user
jadpo call list_entries --as 0192f0c4-7c1e-7a2b-9d3e-4f5a6b7c8da7
# Try an action and roll it back
jadpo call close_entry --as 0192f0c4-7c1e-7a2b-9d3e-4f5a6b7c8da7 --input '{"entry_id":"0192f0c4-7c1e-7a2b-9d3e-4f5a6b7c8df1"}' --rollback
```

## Errors

- [`cli.call_arguments`](/docs/errors/cli.call_arguments.md): A `jadpo call` command names no query or action, one the project doesn't declare, input that isn't a JSON object, or a user `--as` can't sign in as
- [`call.production_refused`](/docs/errors/call.production_refused.md): A query or action was run with `jadpo call` against a database that isn't on this machine, which may be production
- [`call.unavailable`](/docs/errors/call.unavailable.md): The database `jadpo call` runs against couldn't be reached or has migrations not yet applied, so nothing was run
- [`toolchain.project_not_found`](/docs/errors/toolchain.project_not_found.md): You ran a command that works on a project in a folder with no `app.jadpo`, in it or in any folder above it
