triqai 0.2.7 → 0.3.0

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.
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Triqai Transaction Enrichment API
4
- version: 1.5.37
4
+ version: 1.5.53
5
5
  description: |
6
6
  The Triqai API provides transaction enrichment capabilities for financial applications.
7
7
 
@@ -12,7 +12,8 @@ info:
12
12
  ## Rate Limiting
13
13
 
14
14
  Per-organization limits use a token bucket (RPS) plus a concurrent in-flight cap.
15
- Headers may include:
15
+ Every `/v1/...` endpoint except `GET /v1` returns these headers once the organization
16
+ rate-limit check has run, including on its 429 responses:
16
17
  - `X-RateLimit-Limit`
17
18
  - `X-RateLimit-Remaining`
18
19
  - `X-RateLimit-Reset`
@@ -20,15 +21,26 @@ info:
20
21
  - `X-RateLimit-Concurrency-Limit`
21
22
  - `X-RateLimit-Concurrency-Remaining`
22
23
 
24
+ `X-RateLimit-Limit` and `X-RateLimit-Remaining` describe the limit named by `X-RateLimit-Scope`.
25
+ On a `concurrency` 429 they carry the concurrent request cap and the free request slots,
26
+ not the per-second bucket.
27
+
28
+ Requests with a missing or malformed API key, and repeated API key lookups from one IP address,
29
+ have their own limits. Their 429 responses send only `Retry-After`.
30
+
23
31
  `Retry-After` is returned in **seconds** on throttled responses.
24
32
 
25
33
  ## Idempotency
26
34
 
27
- You must supply `Idempotency-Key` (or `X-Idempotency-Key`) for enrichment requests so retries preserve billing and persistence identity.
28
- Keys must match `^[a-zA-Z0-9_-]{1,64}$`.
29
- Reusing a key returns `409`:
30
- - `state=completed`: request with this key already finished
31
- - `state=in_progress`: request with this key is still processing (`Retry-After` included)
35
+ `Idempotency-Key` (or `X-Idempotency-Key`) on enrichment requests is optional. It only matters when the same request can be sent more than once: without a key, every request, including a retry, is a new enrichment and is charged. The Node.js SDK sends a key with every enrichment and reuses it on its own retries. To retry across separate calls, or to re-send transactions you have already enriched, send one key per bank transaction, such as your own transaction ID, and reuse it only for that same request.
36
+ Keys must match `^[a-zA-Z0-9_-]{1,64}$` and are scoped to your organization. A key identifies one request: its normalized `title`, `country`, `type` and `options` (including `options.p2p`).
37
+ Reusing a key:
38
+ - Same request, completed: `200` with the stored result and the same `meta.transactionId`. No credit is charged, but the replay counts toward your rate limit and, like any enrichment, can be refused with `402` when no credit is available.
39
+ - Same request, still processing: `409` `DUPLICATE_REQUEST` with `details.state=in_progress` and `Retry-After`.
40
+ - Same request, stored result partial: the request is enriched again and can complete the result. Only the first complete result is charged.
41
+ - Different request: `409` `DUPLICATE_REQUEST` with `details.state=completed` and `details.reason=payload_mismatch`. Nothing is charged and no stored data is returned.
42
+ - If the stored result cannot be read within a few minutes of the original request, a retry may return `409` `DUPLICATE_REQUEST` with `details.state=completed` and no `reason`. Retry shortly.
43
+ After you delete a transaction, its key returns `410`. After the transaction passes your retention period, its key enriches as a new, charged request.
32
44
  contact:
33
45
  name: Triqai Contact
34
46
  url: https://triqai.com/contact
@@ -67,6 +79,8 @@ paths:
67
79
  application/json:
68
80
  schema:
69
81
  $ref: '#/components/schemas/HealthResponse'
82
+ '422':
83
+ $ref: '#/components/responses/ValidationError'
70
84
 
71
85
  /health:
72
86
  get:
@@ -82,6 +96,8 @@ paths:
82
96
  application/json:
83
97
  schema:
84
98
  $ref: '#/components/schemas/HealthResponse'
