brex-cli 0.1.0 → 2026.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +490 -60
  2. package/dist/main.js +203 -480
  3. package/package.json +5 -7
package/README.md CHANGED
@@ -1,124 +1,554 @@
1
1
  # brex-cli
2
2
 
3
- CLI for the Brex APIs at `https://platform.brexapis.com`.
3
+ ![Brex CLI Hero](hero.jpg)
4
4
 
5
- This project was cloned from `mercury-cli` and then reworked to use Brex endpoints from:
6
- - Authentication: https://developer.brex.com/openapi/authentication
7
- - Transactions: https://developer.brex.com/openapi/transactions
8
- - Team: https://developer.brex.com/openapi/team
9
- - Payments: https://developer.brex.com/openapi/payments
10
- - Webhooks: https://developer.brex.com/openapi/webhooks
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
11
6
 
12
- ## Install
7
+ A powerful CLI for the [Brex Platform API](https://developer.brex.com/). Manage accounts, transactions, transfers, recipients, webhooks, and more from your terminal.
8
+
9
+ ## Features
10
+
11
+ - 🏦 **Full Brex API coverage** — accounts, transactions, transfers, recipients, cards, statements, webhooks, and more
12
+ - 📊 **Multiple output formats** — human-readable tables or JSON for scripting
13
+ - 🔐 **Secure token storage** — credentials stored safely in `~/.brex/`
14
+ - 💳 **Cash & card accounts** — unified interface for both account types
15
+ - 🤖 **Scriptable** — no interactive prompts, perfect for CI/CD and automation
16
+
17
+ ## Installation
13
18
 
14
19
  ```bash
15
- bun install
16
- bun run build
20
+ npm install -g brex-cli
17
21
  ```
18
22
 
19
- Run locally:
23
+ ### Requirements
24
+
25
+ - Node.js v18 or later
26
+
27
+ ---
28
+
29
+ ## Quick Start
20
30
 
21
31
  ```bash
22
- bun ./sources/main.ts --help
32
+ # 1. Get your API token from Brex Developer Portal
33
+ # https://developer.brex.com/
34
+
35
+ # 2. Authenticate
36
+ brex login --token <YOUR_API_TOKEN>
37
+
38
+ # 3. List your accounts
39
+ brex accounts list
40
+
41
+ # 4. View transactions
42
+ brex transactions <account-id>
23
43
  ```
24
44
 
45
+ ---
46
+
47
+ ## Global Options
48
+
49
+ All commands support these global options:
50
+
51
+ | Option | Description |
52
+ |--------|-------------|
53
+ | `--json` | Output as JSON instead of human-readable tables |
54
+ | `-h`, `--help` | Show help for the command |
55
+ | `-v`, `--version` | Show CLI version |
56
+
57
+ ---
58
+
25
59
  ## Authentication
26
60
 
27
- Store an API access token locally:
61
+ Brex CLI uses API tokens for authentication. Tokens are stored locally in `~/.brex/token`.
62
+
63
+ ### Getting Your API Token
64
+
65
+ 1. Log in to the [Brex Developer Portal](https://developer.brex.com/)
66
+ 2. Create an API token with the appropriate scopes
67
+ 3. Copy the token
68
+
69
+ ### `brex login`
70
+
71
+ Store an API token for authentication.
72
+
73
+ **Syntax:**
74
+ ```
75
+ brex login --token <TOKEN>
76
+ brex login --token-stdin
77
+ ```
78
+
79
+ **Flags:**
80
+
81
+ | Flag | Required | Description |
82
+ |------|----------|-------------|
83
+ | `--token <TOKEN>` | One of these | API token string |
84
+ | `--token-stdin` | One of these | Read token from stdin |
85
+
86
+ **Examples:**
28
87
 
29
88
  ```bash
30
- brex login --token <ACCESS_TOKEN>
31
- # or
32
- cat token.txt | brex login --token-stdin
89
+ # Direct token input
90
+ brex login --token "brex_prod_xxx..."
91
+
92
+ # From environment variable
93
+ brex login --token "$BREX_TOKEN"
94
+
95
+ # From stdin (CI/CD friendly)
96
+ echo "$BREX_TOKEN" | brex login --token-stdin
97
+
98
+ # From file
99
+ cat ~/.secrets/brex | brex login --token-stdin
33
100
  ```
34
101
 
35
- Token/config location:
36
- - `~/.brex/token`
37
- - `~/.brex/config.json`
102
+ ---
38
103
 
39
- Check status:
104
+ ### `brex logout`
105
+
106
+ Remove stored authentication token.
107
+
108
+ ```bash
109
+ brex logout
110
+ ```
111
+
112
+ ---
113
+
114
+ ### `brex status`
115
+
116
+ Show current authentication and configuration status.
40
117
 
41
118
  ```bash
42
119
  brex status
43
120
  ```
44
121
 
45
- ## Commands
122
+ **Example Output:**
123
+ ```
124
+ Brex CLI Status
125
+ ──────────────────
126
+ Authenticated: Yes
127
+ Token: brex_prod...xxxx
128
+ API Base URL: https://platform.brexapis.com
129
+ Default Account: abc123-def456-...
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Token Storage & Configuration
135
+
136
+ | File | Purpose |
137
+ |------|---------|
138
+ | `~/.brex/token` | API token |
139
+ | `~/.brex/config.json` | Optional configuration (default account, API base URL) |
140
+
141
+ ---
142
+
143
+ ## Accounts
144
+
145
+ Manage Brex bank accounts (cash and card).
146
+
147
+ **Aliases:** `account`, `acc`
148
+
149
+ ### `brex accounts list`
150
+
151
+ List all accounts.
152
+
153
+ **Syntax:**
154
+ ```
155
+ brex accounts list [--type cash|card|all] [--cursor <cursor>] [--json]
156
+ ```
157
+
158
+ **Options:**
159
+
160
+ | Option | Type | Default | Description |
161
+ |--------|------|---------|-------------|
162
+ | `--type` | string | `all` | Account type: `cash`, `card`, or `all` |
163
+ | `--cursor` | string | none | Pagination cursor for next page |
46
164
 
47
- ### Accounts
165
+ ### `brex accounts get`
166
+
167
+ Get detailed information about a specific account.
168
+
169
+ **Syntax:**
170
+ ```
171
+ brex accounts get <account-id> [--type cash|card] [--json]
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Transactions
177
+
178
+ View account transactions.
179
+
180
+ **Aliases:** `tx`, `txn`
181
+
182
+ ### `brex transactions`
183
+
184
+ List transactions for an account.
185
+
186
+ **Syntax:**
187
+ ```
188
+ brex transactions <account-id> [options] [--json]
189
+ ```
190
+
191
+ **Options:**
192
+
193
+ | Option | Type | Default | Description |
194
+ |--------|------|---------|-------------|
195
+ | `--type` | string | `cash` | Account type: `cash` or `card` |
196
+ | `--limit <N>` | integer | 25 | Maximum number of transactions to return |
197
+ | `--cursor` | string | none | Pagination cursor |
198
+ | `--start <date>` | ISO date | none | Filter transactions on or after this date |
199
+ | `--end <date>` | ISO date | none | Filter transactions on or before this date |
200
+
201
+ **Examples:**
202
+
203
+ ```bash
204
+ # List recent transactions for a cash account
205
+ brex transactions abc123-def456-...
206
+
207
+ # Card transactions with limit
208
+ brex transactions abc123-def456-... --type card --limit 50
209
+
210
+ # Filter by date range
211
+ brex transactions abc123-def456-... --start 2024-01-01 --end 2024-12-31
212
+
213
+ # Paginate results
214
+ brex transactions abc123-def456-... --cursor <cursor>
215
+ ```
216
+
217
+ ### `brex transactions get`
218
+
219
+ Get detailed information about a specific transaction.
220
+
221
+ **Syntax:**
222
+ ```
223
+ brex transactions get <account-id> <transaction-id> [--type cash|card] [--json]
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Transfers (Payments API)
229
+
230
+ Create and manage outbound transfers.
231
+
232
+ ### `brex transfer`
233
+
234
+ Send funds to a counterparty.
235
+
236
+ **Syntax:**
237
+ ```
238
+ brex transfer --from <cash-account-id> --to <counterparty-id> --amount <decimal> --idempotency-key <key> [--currency <code>] [--json]
239
+ ```
240
+
241
+ **Options:**
242
+
243
+ | Option | Required | Type | Description |
244
+ |--------|----------|------|-------------|
245
+ | `--from` | Yes | string | Source cash account ID |
246
+ | `--to` | Yes | string | Counterparty ID (recipient) |
247
+ | `--amount` | Yes | decimal | Amount (e.g., `125.50`) |
248
+ | `--idempotency-key` | Yes | string | Unique key to prevent duplicate transfers |
249
+ | `--currency` | No | string | Currency code (default: `USD`) |
250
+
251
+ **Examples:**
48
252
 
49
253
  ```bash
50
- brex accounts list --type all
51
- brex accounts list --type cash --cursor <cursor>
52
- brex accounts get <account-id> --type cash
254
+ # Send $125.50 to a recipient
255
+ brex transfer --from acc-123 --to cpty-456 --amount 125.50 --idempotency-key "inv-2024-001"
53
256
  ```
54
257
 
55
- ### Transactions
258
+ ### `brex transfer get`
259
+
260
+ Get details about a specific transfer.
56
261
 
57
262
  ```bash
58
- brex transactions <account-id> --type cash --limit 50
59
- brex transactions <account-id> --type card --cursor <cursor>
60
- brex transactions get <account-id> <transaction-id> --type cash
263
+ brex transfer get <transfer-id> [--json]
264
+ ```
265
+
266
+ ### `brex transfer list`
267
+
268
+ List transfers with optional filters.
269
+
270
+ **Syntax:**
271
+ ```
272
+ brex transfer list [--status <status>] [--limit <N>] [--cursor <cursor>] [--json]
273
+ ```
274
+
275
+ **Options:**
276
+
277
+ | Option | Type | Description |
278
+ |--------|------|-------------|
279
+ | `--status` | string | Filter by status (e.g., `PROCESSING`, `COMPLETED`) |
280
+ | `--limit` | integer | Maximum results |
281
+ | `--cursor` | string | Pagination cursor |
282
+ | `--from-account-id` | string | Filter by source account |
283
+ | `--to-counterparty-id` | string | Filter by recipient |
284
+
285
+ ---
286
+
287
+ ## Recipients (Payment Counterparties)
288
+
289
+ Manage payment recipients for outbound transfers.
290
+
291
+ **Aliases:** `recipient`, `recip`
292
+
293
+ ### `brex recipients list`
294
+
295
+ List all recipients.
296
+
297
+ **Syntax:**
298
+ ```
299
+ brex recipients [list] [--limit <N>] [--cursor <cursor>] [--name <name>] [--json]
61
300
  ```
62
301
 
63
- ### Transfers (Payments API)
302
+ ### `brex recipients get`
303
+
304
+ Get details about a recipient.
64
305
 
65
306
  ```bash
66
- brex transfer --from <cash-account-id> --to <counterparty-id> --amount 125.50 --idempotency-key <key>
67
- brex transfer get <transfer-id>
68
- brex transfer list --status PROCESSING --limit 20
307
+ brex recipients get <counterparty-id> [--json]
69
308
  ```
70
309
 
71
- ### Recipients (Payment Counterparties)
310
+ ### `brex recipients add`
311
+
312
+ Add a new payment recipient.
313
+
314
+ **Syntax:**
315
+ ```
316
+ brex recipients add --name <name> --account <number> --routing <number> [options] [--json]
317
+ ```
318
+
319
+ **Options:**
320
+
321
+ | Option | Required | Type | Description |
322
+ |--------|----------|------|-------------|
323
+ | `--name` | Yes | string | Recipient name |
324
+ | `--account` | Yes | string | Bank account number |
325
+ | `--routing` | Yes | string | Bank routing number (9 digits) |
326
+ | `--account-type` | No | string | `CHECKING` or `SAVINGS` |
327
+ | `--country` | No | string | Country code |
328
+ | `--currency` | No | string | Currency code |
329
+
330
+ ### `brex recipients delete`
331
+
332
+ Delete a recipient.
72
333
 
73
334
  ```bash
74
- brex recipients list --limit 50
75
- brex recipients add --name "Vendor A" --account 123456789 --routing 021000021 --account-type CHECKING
76
- brex recipients get <counterparty-id>
77
335
  brex recipients delete <counterparty-id>
78
336
  ```
79
337
 
80
- ### Cards / Users / Organization
338
+ ---
339
+
340
+ ## Cards
341
+
342
+ View card information.
343
+
344
+ **Aliases:** `card`
345
+
346
+ ### `brex cards list`
347
+
348
+ List cards with optional filters.
349
+
350
+ **Syntax:**
351
+ ```
352
+ brex cards [list] [--user-id <user-id>] [--cursor <cursor>] [--limit <N>] [--json]
353
+ ```
354
+
355
+ ### `brex cards get`
356
+
357
+ Get details about a specific card.
81
358
 
82
359
  ```bash
83
- brex cards list --user-id <user-id>
84
- brex cards get <card-id>
360
+ brex cards get <card-id> [--json]
361
+ ```
362
+
363
+ ---
85
364
 
86
- brex users list --cursor <cursor>
87
- brex users get <user-id>
365
+ ## Users
88
366
 
89
- brex organization
367
+ List and view organization members.
368
+
369
+ **Aliases:** `user`
370
+
371
+ ### `brex users list`
372
+
373
+ List all users in the organization.
374
+
375
+ **Syntax:**
376
+ ```
377
+ brex users [list] [--cursor <cursor>] [--email <email>] [--json]
90
378
  ```
91
379
 
92
- ### Statements
380
+ ### `brex users get`
381
+
382
+ Get details about a specific user.
93
383
 
94
384
  ```bash
95
- # Primary card account
96
- brex statements --scope primary
97
- brex statements get <statement-id> --scope primary
385
+ brex users get <user-id> [--json]
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Organization
391
+
392
+ **Aliases:** `org`
393
+
394
+ ### `brex organization`
395
+
396
+ Get organization information (legal name, DBA, status, address).
397
+
398
+ ```bash
399
+ brex organization [--json]
400
+ ```
401
+
402
+ ---
403
+
404
+ ## Statements
405
+
406
+ View card account statements.
407
+
408
+ **Aliases:** `statement`
98
409
 
99
- # Additional card account
100
- brex statements --scope additional --account-id <card-account-id>
101
- brex statements get <statement-id> --scope additional --account-id <card-account-id>
410
+ ### `brex statements`
411
+
412
+ List statements for a card account.
413
+
414
+ **Syntax:**
102
415
  ```
416
+ brex statements [--scope primary|additional] [--account-id <id>] [--cursor <cursor>] [--json]
417
+ ```
418
+
419
+ **Options:**
103
420
 
104
- ### Webhooks & Events
421
+ | Option | Type | Default | Description |
422
+ |--------|------|---------|-------------|
423
+ | `--scope` | string | `primary` | `primary` or `additional` card account |
424
+ | `--account-id` | string | none | Required when scope is `additional` |
425
+ | `--cursor` | string | none | Pagination cursor |
426
+
427
+ ### `brex statements get`
428
+
429
+ Get a specific statement.
430
+
431
+ ```bash
432
+ brex statements get <statement-id> [--scope primary|additional] [--account-id <id>] [--json]
433
+ ```
434
+
435
+ ---
436
+
437
+ ## Webhooks
438
+
439
+ Manage webhook endpoints.
440
+
441
+ **Aliases:** `webhook`, `wh`
442
+
443
+ ### `brex webhooks list`
444
+
445
+ List all webhook endpoints.
446
+
447
+ ```bash
448
+ brex webhooks [list] [--cursor <cursor>] [--limit <N>] [--json]
449
+ ```
450
+
451
+ ### `brex webhooks get`
452
+
453
+ Get details about a webhook.
454
+
455
+ ```bash
456
+ brex webhooks get <webhook-id> [--json]
457
+ ```
458
+
459
+ ### `brex webhooks create`
460
+
461
+ Create a new webhook endpoint.
462
+
463
+ **Syntax:**
464
+ ```
465
+ brex webhooks create --url <url> [--events <event1,event2>] [--status <status>] [--json]
466
+ ```
467
+
468
+ **Event Types:** `PAYMENT_COMPLETED`, `TRANSFER_COMPLETED`, and others.
469
+
470
+ ### `brex webhooks update`
471
+
472
+ Update an existing webhook.
473
+
474
+ ```bash
475
+ brex webhooks update <webhook-id> [--url <url>] [--status <status>] [--events <events>] [--json]
476
+ ```
477
+
478
+ ### `brex webhooks delete`
479
+
480
+ Delete a webhook endpoint.
105
481
 
106
482
  ```bash
107
- brex webhooks list
108
- brex webhooks create --url https://example.com/webhooks/brex --events PAYMENT_COMPLETED,TRANSFER_COMPLETED
109
- brex webhooks get <webhook-id>
110
- brex webhooks update <webhook-id> --status ACTIVE
111
483
  brex webhooks delete <webhook-id>
484
+ ```
485
+
486
+ ---
487
+
488
+ ## Events
112
489
 
113
- brex events list --event-type PAYMENT_COMPLETED --limit 25
114
- brex events get <event-id>
490
+ View webhook event history.
491
+
492
+ **Aliases:** `event`
493
+
494
+ ### `brex events list`
495
+
496
+ List webhook events.
497
+
498
+ **Syntax:**
499
+ ```
500
+ brex events [list] [--event-type <type>] [--after-date <ISO>] [--before-date <ISO>] [--cursor <cursor>] [--limit <N>] [--json]
501
+ ```
502
+
503
+ ### `brex events get`
504
+
505
+ Get details about a specific event.
506
+
507
+ ```bash
508
+ brex events get <event-id> [--json]
509
+ ```
510
+
511
+ ---
512
+
513
+ ## Scripting Examples
514
+
515
+ ### Export Transactions to CSV
516
+
517
+ ```bash
518
+ brex transactions "$ACCOUNT_ID" --json | \
519
+ jq -r '.[] | [.id, .status, .amount, .counterpartyName] | @csv'
520
+ ```
521
+
522
+ ### Daily Balance Check
523
+
524
+ ```bash
525
+ brex accounts get "$ACCOUNT_ID" --type cash --json | jq -r '.availableBalance'
115
526
  ```
116
527
 
117
- ## Notes
528
+ ---
118
529
 
119
- - `brex transactions send` is intentionally not used for outbound payments. Use `brex transfer`.
120
- - `brex categories` is currently a placeholder because there is no direct categories endpoint wired in this CLI.
530
+ ## API Reference
531
+
532
+ - **Base URL:** `https://platform.brexapis.com`
533
+ - **Authentication:** Bearer token
534
+ - **Documentation:** [developer.brex.com](https://developer.brex.com/)
535
+
536
+ ### API Sources
537
+
538
+ | Domain | Reference |
539
+ |--------|-----------|
540
+ | Authentication | [developer.brex.com/openapi/authentication](https://developer.brex.com/openapi/authentication) |
541
+ | Transactions | [developer.brex.com/openapi/transactions](https://developer.brex.com/openapi/transactions) |
542
+ | Team | [developer.brex.com/openapi/team](https://developer.brex.com/openapi/team) |
543
+ | Payments | [developer.brex.com/openapi/payments](https://developer.brex.com/openapi/payments) |
544
+ | Webhooks | [developer.brex.com/openapi/webhooks](https://developer.brex.com/openapi/webhooks) |
545
+
546
+ ---
121
547
 
122
548
  ## Disclaimer
123
549
 
124
550
  This is an unofficial CLI. Verify scopes, permissions, and request payload requirements in Brex docs before production use.
551
+
552
+ ## License
553
+
554
+ MIT License. See [LICENSE](LICENSE) for details.