Repository navigation
Expand file tree
/
Copy pathopenapi.yml
More file actions
7361 lines (7069 loc) · 257 KB
/
Copy pathopenapi.yml
File metadata and controls
7361 lines (7069 loc) · 257 KB
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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: Ledger v3 API
description: |
API for Ledger v3, a distributed accounting ledger with Raft consensus.
Signed and ordinary transaction mutations use application/json, including
MIME parameters. Either Formance-Signing-Key-Id or Formance-Signature header,
even if empty, selects the signed wrapper containing request and payload on
the five supporting operations. Both headers are then required exactly once
and nonempty. With neither header present, the ordinary unsigned REST body applies.
Signing headers with a non-JSON or missing content type, or on other /v3
operations, reject with HTTP 415 and an ErrorResponse JSON body.
version: 1.0.0
contact:
name: Formance
url: https://formance.com
servers:
- url: http://localhost:9000
description: Local development server
security:
- BearerAuth: []
- {}
paths:
/v3/:
get:
summary: List all ledgers
description: |
Lists the ledgers in the cluster, paged by name (ascending unless
`reverse=true`). Requires `ledger:read` scope.
operationId: v3ListAllLedgers
x-speakeasy-name-override: ListAllLedgers
tags:
- Ledgers
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageCursor'
- name: reverse
in: query
schema:
type: boolean
default: false
description: List in descending name order when true.
responses:
'200':
description: List of ledgers retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ListAllLedgersResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/health:
get:
summary: Health check
description: Returns the health status of the node. Returns 503 if the node is not connected to the cluster.
operationId: v3Health
x-speakeasy-name-override: Health
tags:
- Health
responses:
'200':
description: Node is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/livez:
get:
summary: Liveness probe
description: Returns 200 as long as the process is alive. Suitable for Kubernetes liveness probes.
operationId: v3Livez
x-speakeasy-name-override: Livez
tags:
- Health
responses:
'200':
description: Process is alive
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/readyz:
get:
summary: Readiness probe
description: |
Returns 200 once the local Raft loop has started, regardless of whether
a leader has been elected. Suitable for Kubernetes readiness probes and
StatefulSet `OrderedReady` ordering: it is intentionally permissive so
peer pods can be brought up during a cold start where quorum cannot
form until they exist. Use `/clusterz` for the stricter
cluster-availability signal.
operationId: v3Readyz
x-speakeasy-name-override: Readyz
tags:
- Health
responses:
'200':
description: Local Raft loop has started
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/clusterz:
get:
summary: Cluster-availability probe
description: |
Returns 200 only when the node is part of a healthy cluster (Raft state
healthy and a leader elected). Disk and clock skew gate writes (see
admission), not cluster readiness. Returns 503 otherwise. Use this
for external monitoring or any client that needs to wait until the node
can actually serve cluster-dependent traffic. Kubernetes readiness
probes should target `/readyz` instead — this endpoint MUST NOT gate
StatefulSet ordering, otherwise the cluster cannot recover from a
full-kill cold start.
operationId: v3Clusterz
x-speakeasy-name-override: Clusterz
tags:
- Health
responses:
'200':
description: Node is part of a healthy cluster
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/_info:
get:
summary: Get server build information
description: Returns the server build metadata (version, commit, build date, Go runtime version). Unauthenticated.
operationId: v3Info
x-speakeasy-name-override: Info
tags:
- Health
responses:
'200':
description: Server build information
content:
application/json:
schema:
$ref: '#/components/schemas/ServerInfo'
/v3/{ledgerName}:
get:
summary: Get a ledger
description: Retrieves a ledger by its name. Requires `ledger:read` scope.
operationId: v3GetLedger
x-speakeasy-name-override: GetLedger
tags:
- Ledgers
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/LedgerName'
responses:
'200':
description: Ledger retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/GetLedgerResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
post:
summary: Create a new ledger
description: |
Creates a new ledger with the specified name. Storage is configured at the server level.
Each ledger has its own Raft group for data consistency. Requires `ledger:write` scope.
The ledger name `_` is reserved: all system / non-ledger routes live
under the `/v3/_/…` segment (e.g. `/v3/_/audit-entries`), so a ledger
named `_` would be unreachable over REST. Creating it is rejected with a
validation error. The exact name `_system` is also reserved for system
events and rejected. Other underscore-prefixed names remain valid.
operationId: v3CreateLedger
x-speakeasy-name-override: CreateLedger
tags:
- Ledgers
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/IdempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateLedgerRequest'
responses:
'201':
description: Ledger created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CreateLedgerResponse'
links:
GetCreatedLedger:
operationId: v3GetLedger
parameters:
ledgerName: '$response.body#/data/name'
DeleteCreatedLedger:
operationId: v3DeleteLedger
parameters:
ledgerName: '$response.body#/data/name'
GetLedgerStats:
operationId: v3GetLedgerStats
parameters:
ledgerName: '$response.body#/data/name'
CreateTransactionInLedger:
operationId: v3CreateTransaction
parameters:
ledgerName: '$response.body#/data/name'
ListLedgerAccounts:
operationId: v3ListAccounts
parameters:
ledgerName: '$response.body#/data/name'
ListLedgerLogs:
operationId: v3ListLedgerLogs
parameters:
ledgerName: '$response.body#/data/name'
SaveNumscriptInLedger:
operationId: v3SaveNumscript
parameters:
ledgerName: '$response.body#/data/name'
BulkInLedger:
operationId: v3BulkOperations
parameters:
ledgerName: '$response.body#/data/name'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'409':
$ref: '#/components/responses/Conflict'
'429':
$ref: '#/components/responses/ResourceExhausted'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
delete:
summary: Delete a ledger
description: Deletes a ledger by its name. This operation removes the ledger and its associated Raft group from the cluster. Requires `ledger:write` scope.
operationId: v3DeleteLedger
x-speakeasy-name-override: DeleteLedger
tags:
- Ledgers
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/IdempotencyKey'
responses:
'204':
description: Ledger deleted successfully
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'429':
$ref: '#/components/responses/ResourceExhausted'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/stats:
get:
summary: Get ledger statistics
description: >-
Returns aggregate usage statistics (transaction, volume, reference, posting, log, revert
and Numscript-execution counts, plus ephemeral-evicted and transient-used volume tallies)
for a ledger. Requires `ledger:read` scope.
On live reads, `transactionCount` and `logCount` are FSM-backed. The seven
usage-derived counters (`postingCount`, `revertCount`, `numscriptExecutionCount`,
`referenceCount`, `ephemeralEvictedCount`, `transientUsedCount`, `volumeCount`)
are materialised asynchronously in the serving replica's usagestore and may lag
committed state even after the request's ReadIndex barrier.
Note: for checkpoint-scoped (historical) reads, only `transactionCount` and `logCount` are
checkpoint-consistent; the usage-derived counters (`postingCount`, `revertCount`,
`numscriptExecutionCount`, `referenceCount`, `ephemeralEvictedCount`, `transientUsedCount`,
`volumeCount`) are sourced from the live usagestore projection, which is not checkpoint-aware,
and are returned as `0` at a checkpoint rather than a live value — treat `0` on a checkpoint
read as "not available at this checkpoint".
operationId: v3GetLedgerStats
x-speakeasy-name-override: GetLedgerStats
tags:
- Ledgers
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/LedgerName'
responses:
'200':
description: Ledger statistics retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/GetLedgerStatsResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
description: Ledger not found (`LEDGER_NOT_FOUND`)
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/logs:
get:
summary: List logs for a ledger
description: |
Lists log entries for a specific ledger, paged by ledger-local log ID
(ascending unless `reverse=true`).
Requires the builtin `LOG` index to be enabled on the ledger via `CreateIndex`.
Requires `ledger:read` scope.
operationId: v3ListLedgerLogs
x-speakeasy-name-override: ListLedgerLogs
tags:
- Logs
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/BigIntAsString'
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageCursor'
- name: reverse
in: query
schema:
type: boolean
default: false
description: List in descending ledger-local log ID order when true.
- name: startDate
in: query
schema:
type: string
format: date-time
description: |
Filter logs with date >= startDate (inclusive, RFC3339 format).
Must be on or after the Unix epoch (1970-01-01T00:00:00Z); earlier
dates are rejected with a 400.
Requires the builtin `LOG_DATE` index to be enabled on the ledger.
- name: endDate
in: query
schema:
type: string
format: date-time
description: |
Filter logs with date < endDate (exclusive, RFC3339 format).
Must be on or after the Unix epoch (1970-01-01T00:00:00Z); earlier
dates are rejected with a 400.
Requires the builtin `LOG_DATE` index to be enabled on the ledger.
- $ref: '#/components/parameters/ListFilter'
responses:
'200':
description: Logs retrieved successfully
content:
application/json:
schema:
type: object
required:
- data
- hasMore
properties:
data:
type: array
items:
$ref: '#/components/schemas/SystemLog'
next:
$ref: '#/components/schemas/PageToken'
previous:
$ref: '#/components/schemas/PageToken'
hasMore:
type: boolean
description: True when a following page exists; set iff `next` is.
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/_/audit-entries:
get:
summary: List audit entries
description: |
Lists audit trail entries (one per proposal, success or failure) across
the whole bucket, paged by audit sequence (ascending unless
`reverse=true`). Audit reads are
not ledger-scoped in the path — a single proposal can touch several
ledgers — so ledger scope, outcome and other dimensions are expressed
through the `filter` query parameter.
This endpoint always performs a live read and does not expose pinned
checkpoint reads. Filters containing indexed audit conditions wait for
the audit projection to certify the request's fixed main-store horizon;
matching entries are loaded from that same main snapshot. Unfiltered
reads and sequence-only bounds scan the audit zone directly without
waiting for the audit projection.
Requires `ledger:ReadAudit` scope.
operationId: v3ListAuditEntries
x-speakeasy-name-override: ListAuditEntries
tags:
- Audit
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageCursor'
- name: reverse
in: query
schema:
type: boolean
default: false
description: Iterate newest-first (descending sequence) when true
- name: filter
in: query
schema:
type: string
description: |
A filter, decoded by the same shared dual-format decoder every list
endpoint uses (see the `ListFilter` parameter), restricted to bare
audit fields (`outcome`, `ledger`, `seq`, `proposal_id`,
`timestamp`, `log_seq`, `caller_subject`, `order_type`,
`idempotency_key`). These are
written without any prefix and are resolved against the audit query
target (EN-1549 — this replaced the old `audit[...]` namespaced
syntax; it is a breaking change with no backward compatibility):
- `outcome == failure`
- `ledger == main`
- `order_type in (create_transaction, revert_transaction)`
- `seq between 1000 and 2000`
- `timestamp >= "2023-11-14T22:13:20Z"`
- `idempotency_key == "retry-123"`
- `idempotency_key ^= "import-2026-"`
Supported fields: `seq`, `proposal_id`, `log_seq` (numeric);
`timestamp` (RFC3339 or unix microseconds); `outcome`
(success|failure), `ledger`, `caller_subject`, `order_type`,
`idempotency_key` (string; `idempotency_key` also supports prefix
matching with `^=`; a reused key returns every historical audit
entry; bare alphanumeric values are accepted unquoted, while values
containing `-`, `:`, spaces, or other non-identifier characters
must be single- or double-quoted; keys containing both `"` and `'`
cannot be expressed in the textual DSL: use the structured form for
exact and `in` lookups (`{"$match":{"idempotency_key":"…"}}`, an
`$or` of such leaves) and the gRPC API directly
(`AuditCondition.string_prefix`) for prefix lookups). Bare audit fields are resolved against the audit query
target: `timestamp` and `ledger` collide with the transaction
`timestamp` field and the top-level `ledger` condition, so on the
audit target they resolve to the audit condition (and only there —
hence audit fields are valid on this endpoint only). The structured
JSON form uses the same bare field names, resolved against the
audit target the same way: `{"$match":{"outcome":"failure"}}`,
`{"$gte":{"seq":1000}}`, `{"$match":{"idempotency_key":"retry-123"}}`.
Parameters (`{"$param": …}`) are rejected on audit fields, and the
`idempotency_key ^=` prefix match has no structured form (the JSON
DSL has no prefix operator).
responses:
'200':
description: List of audit entries
content:
application/json:
schema:
type: object
required:
- data
- hasMore
properties:
data:
type: array
items:
$ref: '#/components/schemas/AuditEntry'
next:
$ref: '#/components/schemas/PageToken'
previous:
$ref: '#/components/schemas/PageToken'
hasMore:
type: boolean
description: True when a following page exists; set iff `next` is.
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/_/audit-entries/{sequence}:
get:
summary: Get an audit entry
description: |
Returns a single audit entry by its global sequence, with per-order
`items` populated (the list endpoint omits `items` for compactness).
Requires `ledger:ReadAudit` scope.
operationId: v3GetAuditEntry
x-speakeasy-name-override: GetAuditEntry
tags:
- Audit
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- name: sequence
in: path
required: true
schema:
type: integer
format: uint64
minimum: 0
description: Audit entry sequence
responses:
'200':
description: The audit entry
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/AuditEntry'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/promote:
post:
summary: Promote a mirror ledger
description: |
Promotes a mirror-mode ledger to normal mode. After promotion, the mirror sync
worker is stopped and the ledger accepts direct write operations. Requires `ledger:write` scope.
operationId: v3PromoteLedger
x-speakeasy-name-override: PromoteLedger
tags:
- Ledgers
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/LedgerName'
responses:
'201':
description: Ledger promoted successfully
content:
application/json:
schema:
$ref: '#/components/schemas/PromoteLedgerResponse'
'400':
description: The request is invalid, or the ledger is not in mirror mode (`LEDGER_NOT_IN_MIRROR_MODE`).
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
description: The ledger has been deleted (`LEDGER_DELETED`).
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'429':
$ref: '#/components/responses/ResourceExhausted'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/transactions:
post:
summary: Create a new transaction
description: |
Creates a new transaction in the specified ledger with the specified postings. Requires `ledger:write` scope.
Signed requests use `application/json` (including MIME parameters) with
`request` and standard-base64 `payload`. Either signing header, even if
empty, selects this wrapper; with neither header present, the ordinary REST body applies.
Runtime headers choose the representation from the documented anyOf.
The signed protobuf batch must
equal the route/body/Idempotency-Key-derived batch in full. Supply exactly
one nonempty Formance-Signing-Key-Id and Formance-Signature header; the
latter is a standard-base64 Ed25519 signature of 64 decoded bytes. Missing,
empty or repeated signing headers, invalid base64 and wrong signature
length return 400. Signing headers with a non-JSON or missing content type return 415.
Signature enforcement
returns 401 `UNAUTHENTICATED` when required but absent and 403
`PERMISSION_DENIED` for invalid, unknown/revoked-key or mismatched
signatures. Malformed signed envelopes return 400. The complete
wrapper counts toward the 4 MiB body limit. JWT scopes still apply.
operationId: v3CreateTransaction
x-speakeasy-name-override: CreateTransaction
tags:
- Transactions
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/BigIntAsString'
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/IdempotencyKey'
- $ref: '#/components/parameters/SigningKeyId'
- $ref: '#/components/parameters/RequestSignature'
requestBody:
required: true
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/CreateTransactionRequest'
- $ref: '#/components/schemas/SignedCreateTransactionRequest'
responses:
'201':
description: Transaction created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTransactionResponse'
links:
GetCreatedTransaction:
operationId: v3GetTransaction
parameters:
ledgerName: '$request.path.ledgerName'
transactionId: '$response.body#/data/transaction/id'
RevertCreatedTransaction:
operationId: v3RevertTransaction
parameters:
ledgerName: '$request.path.ledgerName'
transactionId: '$response.body#/data/transaction/id'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
description: Conflict (concurrent modification, or reference already claimed by another transaction). Callers that need continue-on-failure semantics should use the bulk endpoint with a per-entry `skippableReasons` list.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'429':
$ref: '#/components/responses/ResourceExhausted'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
get:
summary: List transactions for a ledger
description: |
Lists transactions for a specific ledger. The default order is
newest-first (descending transaction id); pass `reverse=true` to
get oldest-first (ascending). Supports cursor pagination (`pageSize`,
`cursor`), an optional date range (`startDate`/`endDate`),
and the generic `filter` parameter (e.g. reference selection via
`filter={"$match":{"reference":"..."}}`, URL-encoded). Requires
`ledger:ReadTransaction` scope.
Exact address filters search retained transaction history for any,
source and destination roles even when the current account is absent.
Address prefixes enumerate current accounts. Purging an EPHEMERAL
volume does not remove exact historical address matches. Previously
omitted index mappings require an explicit address-index repair.
This is a live read, linearizable by default. `X-Consistency: stale`
reads the receiving node's local state, which may lag the leader. Every
projection used by the filter is automatically aligned. Unlike the
gRPC API, it does not accept the `checkpointId` option to pin the read
to a specific historical snapshot — use gRPC for checkpoint-pinned
reads. (Tracked follow-up, same carve-out as the audit reads.)
operationId: v3ListLedgerTransactions
x-speakeasy-name-override: ListLedgerTransactions
tags:
- Transactions
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/BigIntAsString'
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageCursor'
- name: reverse
in: query
schema:
type: boolean
default: false
description: |
Reverse the default order. Default (`false`) returns
newest-first (descending); `true` returns oldest-first
(ascending). Mirrors the gRPC `ListTransactions` reverse
flag semantic.
- name: startDate
in: query
schema:
type: string
format: date-time
description: |
Filter transactions with timestamp >= startDate (inclusive, RFC3339 format).
Requires the builtin `TX_BUILTIN_INDEX_TIMESTAMP` index to be enabled on the ledger.
- name: endDate
in: query
schema:
type: string
format: date-time
description: |
Filter transactions with timestamp < endDate (exclusive, RFC3339 format).
Requires the builtin `TX_BUILTIN_INDEX_TIMESTAMP` index to be enabled on the ledger.
- $ref: '#/components/parameters/ListFilter'
- $ref: '#/components/parameters/QueryProfile'
responses:
'200':
description: Transactions retrieved successfully.
headers:
X-Query-Profile-Result:
$ref: '#/components/headers/QueryProfileResult'
content:
application/json:
schema:
type: object
required:
- data
- hasMore
properties:
data:
type: array
items:
$ref: '#/components/schemas/TransactionResponse'
next:
$ref: '#/components/schemas/PageToken'
previous:
$ref: '#/components/schemas/PageToken'
hasMore:
type: boolean
description: True when a following page exists; set iff `next` is.
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/transactions/{transactionId}:
get:
summary: Get a transaction
description: Retrieves a transaction by its ID from the specified ledger. Requires `ledger:read` scope.
operationId: v3GetTransaction
x-speakeasy-name-override: GetTransaction
tags:
- Transactions
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/BigIntAsString'
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/TransactionId'
responses:
'200':
description: Transaction retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/GetTransactionResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/accounts:
get:
summary: List accounts
description: |
Lists accounts in a ledger in alphabetical order with cursor
pagination and an optional generic `filter` (e.g. address-prefix
selection via `filter=address ^= "users:"`). Requires `ledger:read`
scope.
operationId: v3ListAccounts
x-speakeasy-name-override: ListAccounts
tags:
- Accounts
security:
- BearerAuth: []
- {}
parameters:
- $ref: '#/components/parameters/Consistency'
- $ref: '#/components/parameters/BigIntAsString'
- $ref: '#/components/parameters/LedgerName'
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageCursor'
- name: reverse
in: query
schema:
type: boolean
default: false
description: |
Reverse the default order. Default (`false`) returns accounts in
alphabetical order; `true` returns reverse alphabetical order.
- $ref: '#/components/parameters/ListFilter'
- $ref: '#/components/parameters/QueryProfile'
responses:
'200':
description: List of accounts
headers:
X-Query-Profile-Result:
$ref: '#/components/headers/QueryProfileResult'
content:
application/json:
schema:
type: object
required:
- data
- hasMore
properties:
data:
type: array
items:
$ref: '#/components/schemas/Account'
next:
$ref: '#/components/schemas/PageToken'
previous:
$ref: '#/components/schemas/PageToken'
hasMore:
type: boolean
description: True when a following page exists; set iff `next` is.
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'503':
$ref: '#/components/responses/ServiceUnavailable'
'500':
$ref: '#/components/responses/InternalServerError'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'405':
$ref: '#/components/responses/MethodNotAllowed'
/v3/{ledgerName}/accounts/{address}:
get:
summary: Get an account
description: Retrieves account information including metadata for a specific account address. Requires `ledger:read` scope.
operationId: v3GetAccount
x-speakeasy-name-override: GetAccount
tags:
- Accounts