99
+ '422':
100
+ $ref: '#/components/responses/ValidationError'
85
101
 
86
102
  /v1:
87
103
  get:
@@ -100,6 +116,14 @@ paths:
100
116
  $ref: '#/components/responses/Unauthorized'
101
117
  '403':
102
118
  $ref: '#/components/responses/Forbidden'
119
+ '422':
120
+ $ref: '#/components/responses/ValidationError'
121
+ '429':
122
+ $ref: '#/components/responses/RateLimited'
123
+ '500':
124
+ $ref: '#/components/responses/InternalError'
125
+ '503':
126
+ $ref: '#/components/responses/ServiceUnavailable'
103
127
 
104
128
  /v1/transactions/enrich:
105
129
  post:
@@ -111,8 +135,8 @@ paths:
111
135
  parameters:
112
136
  - name: Idempotency-Key
113
137
  in: header
114
- required: true
115
- description: Required retry identity. `X-Idempotency-Key` is also accepted and must match when both are sent.
138
+ required: false
139
+ description: Optional. One key per bank transaction, used only for that request. A retry of the same request with this key returns the stored result without a charge; a different request with it returns `409` with `details.reason=payload_mismatch`. Without a key, every request is a new, charged enrichment. `X-Idempotency-Key` is also accepted and must match when both are sent.
116
140
  schema:
117
141
  type: string
118
142
  minLength: 1
@@ -157,6 +181,14 @@ paths:
157
181
  name: 'Starbucks'
158
182
  location:
159
183
  cityName: 'Amsterdam'
184
+ person_to_person:
185
+ summary: Known person-to-person transfer
186
+ value:
187
+ title: 'BILL PAYMENT TO J D MORGAN REF RENT'
188
+ country: 'GB'
189
+ type: 'expense'
190
+ options:
191
+ p2p: true
160
192
  with_filters:
161
193
  summary: Skip intermediary and location extraction
162
194
  value:
@@ -211,9 +243,11 @@ paths:
211
243
  - name: page
212
244
  in: query
213
245
  required: false
246
+ description: Page number, at most 10000.
214
247
  schema:
215
248
  type: integer
216
249
  minimum: 1
250
+ maximum: 10000
217
251
  default: 1
218
252
  - name: size
219
253
  in: query
@@ -226,14 +260,14 @@ paths:
226
260
  - name: startDate
227
261
  in: query
228
262
  required: false
229
- description: Inclusive lower bound (ISO 8601 timestamp)
263
+ description: Inclusive lower bound (ISO 8601 date or timestamp between 0001-01-01 and 9999-12-31 UTC).
230
264
  schema:
231
265
  type: string
232
266
  format: date-time
233
267
  - name: endDate
234
268
  in: query
235
269
  required: false
236
- description: Inclusive upper bound (ISO 8601 timestamp)
270
+ description: Inclusive upper bound (ISO 8601 date or timestamp between 0001-01-01 and 9999-12-31 UTC).
237
271
  schema:
238
272
  type: string
239
273
  format: date-time
@@ -254,6 +288,8 @@ paths:
254
288
  $ref: '#/components/responses/RateLimited'
255
289
  '500':
256
290
  $ref: '#/components/responses/InternalError'
291
+ '503':
292
+ $ref: '#/components/responses/ServiceUnavailable'
257
293
 
258
294
  /v1/transactions/{id}:
259
295
  get:
@@ -282,6 +318,8 @@ paths:
282
318
  $ref: '#/components/responses/RateLimited'
283
319
  '500':
284
320
  $ref: '#/components/responses/InternalError'
321
+ '503':
322
+ $ref: '#/components/responses/ServiceUnavailable'
285
323
 
286
324
  delete:
287
325
  tags:
@@ -328,7 +366,7 @@ paths:
328
366
  - name: afterDate
329
367
  in: query
330
368
  required: false
331
- description: Only count transactions created on or after this ISO 8601 timestamp.
369
+ description: Only count transactions created on or after this ISO 8601 date or timestamp (between 0001-01-01 and 9999-12-31 UTC).
332
370
  schema:
333
371
  type: string
334
372
  format: date-time
