-
Notifications
You must be signed in to change notification settings - Fork 5
/
openapi.yaml
882 lines (870 loc) · 25 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
openapi: 3.0.1
info:
title: Expenses API
description: |
The Expenses API allows you to manage accounting and expenses information.
version: '0.1'
contact:
name: Admin
url: https://brex.com
email: developer-access@brex.com
servers:
- description: Production
url: https://platform.brexapis.com
- description: >-
Staging (Note: This is not a sandbox. It will not work with customer
tokens.)
url: https://platform.staging.brexapps.com
tags:
- description: View and manage card expenses data.
name: Card Expenses
- description: Upload receipt and match automatically.
name: Receipt Match
- name: Receipt Upload
paths:
/v1/expenses/card:
get:
tags:
- Card Expenses
summary: List expenses
operationId: CardExpenses_list
security:
- OAuth2:
- expenses.card.readonly
- expenses.card
description: >-
List expenses under the same account. Admin and bookkeeper have access
to any expense, and regular users can only access their own.
parameters:
- description: >-
Get additional details for the expense, e.g. merchant mcc code, by
passing in `expand[]=merchant`. Query parameters include `location`,
`department`, `merchant`, `receipts.download_uris`, `user`, `budget`
and `payment`.
name: expand[]
in: query
required: false
schema:
type: array
nullable: true
items:
type: string
example:
- merchant
- location
- description: Get expenses belong to provided user(s).
name: user_id[]
in: query
required: false
schema:
type: array
nullable: true
items:
type: string
- description: Get itemized expenses belong to provided parent expenses ID(s).
name: parent_expense_id[]
in: query
required: false
schema:
type: array
nullable: true
items:
type: string
- name: budget_id[]
in: query
required: false
schema:
type: array
nullable: true
items:
type: string
- name: status[]
in: query
required: false
schema:
type: array
nullable: true
items:
$ref: '#/components/schemas/ExpenseStatus'
- name: payment_status[]
in: query
required: false
schema:
type: array
nullable: true
items:
$ref: '#/components/schemas/ExpensePaymentStatus'
- description: >
Shows only expenses with a `purchased_at` on or after this
date-time. This parameter is the date-time notation as defined by
[RFC 3339, section
5.6](https://tools.ietf.org/html/rfc3339#section-5.6), e.g.
2022-11-12T23:59:59.999
name: purchased_at_start
in: query
required: false
schema:
type: string
format: date-time
nullable: true
example: '2023-01-01T23:59:59.999'
- description: >
Shows only expenses with a `purchased_at` on or before this
date-time. This parameter is the date-time notation as defined by
[RFC 3339, section
5.6](https://tools.ietf.org/html/rfc3339#section-5.6), e.g.
2022-11-12T23:59:59.999
name: purchased_at_end
in: query
required: false
schema:
type: string
format: date-time
nullable: true
example: '2023-01-10T23:59:59.999'
- description: Load custom fields for the expenses.
name: load_custom_fields
in: query
required: false
schema:
type: boolean
nullable: true
default: false
- description: >
The cursor to use for pagination. This is the `next_cursor` value
returned from the previous response.
name: cursor
in: query
required: false
schema:
type: string
nullable: true
- name: limit
in: query
required: false
schema:
type: integer
format: int32
nullable: true
responses:
'200':
description: listExpenses 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/Page_ExpandableExpense_'
'400':
description: Bad request
'401':
description: Unauthorized
'403':
description: Forbidden
/v1/expenses/card/receipt_match:
post:
tags:
- Receipt Match
summary: Create a new receipt match
operationId: ReceiptMatch_createNewReceiptMatch
description: >
The `uri` will be a pre-signed S3 URL allowing you to upload the receipt
securely. This URL can only be used for a `PUT` operation and expires 30
minutes after its creation. Once your upload is complete, we will try to
match the receipt with existing expenses.
Refer to these
[docs](https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html)
on how to upload to this pre-signed S3 URL. We highly recommend using
one of AWS SDKs if they're available for your language to upload these
files.
parameters: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ReceiptMatchRequest'
required: true
responses:
'200':
description: receiptMatch 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAsyncFileUploadResponse'
'400':
description: Bad request
'401':
description: Unauthorized
/v1/expenses/card/{expense_id}:
get:
tags:
- Card Expenses
summary: Get an expense
operationId: CardExpenses_getById
security:
- OAuth2:
- expenses.card.readonly
- expenses.card
description: Get an expense by its ID.
parameters:
- name: expense_id
in: path
required: true
schema:
type: string
- description: >-
Get additional details for the expense, e.g. merchant mcc code, by
passing in `expand[]=merchant`. Query parameters include `location`,
`department`, `merchant`, `receipts.download_uris`, `user`, `budget`
and `payment`.
name: expand[]
in: query
required: false
schema:
type: array
nullable: true
items:
type: string
example:
- merchant
- location
- description: Load custom fields for the expense.
name: load_custom_fields
in: query
required: false
schema:
type: boolean
nullable: true
default: false
responses:
'200':
description: getExpense 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/ExpandableExpense'
'400':
description: Bad request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
put:
tags:
- Card Expenses
summary: Update an expense
operationId: CardExpenses_updateExpense
security:
- OAuth2:
- expenses.card
description: >-
Update an expense. Admin and bookkeeper have access to any expense, and
regular users can only access their own.
parameters:
- name: expense_id
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateExpenseRequest'
required: true
responses:
'200':
description: updateExpense 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/Expense'
'400':
description: Bad request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
/v1/expenses/card/{expense_id}/receipt_upload:
post:
tags:
- Receipt Upload
summary: Create a new receipt upload
operationId: ReceiptUpload_createNewReceipt
description: >
The `uri` will be a pre-signed S3 URL allowing you to upload the receipt
securely. This URL can only be used for a `PUT` operation and expires 30
minutes after its creation. Once your upload is complete, we will try to
match the receipt with existing expenses.
Refer to these
[docs](https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html)
on how to upload to this pre-signed S3 URL. We highly recommend using
one of AWS SDKs if they're available for your language to upload these
files.
parameters:
- name: expense_id
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ReceiptUploadRequest'
required: true
responses:
'200':
description: receiptUpload 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAsyncFileUploadResponse'
'400':
description: Bad request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
components:
schemas:
Budget:
required:
- id
- name
type: object
properties:
id:
description: Unique ID for the Budget.
required:
- 'true'
type: string
name:
description: Name for the Budget.
required:
- 'true'
type: string
Category:
description: The category of expenses.
type: string
enum:
- ADVERTISING_AND_MARKETING
- GROCERY
- TELEPHONY
- OFFICE_SUPPLIES
- PRIVATE_AIR_TRAVEL
- CLOTHING
- CAR_RENTAL
- VEHICLE_EXPENSES
- RESTAURANTS
- GAMBLING
- FLOWERS
- ELECTRONICS
- LEGAL_SERVICES
- UTILITIES
- FURNITURE
- BARS_AND_NIGHTLIFE
- LAUNDRY
- EVENT_EXPENSES
- SHIPPING
- OTHER_TRAVEL_EXPENSES
- CHARITY
- SOFTWARE_NON_RECURRING
- LODGING
- FACILITIES_EXPENSES
- SERVERS
- CONFERENCES
- FOOD_DELIVERY
- RENT
- AIRLINE_EXPENSES
- OTHER_BUSINESS_EXPENSES
- BANK_AND_FINANCIAL_FEES
- BOOKS_AND_NEWSPAPERS
- CONSULTANT_AND_CONTRACTOR
- CORPORATE_INSURANCE
- DIGITAL_GOODS
- FEES_AND_LICENSES_AND_TAXES
- GAS_AND_FUEL
- GENERAL_MERCHANDISE
- MEDICAL
- MEMBERSHIPS_AND_CLUBS
- PARKING_EXPENSES
- POLITICAL_DONATIONS
- PUBLIC_TRANSPORTATION
- RECURRING_SOFTWARE_AND_SAAS
- RIDESHARE_AND_TAXI
- TOLL_AND_BRIDGE_FEES
- TRAINING_AND_EDUCATION
- TRAVEL_WIFI
ExpensePaymentStatus:
type: string
enum:
- NOT_STARTED
- PROCESSING
- CANCELED
- DECLINED
- CLEARED
- REFUNDING
- REFUNDED
- CASH_ADVANCE
- CREDITED
- AWAITING_PAYMENT
- SCHEDULED
ExpenseStatus:
type: string
enum:
- DRAFT
- SUBMITTED
- APPROVED
- OUT_OF_POLICY
- VOID
- CANCELED
- SPLIT
- SETTLED
PaymentStatusReason:
description: The reason for the payment's status.
type: string
enum:
- OTHER
- APPROVED
- EXCEEDED_BUDGET_LIMIT
- BUDGET_EXPIRED
- NO_BUDGET
- BUDGET_NOT_YET_STARTED
- BUDGET_CATEGORY_RESTRICTION
- BUDGET_MERCHANT_RESTRICTION
- SUSPECTED_FRAUD
- EXCEEDED_GLOBAL_LIMIT
- EXCEEDED_USER_LIMIT
- EXCEEDED_CARD_LIMIT
- INVALID_EXPIRATION_DATE
- CARD_NOT_ACTIVE
- INVALID_CARD_CREDENTIALS
- INVALID_BILLING_ADDRESS
- CARD_SUSPENDED
- CARD_TERMINATED
- CARD_EXPIRED
- MCC_BLOCKED
- USER_SUSPENDED
- INVALID_PIN
- INVALID_CVV
- EXCEEDED_PIN_ATTEMPTS
- INSIDE_SANCTIONED_COUNTRY
- SOFT_EXPIRATION
- TRANSFERRED_CARD_NEW_MERCHANT
- EXCEEDED_ANCESTOR_BUDGET_LIMIT
- EXCEEDED_BUDGET_TRANSACTION_LIMIT
- TOS_BLOCKED
- COMPLIANCE_BLOCKED
CreateAsyncFileUploadResponse:
description: |
The pre-signed file upload URI and unique identifier of the request.
required:
- id
- uri
type: object
properties:
id:
description: The unique identifier for the request.
required:
- 'true'
type: string
uri:
description: |
The pre-signed S3 link that should be used to upload the file.
The maximum size accepted for this document is 50 MB.
required:
- 'true'
type: string
Department:
description: The department associated with the expense.
required:
- id
- name
type: object
properties:
id:
description: The unique identifier for the department.
required:
- 'true'
type: string
name:
description: The name of the department.
required:
- 'true'
type: string
ExpandableExpense:
description: >-
The expense object that has expandable fields, e.g., `location`,
`department`, and `receipts`.
required:
- id
- updated_at
type: object
properties:
id:
description: Unique ID associated with the expense.
required:
- 'true'
type: string
memo:
description: The memo of the expense.
type: string
nullable: true
location_id:
type: string
nullable: true
location:
allOf:
- $ref: '#/components/schemas/Location'
- nullable: true
department_id:
type: string
nullable: true
department:
allOf:
- $ref: '#/components/schemas/Department'
- nullable: true
updated_at:
description: The last time the expense was updated.
required:
- 'true'
type: string
format: date-time
category:
allOf:
- $ref: '#/components/schemas/Category'
- nullable: true
merchant_id:
type: string
nullable: true
merchant:
allOf:
- $ref: '#/components/schemas/Merchant'
- nullable: true
receipts:
description: A list of receipts associated with the expense.
type: array
nullable: true
items:
$ref: '#/components/schemas/Receipt'
budget_id:
type: string
nullable: true
budget:
allOf:
- $ref: '#/components/schemas/Budget'
- nullable: true
original_amount:
$ref: '#/components/schemas/Money'
billing_amount:
$ref: '#/components/schemas/Money'
purchased_at:
description: The time the purchase was made.
required:
- 'true'
type: string
format: date-time
status:
allOf:
- $ref: '#/components/schemas/ExpenseStatus'
- nullable: true
payment_status:
allOf:
- $ref: '#/components/schemas/ExpensePaymentStatus'
- nullable: true
user_id:
type: string
nullable: true
user:
allOf:
- $ref: '#/components/schemas/User'
- nullable: true
payment:
allOf:
- $ref: '#/components/schemas/Payment'
- nullable: true
x-konfig-properties:
original_amount:
description: >-
The original amount of the expense is the amount that the employee
submitted or incurred for reimbursements or card spends.
billing_amount:
description: >-
The billing amount of the expense is the amount that the entity is
charged, on the entity's currency, for reimbursements or card
spends.
Expense:
required:
- id
- updated_at
type: object
properties:
id:
description: Unique ID associated with the expense.
required:
- 'true'
type: string
memo:
description: The memo of the expense.
type: string
nullable: true
location_id:
type: string
nullable: true
department_id:
type: string
nullable: true
updated_at:
description: The last time the expense was updated.
required:
- 'true'
type: string
format: date-time
category:
allOf:
- $ref: '#/components/schemas/Category'
- nullable: true
merchant_id:
type: string
nullable: true
budget_id:
type: string
nullable: true
original_amount:
$ref: '#/components/schemas/Money'
billing_amount:
$ref: '#/components/schemas/Money'
purchased_at:
description: The time the purchase was made.
required:
- 'true'
type: string
format: date-time
status:
allOf:
- $ref: '#/components/schemas/ExpenseStatus'
- nullable: true
payment_status:
allOf:
- $ref: '#/components/schemas/ExpensePaymentStatus'
- nullable: true
x-konfig-properties:
original_amount:
description: >-
The original amount of the expense is the amount that the employee
submitted or incurred for reimbursements or card spends.
billing_amount:
description: >-
The billing amount of the expense is the amount that the entity is
charged, on the entity's currency, for reimbursements or card
spends.
Location:
description: The location associated with the expense.
required:
- id
- name
type: object
properties:
id:
description: The unique identifier for the location.
required:
- 'true'
type: string
name:
description: The name of the location.
required:
- 'true'
type: string
Merchant:
required:
- mcc
- raw_descriptor
- country
type: object
properties:
raw_descriptor:
description: Merchant descriptor, it can be the merchant name.
required:
- 'true'
type: string
mcc:
description: >-
A four-digit number listed in ISO 18245 for retail financial
services, e.g. 4121 for Taxicabs and Rideshares. Please refer to
https://en.wikipedia.org/wiki/Merchant_category_code for more
details.
required:
- 'true'
type: string
country:
description: Merchant's country, in ISO 3166-1 alpha-3 format.
required:
- 'true'
type: string
Money:
description: >
Money fields can be signed or unsigned. Fields are signed (an unsigned
value will be interpreted as positive). The amount of money will be
represented in the smallest denomination
of the currency indicated. For example, USD 7.00 will be represented in
cents with an amount of 700.
type: object
properties:
amount:
description: >-
The amount of money, in the smallest denomination of the currency
indicated by currency. For example, when currency is USD, amount is
in cents.
type: integer
format: int64
currency:
description: >-
The type of currency, in ISO 4217 format. Default to USD if not
specified
type: string
nullable: true
Page_ExpandableExpense_:
required:
- items
type: object
properties:
next_cursor:
type: string
nullable: true
items:
type: array
items:
$ref: '#/components/schemas/ExpandableExpense'
Payment:
description: The payment associated with the expense.
required:
- id
- payment_instrument
- status_reason
type: object
properties:
id:
description: Unique ID for the payment.
required:
- 'true'
type: string
payment_instrument:
$ref: '#/components/schemas/PaymentInstrument'
status_reason:
$ref: '#/components/schemas/PaymentStatusReason'
x-konfig-properties: {}
PaymentInstrument:
type: object
properties:
type:
description: The type of payment instrument.
type: string
enum:
- CARD
discriminator:
propertyName: type
mapping:
card: '#/components/schemas/CardPaymentInstrument'
oneOf:
- $ref: '#/components/schemas/PaymentInstrument'
Receipt:
description: The receipt associated with the expense.
required:
- id
type: object
properties:
id:
description: The unique identifier for the receipt.
required:
- 'true'
type: string
download_uris:
description: >-
[Presigned S3
link](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html)(s)
to download file(s) of the receipt. Link(s) expire in 15 minutes.
type: array
nullable: true
items:
type: string
ReceiptMatchRequest:
description: The parameter for creating a receipt match.
required:
- receipt_name
type: object
properties:
receipt_name:
description: >-
The name of the receipt (with the file extension). It will be used
in the matching result email.
required:
- 'true'
type: string
ReceiptUploadRequest:
description: The parameter for creating a receipt upload.
required:
- receipt_name
type: object
properties:
receipt_name:
description: The name of the receipt (with the file extension).
required:
- 'true'
type: string
UpdateExpenseRequest:
description: The parameter for updating an expense.
type: object
properties:
memo:
description: Expense memo.
type: string
nullable: true
User:
required:
- id
- first_name
- last_name
type: object
properties:
id:
description: Unique ID for the User.
required:
- 'true'
type: string
first_name:
description: First name of the User.
required:
- 'true'
type: string
last_name:
description: Last name of the User.
required:
- 'true'
type: string
department_id:
type: string
nullable: true
location_id:
type: string
nullable: true
securitySchemes:
OAuth2:
description: OAuth2 security scheme
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://accounts-api.brex.com/oauth2/default/v1/authorize
tokenUrl: https://accounts-api.brex.com/oauth2/default/v1/token
scopes:
openid: openid
offline_access: offline access
expenses.card: View and manage card expenses data
expenses.card.readonly: View card expenses data
security:
- OAuth2: []
x-explorer-enabled: false