brex-cli 0.0.0-canary.107cbde

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