@@ -349,6 +387,8 @@ paths:
349
387
  $ref: '#/components/responses/RateLimited'
350
388
  '500':
351
389
  $ref: '#/components/responses/InternalError'
390
+ '503':
391
+ $ref: '#/components/responses/ServiceUnavailable'
352
392
 
353
393
  /v1/transactions/batch:
354
394
  delete:
@@ -423,10 +463,14 @@ paths:
423
463
  $ref: '#/components/responses/Unauthorized'
424
464
  '403':
425
465
  $ref: '#/components/responses/Forbidden'
466
+ '422':
467
+ $ref: '#/components/responses/ValidationError'
426
468
  '429':
427
469
  $ref: '#/components/responses/RateLimited'
428
470
  '500':
429
471
  $ref: '#/components/responses/InternalError'
472
+ '503':
473
+ $ref: '#/components/responses/ServiceUnavailable'
430
474
 
431
475
  /v1/banks:
432
476
  get:
@@ -475,6 +519,8 @@ paths:
475
519
  $ref: '#/components/responses/RateLimited'
476
520
  '500':
477
521
  $ref: '#/components/responses/InternalError'
522
+ '503':
523
+ $ref: '#/components/responses/ServiceUnavailable'
478
524
 
479
525
  /v1/banks/{id}:
480
526
  get:
@@ -503,6 +549,8 @@ paths:
503
549
  $ref: '#/components/responses/RateLimited'
504
550
  '500':
505
551
  $ref: '#/components/responses/InternalError'
552
+ '503':
553
+ $ref: '#/components/responses/ServiceUnavailable'
506
554
 
507
555
  /v1/merchants/{id}:
508
556
  get:
@@ -531,6 +579,8 @@ paths:
531
579
  $ref: '#/components/responses/RateLimited'
532
580
  '500':
533
581
  $ref: '#/components/responses/InternalError'
582
+ '503':
583
+ $ref: '#/components/responses/ServiceUnavailable'
534
584
 
535
585
  /v1/locations/{id}:
536
586
  get:
@@ -559,6 +609,8 @@ paths:
559
609
  $ref: '#/components/responses/RateLimited'
560
610
  '500':
561
611
  $ref: '#/components/responses/InternalError'
612
+ '503':
613
+ $ref: '#/components/responses/ServiceUnavailable'
562
614
 
563
615
  /v1/intermediaries/{id}:
564
616
  get:
@@ -587,6 +639,8 @@ paths:
587
639
  $ref: '#/components/responses/RateLimited'
588
640
  '500':
589
641
  $ref: '#/components/responses/InternalError'
642
+ '503':
643
+ $ref: '#/components/responses/ServiceUnavailable'
590
644
 
591
645
  /v1/report-issue:
592
646
  post:
@@ -596,6 +650,7 @@ paths:
596
650
  operationId: createIssueReport
597
651
  requestBody:
598
652
  required: true
653
+ description: The request body must not exceed 32,768 bytes.
599
654
  content:
600
655
  application/json:
601
656
  schema:
@@ -619,6 +674,8 @@ paths:
619
674
  $ref: '#/components/responses/RateLimited'
620
675
  '500':
621
676
  $ref: '#/components/responses/InternalError'
677
+ '503':
678
+ $ref: '#/components/responses/ServiceUnavailable'
622
679
 
623
680
  get:
624
681
  tags:
@@ -629,13 +686,16 @@ paths:
629
686
  - name: page
630
687
  in: query
631
688
  required: false
689
+ description: Page number, at most 10000. Values below 1 are treated as 1.
632
690
  schema:
633
691
  type: integer
634
692
  minimum: 1
693
+ maximum: 10000
635
694
  default: 1
636
695
  - name: size
637
696
  in: query
638
697
  required: false
698
+ description: Page size, at most 100. Larger values are capped at 100 instead of being rejected, and values below 1 are treated as 1.
639
699
  schema:
640
700
  type: integer
641
701
  minimum: 1
@@ -669,6 +729,8 @@ paths:
669
729
  $ref: '#/components/responses/RateLimited'
670
730
  '500':
