# CLI

URL: https://docs.usestitch.ai/docs/factory/cli



```sh
npm install -g @usestitch/cli
stitch --help
```

Requires Node.js 24+. `FACTORY_URL` overrides the server origin; HTTPS is required except
on localhost. Results and errors are JSON. Help is text. Treat non-zero exits as failure.

## Commands [#commands]

| Command                                                                                      | Purpose                                |
| -------------------------------------------------------------------------------------------- | -------------------------------------- |
| `stitch auth login`                                                                          | Browser-approved device login          |
| `stitch auth whoami`                                                                         | Check active identity and organization |
| `stitch auth logout`                                                                         | Revoke CLI session                     |
| `stitch repositories list`                                                                   | List connected repositories            |
| `stitch secrets list`                                                                        | List secret metadata, not values       |
| `stitch secrets add <name>`                                                                  | Add a value through a hidden prompt    |
| `stitch validate [file] --dry-run`                                                           | Offline schema and cross-field checks  |
| `stitch validate [file] --repository <id> [--ref <ref>]`                                     | Full read-only validation              |
| `stitch webhooks list`                                                                       | List factory endpoints                 |
| `stitch webhooks get <factory-id>`                                                           | Inspect an endpoint                    |
| `stitch webhooks deliveries <factory-id>`                                                    | Inspect delivery results               |
| `stitch webhooks send <factory-id> --event <name> --idempotency-key <id> --data-file <file>` | Send an event                          |

Use each command's `--help` for further options. `webhooks key` and `webhooks rotate`
return credentials; run privately and do not log output.

## Validation contract [#validation-contract]

Default file: `stitch-factory.yaml`. Do not combine `--dry-run` with `--repository` or `--ref`.
Full validation needs login, a connected repository ID, and referenced secrets.
Inspect `ok`, `valid`, and `errors`; errors include codes, JSON paths, and available hints.
`valid: null` means validation could not complete, not that the file is valid.
Validation does not apply changes or test credentials. Deployment occurs through the default branch.

## Schema [#schema]

[Factory JSON Schema](/schema/factory.json). JSON Schema does not encode every custom
refinement; always run `stitch validate` before pushing.
