# CLI reference

Create persistent service endpoints and integrate the terminal client into scripts. Connection setup lives in [Get connected](https://notify.belweave.ai/docs/quickstart#cli-install); send, ask, and activity examples live with their task guides.

HTML: https://notify.belweave.ai/docs/cli

## Create a persistent webhook

Create a service when another process should use a persistent webhook instead of a CLI connection. `notify services create` stores the default sender title, image, and destination and returns `webhookUrl` in JSON. Later webhook sends only need their message body.

```bash
notify services create \
  --title "Warehouse desk" \
  --image https://warehouse.example.com/icon.png \
  --url https://warehouse.example.com/pickups
```

```json
{
  "service": {
    "id": "svc_...",
    "title": "Warehouse desk",
    "imageUrl": "https://warehouse.example.com/icon.png"
  },
  "webhookUrl": "https://notify.belweave.ai/hooks/whk_your_token"
}
```

Creation requires `services:write`. `--stdin` accepts the JSON fields directly. `services list` returns service metadata with credentials omitted. Reauthorize an older or narrower connection if it lacks the write scope.

> Capture the returned URL securely. It authorizes sends through that service; it should not appear in public command logs.

## Output and terminal outcomes

Send commands write their result as JSON on stdout and diagnostics on stderr. Most other commands also produce JSON; `apps` commands use readable lines unless `--json` is supplied. Branch on a terminal wait result, or inspect explicit status fields when reading existing prompts. The exit codes below describe outcome-bearing commands.

- `0`: successful operation, or a terminal approved/yes/replied answer.
- `4`: wait timeout, canceled question, or expired question.
- `5`: terminal denied/no answer.
- `7`: no provider accepted a push request and no device delivery was queued.
- `1`: API failure; `2`: command usage error; `3`: authentication/scope failure; `6`: network failure.

```bash
if notify send ask "Start the scheduled maintenance?" --approval --wait --timeout 10m; then
  ./run-maintenance.sh && notify send "Maintenance complete" --title "Maintenance desk"
else
  echo "Maintenance was not approved" >&2
fi
```