671
731
  $ref: '#/components/responses/InternalError'
732
+ '503':
733
+ $ref: '#/components/responses/ServiceUnavailable'
672
734
 
673
735
  /v1/report-issue/{id}:
674
736
  get:
@@ -697,6 +759,8 @@ paths:
697
759
  $ref: '#/components/responses/RateLimited'
698
760
  '500':
699
761
  $ref: '#/components/responses/InternalError'
762
+ '503':
763
+ $ref: '#/components/responses/ServiceUnavailable'
700
764
 
701
765
  components:
702
766
  securitySchemes:
@@ -820,6 +884,10 @@ components:
820
884
  state:
821
885
  type: string
822
886
  enum: [in_progress, completed]
887
+ reason:
888
+ type: string
889
+ enum: [payload_mismatch]
890
+ description: Present when the key was already used for a different request (`state=completed`). The stored result is not returned.
823
891
  retryAfterSeconds:
824
892
  type: integer
825
893
  minimum: 1
@@ -957,11 +1025,27 @@ components:
957
1025
  type: object
958
1026
  description: |
959
1027
  Optional enrichment controls. Use `filters` to skip specific entity types,
960
- or pre-fill known entity data to improve accuracy and reduce latency.
1028
+ pre-fill known entity data to improve accuracy and reduce latency, or set
1029
+ `p2p` when you already know whether the payment went to a person.
961
1030
 
962
1031
  **Mutual exclusivity:** a filter flag (e.g. `noMerchant`) cannot be combined with
963
- pre-filled data for the same entity type.
1032
+ pre-filled data for the same entity type, and `p2p: true` cannot be combined with
1033
+ pre-filled `merchant` data.
964
1034
  properties:
1035
+ p2p:
1036
+ type: boolean
1037
+ description: |
1038
+ Whether the transaction is a person-to-person transfer, when you know it from the
1039
+ payment rail (for example an account transfer to a payee, or a card payment).
1040
+
1041
+ - `true`: the counterparty is a private person. No merchant is returned; the
1042
+ response has a `person` entity when the title names the person, and the
1043
+ `Peer to Peer` category.
1044
+ - `false`: the counterparty is a business or organization. No `person` entity
1045
+ and never the `Peer to Peer` category.
1046
+ - Omitted: Triqai decides from the title and web evidence.
1047
+
1048
+ Requests with different `p2p` values are cached separately.
965
1049
  filters:
966
1050
  $ref: '#/components/schemas/EnrichmentFilterOptions'
967
1051
  merchant:
@@ -975,6 +1059,21 @@ components:
975
1059
  items:
976
1060
  $ref: '#/components/schemas/PrefilledIntermediary'
977
1061
  allOf:
1062
+ - if:
1063
+ required: [p2p]
1064
+ properties:
1065
+ p2p:
1066
+ const: true
1067
+ then:
1068
+ not:
1069
+ required: [merchant]
1070
+ properties:
1071
+ merchant:
1072
+ type: object
1073
+ anyOf:
1074
+ - required: [id]
1075
+ - required: [name]
1076
+ - required: [domain]
978
1077
  - if:
979
1078
  required: [filters]
980
1079
  properties:
@@ -1180,6 +1279,10 @@ components:
1180
1279
 
1181
1280
  CategoryStructure:
1182
1281
  type: object
1282
+ description: |
1283
+ Category path from the most specific category up to its top-level category.
1284
+ For example, a parking payment has `primary` Parking, `secondary` Vehicle Services
1285
+ and `tertiary` Transportation.
1183
1286
  required:
1184
1287
  - primary
1185
1288
  - secondary
@@ -1188,11 +1291,14 @@ components:
1188
1291
  properties:
1189
1292
  primary:
1190
1293
  $ref: '#/components/schemas/Category'
1294
+ description: The most specific category assigned.
1191
1295
  secondary:
1296
+ description: Parent of `primary`, or `null` when `primary` is a top-level category.
1192
1297
  oneOf:
1193
1298
  - $ref: '#/components/schemas/Category'
1194
1299
  - type: 'null'
1195
1300
  tertiary:
1301
+ description: Parent of `secondary`, or `null` when the category is fewer than three levels deep.
1196
1302
  oneOf:
1197
1303
  - $ref: '#/components/schemas/Category'
1198
1304
  - type: 'null'
@@ -1445,6 +1551,18 @@ components:
1445
1551
  role:
1446
1552
  type: string
1447
1553
 
1554
+ IntermediaryEntityData:
1555
+ allOf:
1556
+ - $ref: '#/components/schemas/IntermediaryData'
1557
+ - type: object
1558
+ properties:
1559
+ category:
1560
+ $ref: '#/components/schemas/CategoryStructure'
1561
+ description: |
1562
+ Category of a recognized platform, such as a food delivery app. Returned for
1563
+ those platforms on `GET /v1/transactions` and `GET /v1/transactions/{id}`;
1564
+ enrichment responses may omit it. Absent for other intermediaries.
1565
+
1448
1566
  PersonData:
1449
1567
  type: object
1450
1568
  required:
@@ -1454,12 +1572,27 @@ components:
1454
1572
  type: string
1455
1573
 
1456
1574
  EntityResult:
1575
+ description: |
1576
+ An entity linked to the transaction. `type` selects the shape of `data`.
1577
+ oneOf:
1578
+ - $ref: '#/components/schemas/MerchantEntityResult'
1579
+ - $ref: '#/components/schemas/LocationEntityResult'
1580
+ - $ref: '#/components/schemas/IntermediaryEntityResult'
1581
+ - $ref: '#/components/schemas/PersonEntityResult'
1582
+ discriminator:
1583
+ propertyName: type
1584
+ mapping:
1585
+ merchant: '#/components/schemas/MerchantEntityResult'
1586
+ location: '#/components/schemas/LocationEntityResult'
1587
+ intermediary: '#/components/schemas/IntermediaryEntityResult'
1588
+ person: '#/components/schemas/PersonEntityResult'
1589
+
1590
+ EntityResultBase:
1457
1591
  type: object
1458
1592
  required:
1459
1593
  - type
1460
1594
  - role
1461
1595
  - confidence
1462
- - data
1463
1596
  properties:
1464
1597
  type:
1465
1598
  type: string
@@ -1468,12 +1601,71 @@ components:
1468
1601
  type: string
1469
1602
  confidence:
1470
1603
  $ref: '#/components/schemas/ConfidenceWithReasons'
1471
- data:
1472
- oneOf:
1473
- - $ref: '#/components/schemas/MerchantEntityData'
1474
- - $ref: '#/components/schemas/LocationData'
1475
- - $ref: '#/components/schemas/IntermediaryData'
1476
- - $ref: '#/components/schemas/PersonData'
1604
+ reasoning:
1605
+ type: string
1606
+ minLength: 1
1607
+ description: |
1608
+ Short AI-written explanation of why this entity was linked to the transaction.
1609
+ Use it for display or debugging only: the wording varies, so don't parse it.
1610
+ Optional and never `null`. It's returned when a stored explanation exists, for
1611
+ example on `GET /v1/transactions`, `GET /v1/transactions/{id}` and enrichment
1612
+ results reused from an earlier request, and omitted otherwise.
1613
+
1614
+ MerchantEntityResult:
1615
+ allOf:
1616
+ - $ref: '#/components/schemas/EntityResultBase'
1617
+ - type: object
1618
+ required:
1619
+ - type
1620
+ - data
1621
+ properties:
1622
+ type:
1623
+ type: string
1624
+ enum: [merchant]
1625
+ data:
1626
+ $ref: '#/components/schemas/MerchantEntityData'
1627
+
1628
+ LocationEntityResult:
1629
+ allOf:
1630
+ - $ref: '#/components/schemas/EntityResultBase'
1631
+ - type: object
1632
+ required:
1633
+ - type
1634
+ - data
1635
+ properties:
1636
+ type:
1637
+ type: string
1638
+ enum: [location]
1639
+ data:
1640
+ $ref: '#/components/schemas/LocationData'
1641
+
1642
+ IntermediaryEntityResult:
1643
+ allOf:
1644
+ - $ref: '#/components/schemas/EntityResultBase'
1645
+ - type: object
1646
+ required:
1647
+ - type
1648
+ - data
1649
+ properties:
1650
+ type:
1651
+ type: string
1652
+ enum: [intermediary]
1653
+ data:
1654
+ $ref: '#/components/schemas/IntermediaryEntityData'
1655
+
1656
+ PersonEntityResult:
1657
+ allOf:
1658
+ - $ref: '#/components/schemas/EntityResultBase'
1659
+ - type: object
1660
+ required:
1661
+ - type
1662
+ - data
1663
+ properties:
1664
+ type:
1665
+ type: string
1666
+ enum: [person]
1667
+ data:
1668
+ $ref: '#/components/schemas/PersonData'
1477
1669
 
1478
1670
  TransactionData:
1479
1671
  type: object
@@ -2141,7 +2333,9 @@ components:
2141
2333
  version: '1.1.2'
2142
2334
 
2143
2335
  ValidationError:
2144
- description: Request validation failed
2336
+ description: |
2337
+ Request validation failed. Every endpoint returns this for a malformed `Idempotency-Key`
2338
+ or `X-Idempotency-Key` header, or when both headers are sent with different values.
2145
2339
  content:
2146
2340
  application/json:
2147
2341
  schema:
@@ -2196,26 +2390,35 @@ components:
2196
2390
  $ref: '#/components/schemas/DuplicateRequestErrorResponse'
2197
2391
 
2198
2392
  RateLimited:
2199
- description: Rate limit exceeded
2393
+ description: |
2394
+ Rate limit exceeded. Organization limits send the `X-RateLimit-*` headers.
2395
+ Requests with a missing or malformed API key, and repeated API key lookups from
2396
+ one IP address, have separate limits whose 429s send only `Retry-After`, without
2397
+ any `X-RateLimit-*` header.
2200
2398
  headers:
2201
2399
  X-RateLimit-Limit:
2202
2400
  schema:
2203
2401
  type: integer
2204
- description: Requests per second (sustained rate)
2402
+ description: |
2403
+ Limit named by `X-RateLimit-Scope`. For `rps`, the sustained requests per second.
2404
+ For `concurrency`, the maximum concurrent in-flight requests.
2205
2405
  X-RateLimit-Remaining:
2206
2406
  schema:
2207
2407
  type: integer
2208
- description: Current token-bucket capacity available
2408
+ description: |
2409
+ Remaining capacity for the limit named by `X-RateLimit-Scope`. For `rps`, the
2410
+ token-bucket requests left (0 when throttled). For `concurrency`, the free
2411
+ concurrent request slots.
2209
2412
  X-RateLimit-Reset:
2210
2413
  schema:
2211
2414
  type: string
2212
2415
  format: date-time
2213
- description: Timestamp when token bucket refills
2416
+ description: Time when the limit named by `X-RateLimit-Scope` is expected to admit a new request.
2214
2417
  X-RateLimit-Scope:
2215
2418
  schema:
2216
2419
  type: string
2217
2420
  enum: [rps, concurrency]
2218
- description: Active limiting dimension
2421
+ description: Limit that rejected the request.
2219
2422
  X-RateLimit-Concurrency-Limit:
2220
2423
  schema:
2221
2424
  type: integer
@@ -2257,7 +2460,9 @@ components:
2257
2460
  $ref: '#/components/schemas/ErrorResponse'
2258
2461
 
2259
2462
  ServiceUnavailable:
2260
- description: Service temporarily unavailable
2463
+ description: |
2464
+ Service temporarily unavailable, for example when authentication or the rate-limit
2465
+ and credit check can't complete. Retry after `Retry-After` seconds.
2261
2466
  headers:
2262
2467
  Retry-After:
2263
2468
  schema:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triqai",
3
- "version": "0.2.7",
3
+ "version": "0.3.0",
4
4
  "description": "Official TypeScript SDK for the Triqai Transaction Enrichment API",
5
5
  "author": "Triqai <hello@triqai.com>",
6
6
  "license": "MIT",