@bitgen/sdk 0.1.6 → 1.0.4

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 (338) hide show
  1. package/CHANGELOG.md +63 -2
  2. package/README.md +27 -106
  3. package/dist/cjs/client.d.ts +20 -8
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +33 -12
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/constants.d.ts +256 -0
  8. package/dist/cjs/constants.d.ts.map +1 -0
  9. package/dist/cjs/constants.js +214 -0
  10. package/dist/cjs/constants.js.map +1 -0
  11. package/dist/cjs/error.d.ts +17 -10
  12. package/dist/cjs/error.d.ts.map +1 -1
  13. package/dist/cjs/error.js +25 -7
  14. package/dist/cjs/error.js.map +1 -1
  15. package/dist/cjs/http.d.ts +13 -8
  16. package/dist/cjs/http.d.ts.map +1 -1
  17. package/dist/cjs/http.js +135 -44
  18. package/dist/cjs/http.js.map +1 -1
  19. package/dist/cjs/index.d.ts +14 -1
  20. package/dist/cjs/index.d.ts.map +1 -1
  21. package/dist/cjs/index.js +30 -1
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/resources/apikeys.d.ts +18 -0
  24. package/dist/cjs/resources/apikeys.d.ts.map +1 -0
  25. package/dist/cjs/resources/apikeys.js +31 -0
  26. package/dist/cjs/resources/apikeys.js.map +1 -0
  27. package/dist/cjs/resources/asset.d.ts +17 -5
  28. package/dist/cjs/resources/asset.d.ts.map +1 -1
  29. package/dist/cjs/resources/asset.js +17 -6
  30. package/dist/cjs/resources/asset.js.map +1 -1
  31. package/dist/cjs/resources/bank.d.ts +11 -6
  32. package/dist/cjs/resources/bank.d.ts.map +1 -1
  33. package/dist/cjs/resources/bank.js +17 -9
  34. package/dist/cjs/resources/bank.js.map +1 -1
  35. package/dist/cjs/resources/core.d.ts +12 -0
  36. package/dist/cjs/resources/core.d.ts.map +1 -0
  37. package/dist/cjs/resources/core.js +22 -0
  38. package/dist/cjs/resources/core.js.map +1 -0
  39. package/dist/cjs/resources/custody.d.ts +27 -0
  40. package/dist/cjs/resources/custody.d.ts.map +1 -0
  41. package/dist/cjs/resources/custody.js +38 -0
  42. package/dist/cjs/resources/custody.js.map +1 -0
  43. package/dist/cjs/resources/customer.d.ts +20 -0
  44. package/dist/cjs/resources/customer.d.ts.map +1 -0
  45. package/dist/cjs/resources/customer.js +38 -0
  46. package/dist/cjs/resources/customer.js.map +1 -0
  47. package/dist/cjs/resources/staking.d.ts +32 -0
  48. package/dist/cjs/resources/staking.d.ts.map +1 -0
  49. package/dist/cjs/resources/staking.js +69 -0
  50. package/dist/cjs/resources/staking.js.map +1 -0
  51. package/dist/cjs/resources/trading.d.ts +24 -0
  52. package/dist/cjs/resources/trading.d.ts.map +1 -0
  53. package/dist/cjs/resources/trading.js +41 -0
  54. package/dist/cjs/resources/trading.js.map +1 -0
  55. package/dist/cjs/resources/transaction.d.ts +6 -9
  56. package/dist/cjs/resources/transaction.d.ts.map +1 -1
  57. package/dist/cjs/resources/transaction.js +10 -15
  58. package/dist/cjs/resources/transaction.js.map +1 -1
  59. package/dist/cjs/resources/webhooks.d.ts +46 -0
  60. package/dist/cjs/resources/webhooks.d.ts.map +1 -0
  61. package/dist/cjs/resources/webhooks.js +142 -0
  62. package/dist/cjs/resources/webhooks.js.map +1 -0
  63. package/dist/cjs/types/apikeys.d.ts +43 -0
  64. package/dist/cjs/types/apikeys.d.ts.map +1 -0
  65. package/dist/cjs/types/apikeys.js +3 -0
  66. package/dist/cjs/types/apikeys.js.map +1 -0
  67. package/dist/cjs/types/asset.d.ts +57 -0
  68. package/dist/cjs/types/asset.d.ts.map +1 -0
  69. package/dist/cjs/types/asset.js +3 -0
  70. package/dist/cjs/types/asset.js.map +1 -0
  71. package/dist/cjs/types/bank.d.ts +58 -0
  72. package/dist/cjs/types/bank.d.ts.map +1 -0
  73. package/dist/cjs/types/bank.js +3 -0
  74. package/dist/cjs/types/bank.js.map +1 -0
  75. package/dist/cjs/types/core.d.ts +32 -0
  76. package/dist/cjs/types/core.d.ts.map +1 -0
  77. package/dist/cjs/types/core.js +3 -0
  78. package/dist/cjs/types/core.js.map +1 -0
  79. package/dist/cjs/types/custody.d.ts +50 -0
  80. package/dist/cjs/types/custody.d.ts.map +1 -0
  81. package/dist/cjs/types/custody.js +3 -0
  82. package/dist/cjs/types/custody.js.map +1 -0
  83. package/dist/cjs/types/customer.d.ts +190 -0
  84. package/dist/cjs/types/customer.d.ts.map +1 -0
  85. package/dist/cjs/types/customer.js +3 -0
  86. package/dist/cjs/types/customer.js.map +1 -0
  87. package/dist/cjs/types/index.d.ts +78 -194
  88. package/dist/cjs/types/index.d.ts.map +1 -1
  89. package/dist/cjs/types/index.js +0 -1
  90. package/dist/cjs/types/index.js.map +1 -1
  91. package/dist/cjs/types/staking.d.ts +88 -0
  92. package/dist/cjs/types/staking.d.ts.map +1 -0
  93. package/dist/cjs/types/staking.js +3 -0
  94. package/dist/cjs/types/staking.js.map +1 -0
  95. package/dist/cjs/types/trading.d.ts +51 -0
  96. package/dist/cjs/types/trading.d.ts.map +1 -0
  97. package/dist/cjs/types/trading.js +3 -0
  98. package/dist/cjs/types/trading.js.map +1 -0
  99. package/dist/cjs/types/transaction.d.ts +61 -0
  100. package/dist/cjs/types/transaction.d.ts.map +1 -0
  101. package/dist/cjs/types/transaction.js +3 -0
  102. package/dist/cjs/types/transaction.js.map +1 -0
  103. package/dist/cjs/types/webhooks.d.ts +55 -0
  104. package/dist/cjs/types/webhooks.d.ts.map +1 -0
  105. package/dist/cjs/types/webhooks.js +3 -0
  106. package/dist/cjs/types/webhooks.js.map +1 -0
  107. package/dist/cjs/utils.d.ts +21 -2
  108. package/dist/cjs/utils.d.ts.map +1 -1
  109. package/dist/cjs/utils.js +67 -4
  110. package/dist/cjs/utils.js.map +1 -1
  111. package/dist/cjs/version.d.ts +2 -0
  112. package/dist/cjs/version.d.ts.map +1 -0
  113. package/dist/cjs/version.js +6 -0
  114. package/dist/cjs/version.js.map +1 -0
  115. package/dist/esm/client.d.ts +20 -8
  116. package/dist/esm/client.d.ts.map +1 -1
  117. package/dist/esm/client.js +33 -12
  118. package/dist/esm/client.js.map +1 -1
  119. package/dist/esm/constants.d.ts +256 -0
  120. package/dist/esm/constants.d.ts.map +1 -0
  121. package/dist/esm/constants.js +211 -0
  122. package/dist/esm/constants.js.map +1 -0
  123. package/dist/esm/error.d.ts +17 -10
  124. package/dist/esm/error.d.ts.map +1 -1
  125. package/dist/esm/error.js +24 -6
  126. package/dist/esm/error.js.map +1 -1
  127. package/dist/esm/http.d.ts +13 -8
  128. package/dist/esm/http.d.ts.map +1 -1
  129. package/dist/esm/http.js +136 -45
  130. package/dist/esm/http.js.map +1 -1
  131. package/dist/esm/index.d.ts +14 -1
  132. package/dist/esm/index.d.ts.map +1 -1
  133. package/dist/esm/index.js +6 -0
  134. package/dist/esm/index.js.map +1 -1
  135. package/dist/esm/resources/apikeys.d.ts +18 -0
  136. package/dist/esm/resources/apikeys.d.ts.map +1 -0
  137. package/dist/esm/resources/apikeys.js +27 -0
  138. package/dist/esm/resources/apikeys.js.map +1 -0
  139. package/dist/esm/resources/asset.d.ts +17 -5
  140. package/dist/esm/resources/asset.d.ts.map +1 -1
  141. package/dist/esm/resources/asset.js +17 -6
  142. package/dist/esm/resources/asset.js.map +1 -1
  143. package/dist/esm/resources/bank.d.ts +11 -6
  144. package/dist/esm/resources/bank.d.ts.map +1 -1
  145. package/dist/esm/resources/bank.js +18 -10
  146. package/dist/esm/resources/bank.js.map +1 -1
  147. package/dist/esm/resources/core.d.ts +12 -0
  148. package/dist/esm/resources/core.d.ts.map +1 -0
  149. package/dist/esm/resources/core.js +18 -0
  150. package/dist/esm/resources/core.js.map +1 -0
  151. package/dist/esm/resources/custody.d.ts +27 -0
  152. package/dist/esm/resources/custody.d.ts.map +1 -0
  153. package/dist/esm/resources/custody.js +34 -0
  154. package/dist/esm/resources/custody.js.map +1 -0
  155. package/dist/esm/resources/customer.d.ts +20 -0
  156. package/dist/esm/resources/customer.d.ts.map +1 -0
  157. package/dist/esm/resources/customer.js +34 -0
  158. package/dist/esm/resources/customer.js.map +1 -0
  159. package/dist/esm/resources/staking.d.ts +32 -0
  160. package/dist/esm/resources/staking.d.ts.map +1 -0
  161. package/dist/esm/resources/staking.js +65 -0
  162. package/dist/esm/resources/staking.js.map +1 -0
  163. package/dist/esm/resources/trading.d.ts +24 -0
  164. package/dist/esm/resources/trading.d.ts.map +1 -0
  165. package/dist/esm/resources/trading.js +37 -0
  166. package/dist/esm/resources/trading.js.map +1 -0
  167. package/dist/esm/resources/transaction.d.ts +6 -9
  168. package/dist/esm/resources/transaction.d.ts.map +1 -1
  169. package/dist/esm/resources/transaction.js +11 -16
  170. package/dist/esm/resources/transaction.js.map +1 -1
  171. package/dist/esm/resources/webhooks.d.ts +46 -0
  172. package/dist/esm/resources/webhooks.d.ts.map +1 -0
  173. package/dist/esm/resources/webhooks.js +138 -0
  174. package/dist/esm/resources/webhooks.js.map +1 -0
  175. package/dist/esm/types/apikeys.d.ts +43 -0
  176. package/dist/esm/types/apikeys.d.ts.map +1 -0
  177. package/dist/esm/types/apikeys.js +2 -0
  178. package/dist/esm/types/apikeys.js.map +1 -0
  179. package/dist/esm/types/asset.d.ts +57 -0
  180. package/dist/esm/types/asset.d.ts.map +1 -0
  181. package/dist/esm/types/asset.js +2 -0
  182. package/dist/esm/types/asset.js.map +1 -0
  183. package/dist/esm/types/bank.d.ts +58 -0
  184. package/dist/esm/types/bank.d.ts.map +1 -0
  185. package/dist/esm/types/bank.js +2 -0
  186. package/dist/esm/types/bank.js.map +1 -0
  187. package/dist/esm/types/core.d.ts +32 -0
  188. package/dist/esm/types/core.d.ts.map +1 -0
  189. package/dist/esm/types/core.js +2 -0
  190. package/dist/esm/types/core.js.map +1 -0
  191. package/dist/esm/types/custody.d.ts +50 -0
  192. package/dist/esm/types/custody.d.ts.map +1 -0
  193. package/dist/esm/types/custody.js +2 -0
  194. package/dist/esm/types/custody.js.map +1 -0
  195. package/dist/esm/types/customer.d.ts +190 -0
  196. package/dist/esm/types/customer.d.ts.map +1 -0
  197. package/dist/esm/types/customer.js +2 -0
  198. package/dist/esm/types/customer.js.map +1 -0
  199. package/dist/esm/types/index.d.ts +78 -194
  200. package/dist/esm/types/index.d.ts.map +1 -1
  201. package/dist/esm/types/index.js +0 -1
  202. package/dist/esm/types/index.js.map +1 -1
  203. package/dist/esm/types/staking.d.ts +88 -0
  204. package/dist/esm/types/staking.d.ts.map +1 -0
  205. package/dist/esm/types/staking.js +2 -0
  206. package/dist/esm/types/staking.js.map +1 -0
  207. package/dist/esm/types/trading.d.ts +51 -0
  208. package/dist/esm/types/trading.d.ts.map +1 -0
  209. package/dist/esm/types/trading.js +2 -0
  210. package/dist/esm/types/trading.js.map +1 -0
  211. package/dist/esm/types/transaction.d.ts +61 -0
  212. package/dist/esm/types/transaction.d.ts.map +1 -0
  213. package/dist/esm/types/transaction.js +2 -0
  214. package/dist/esm/types/transaction.js.map +1 -0
  215. package/dist/esm/types/webhooks.d.ts +55 -0
  216. package/dist/esm/types/webhooks.d.ts.map +1 -0
  217. package/dist/esm/types/webhooks.js +2 -0
  218. package/dist/esm/types/webhooks.js.map +1 -0
  219. package/dist/esm/utils.d.ts +21 -2
  220. package/dist/esm/utils.d.ts.map +1 -1
  221. package/dist/esm/utils.js +62 -4
  222. package/dist/esm/utils.js.map +1 -1
  223. package/dist/esm/version.d.ts +2 -0
  224. package/dist/esm/version.d.ts.map +1 -0
  225. package/dist/esm/version.js +3 -0
  226. package/dist/esm/version.js.map +1 -0
  227. package/package.json +29 -12
  228. package/readme/concepts.md +128 -0
  229. package/readme/configuration.md +72 -0
  230. package/readme/errors.md +67 -0
  231. package/readme/installation.md +43 -0
  232. package/readme/media/activation.svg +58 -0
  233. package/readme/media/deposit-flow.svg +70 -0
  234. package/readme/media/order-buy.svg +43 -0
  235. package/readme/media/order-sell.svg +47 -0
  236. package/readme/media/purchase-flow.svg +61 -0
  237. package/readme/media/sale-flow.svg +61 -0
  238. package/readme/media/staking-position.svg +75 -0
  239. package/readme/media/transaction-lifecycle.svg +61 -0
  240. package/readme/media/webhook-delivery.svg +53 -0
  241. package/readme/media/withdrawal-flow.svg +64 -0
  242. package/readme/quick-start.md +87 -0
  243. package/readme/resource/apikeys.md +103 -0
  244. package/readme/resource/asset.md +121 -0
  245. package/readme/resource/bank.md +161 -0
  246. package/readme/resource/core.md +91 -0
  247. package/readme/resource/custody.md +166 -0
  248. package/readme/resource/customer.md +210 -0
  249. package/readme/resource/staking.md +281 -0
  250. package/readme/resource/trading.md +171 -0
  251. package/readme/resource/transaction.md +110 -0
  252. package/readme/resource/webhooks.md +309 -0
  253. package/src/client.ts +46 -0
  254. package/src/constants.ts +281 -0
  255. package/src/error.ts +36 -0
  256. package/src/http.ts +201 -0
  257. package/src/index.ts +111 -0
  258. package/src/resources/apikeys.ts +30 -0
  259. package/src/resources/asset.ts +28 -0
  260. package/src/resources/bank.ts +39 -0
  261. package/src/resources/core.ts +19 -0
  262. package/src/resources/custody.ts +37 -0
  263. package/src/resources/customer.ts +46 -0
  264. package/src/resources/staking.ts +88 -0
  265. package/src/resources/trading.ts +41 -0
  266. package/src/resources/transaction.ts +20 -0
  267. package/src/resources/webhooks.ts +169 -0
  268. package/src/types/apikeys.ts +35 -0
  269. package/src/types/asset.ts +59 -0
  270. package/src/types/bank.ts +60 -0
  271. package/src/types/core.ts +32 -0
  272. package/src/types/custody.ts +40 -0
  273. package/src/types/customer.ts +189 -0
  274. package/src/types/index.ts +215 -0
  275. package/src/types/staking.ts +87 -0
  276. package/src/types/trading.ts +56 -0
  277. package/src/types/transaction.ts +62 -0
  278. package/src/types/webhooks.ts +60 -0
  279. package/src/utils.ts +74 -0
  280. package/src/version.ts +2 -0
  281. package/dist/cjs/resources/order.d.ts +0 -17
  282. package/dist/cjs/resources/order.d.ts.map +0 -1
  283. package/dist/cjs/resources/order.js +0 -30
  284. package/dist/cjs/resources/order.js.map +0 -1
  285. package/dist/cjs/resources/stats.d.ts +0 -11
  286. package/dist/cjs/resources/stats.d.ts.map +0 -1
  287. package/dist/cjs/resources/stats.js +0 -18
  288. package/dist/cjs/resources/stats.js.map +0 -1
  289. package/dist/cjs/resources/user.d.ts +0 -22
  290. package/dist/cjs/resources/user.d.ts.map +0 -1
  291. package/dist/cjs/resources/user.js +0 -37
  292. package/dist/cjs/resources/user.js.map +0 -1
  293. package/dist/cjs/resources/wallet.d.ts +0 -11
  294. package/dist/cjs/resources/wallet.d.ts.map +0 -1
  295. package/dist/cjs/resources/wallet.js +0 -19
  296. package/dist/cjs/resources/wallet.js.map +0 -1
  297. package/dist/esm/resources/order.d.ts +0 -17
  298. package/dist/esm/resources/order.d.ts.map +0 -1
  299. package/dist/esm/resources/order.js +0 -26
  300. package/dist/esm/resources/order.js.map +0 -1
  301. package/dist/esm/resources/stats.d.ts +0 -11
  302. package/dist/esm/resources/stats.d.ts.map +0 -1
  303. package/dist/esm/resources/stats.js +0 -14
  304. package/dist/esm/resources/stats.js.map +0 -1
  305. package/dist/esm/resources/user.d.ts +0 -22
  306. package/dist/esm/resources/user.d.ts.map +0 -1
  307. package/dist/esm/resources/user.js +0 -33
  308. package/dist/esm/resources/user.js.map +0 -1
  309. package/dist/esm/resources/wallet.d.ts +0 -11
  310. package/dist/esm/resources/wallet.d.ts.map +0 -1
  311. package/dist/esm/resources/wallet.js +0 -15
  312. package/dist/esm/resources/wallet.js.map +0 -1
  313. package/dist/types/client.d.ts +0 -19
  314. package/dist/types/client.d.ts.map +0 -1
  315. package/dist/types/error.d.ts +0 -15
  316. package/dist/types/error.d.ts.map +0 -1
  317. package/dist/types/http.d.ts +0 -21
  318. package/dist/types/http.d.ts.map +0 -1
  319. package/dist/types/index.d.ts +0 -4
  320. package/dist/types/index.d.ts.map +0 -1
  321. package/dist/types/resources/asset.d.ts +0 -11
  322. package/dist/types/resources/asset.d.ts.map +0 -1
  323. package/dist/types/resources/bank.d.ts +0 -13
  324. package/dist/types/resources/bank.d.ts.map +0 -1
  325. package/dist/types/resources/order.d.ts +0 -17
  326. package/dist/types/resources/order.d.ts.map +0 -1
  327. package/dist/types/resources/stats.d.ts +0 -11
  328. package/dist/types/resources/stats.d.ts.map +0 -1
  329. package/dist/types/resources/transaction.d.ts +0 -15
  330. package/dist/types/resources/transaction.d.ts.map +0 -1
  331. package/dist/types/resources/user.d.ts +0 -22
  332. package/dist/types/resources/user.d.ts.map +0 -1
  333. package/dist/types/resources/wallet.d.ts +0 -11
  334. package/dist/types/resources/wallet.d.ts.map +0 -1
  335. package/dist/types/types/index.d.ts +0 -213
  336. package/dist/types/types/index.d.ts.map +0 -1
  337. package/dist/types/utils.d.ts +0 -7
  338. package/dist/types/utils.d.ts.map +0 -1
@@ -0,0 +1,91 @@
1
+ # Connectors
2
+
3
+ A connector — a *core* — is a service the BITGEN platform is plugged into: a bank (`CoreType.RAMP`), an exchange (`CoreType.TRADING`), a custodian (`CoreType.CUSTODY`), a staking provider (`CoreType.STAKING`), an identity verification service (`CoreType.IDENTITY`) or an anti-money-laundering service (`CoreType.AML`). `client.core` reads this catalogue: which connectors exist, their state, and — for staking providers — the asset and the offer they carry. Its main use for an integration is to pick a staking provider ([Staking](staking.md)).
4
+
5
+ Examples use `client`, a configured `BitgenClient` ([Configuration](../configuration.md)).
6
+
7
+ ## Methods
8
+
9
+ | Method | What it does | Returns |
10
+ |---|---|---|
11
+ | `list(params?)` | Lists the connectors of the platform, optionally filtered by type, asset and state | `Page<Core>` |
12
+ | `get(core)` | Reads one connector | `Core` |
13
+
14
+ TypeScript types of this resource, exported by the package: `CoreConfigField`, `Core`, `CoreListParams` — the constants `CoreType`, `CoreState` (also types) — plus the shared `CoreRef`, `AssetRef`, `AssetInput`, `Page`.
15
+
16
+ The catalogue is managed by BITGEN. Which connectors your organization uses, and their configuration, are set in the BITGEN interface — not through the API.
17
+
18
+ ## List
19
+
20
+ ```
21
+ client.core.list(params?: CoreListParams): Promise<Page<Core>>
22
+ ```
23
+
24
+ Not paginated: `count` is everything that matches. All the filters are optional and combine.
25
+
26
+ | Parameter | Type | Description |
27
+ |---|---|---|
28
+ | `params.type` | `CoreType` | `CoreType.IDENTITY`, `AML`, `TRADING`, `CUSTODY`, `STAKING` or `RAMP` — anything else → `424 unknown_core_type` |
29
+ | `params.asset` | `AssetInput` | Only the connectors attached to this asset (the `CoreType.STAKING` ones), by uuid or ISO code (`Asset.ETH`) or by model ([Assets](../concepts.md#assets)) — unknown → `404 unknown_asset` |
30
+ | `params.state` | `CoreState` | `CoreState.ENABLED` or `CoreState.DISABLED` — anything else → `400 invalid_core_status` |
31
+
32
+ ```ts
33
+ import { Asset, CoreState, CoreType } from '@bitgen/sdk'
34
+
35
+ const banks = await client.core.list({ type: CoreType.RAMP })
36
+ const exchanges = await client.core.list({ type: CoreType.TRADING })
37
+ const custodians = await client.core.list({ type: CoreType.CUSTODY })
38
+ const providers = await client.core.list({ type: CoreType.STAKING, asset: Asset.ETH }) // the staking providers of ETH
39
+
40
+ for (const provider of providers.items) {
41
+ console.log(provider.name, provider.asset?.iso, provider.state === CoreState.ENABLED) // 'bitgen_eth' 'ETH' true
42
+ }
43
+ ```
44
+
45
+ Returns the matching `Core` connectors ([get](#get)).
46
+
47
+ ## Get
48
+
49
+ ```
50
+ client.core.get(core: string | Core): Promise<Core>
51
+ ```
52
+
53
+ `core` is the uuid of the connector, or a `Core` of `list()`.
54
+
55
+ ```ts
56
+ const core = await client.core.get('CORE_UUID')
57
+
58
+ for (const field of core.config) {
59
+ console.log(field.name, field.data.value) // 'min_deposit' …
60
+ }
61
+ ```
62
+
63
+ Returns a `Core`:
64
+
65
+ | Field | Description |
66
+ |---|---|
67
+ | `uuid` | The connector |
68
+ | `state` | `CoreState.ENABLED` or `CoreState.DISABLED` |
69
+ | `name` | The identifier of the connector — for a `CoreType.STAKING` connector, `<provider>_<iso>` (`figment_sol`, `bitgen_eth`) |
70
+ | `label` | Display name |
71
+ | `type` | `CoreType.IDENTITY`, `AML`, `TRADING`, `CUSTODY`, `STAKING` or `RAMP` |
72
+ | `asset` | `AssetRef`: `{ uuid, iso, label }` for a `CoreType.STAKING` connector (derived from its `name`), `null` for the other types |
73
+ | `config` | The configuration schema of the connector, a list of `CoreConfigField`: `name` (key), `label` (display names `{ fr, en }`), `data.type` (`string`, `int`, `bool`, `password` or `webhook`), `data.value` (the value — empty for secrets). The secrets of your organization's configuration never appear here. |
74
+
75
+ An unknown uuid answers `404 unknown_core`.
76
+
77
+ ## Errors
78
+
79
+ In addition to the [common errors](../errors.md#common-errors):
80
+
81
+ | Status | `code` | Meaning |
82
+ |---|---|---|
83
+ | `400` | `invalid_core_status` | `state` is neither `CoreState.ENABLED` nor `CoreState.DISABLED` |
84
+ | `404` | `unknown_asset` | `list`: unknown `asset` |
85
+ | `404` | `unknown_core` | `get`: unknown connector |
86
+ | `424` | `unknown_core_type` | `type` is not one of the connector types |
87
+
88
+ ## Related
89
+
90
+ - [Staking](staking.md) — `client.staking.providers` is `list` filtered on `CoreType.STAKING`; a `StakingPosition` carries its provider as a `CoreRef`
91
+ - [Assets](../concepts.md#assets) — uuid or ISO code, case
@@ -0,0 +1,166 @@
1
+ # Custody wallets
2
+
3
+ A custody wallet holds the crypto of a customer for one asset, at the custodian of the platform: a deposit address the customer sends funds to, an exact balance, and on-chain withdrawals to external addresses. `client.custody` lists and reads the wallets of a customer, provisions them, reads the EUR value of their custody, and withdraws.
4
+
5
+ Examples use `client`, a configured `BitgenClient` ([Configuration](../configuration.md)). A customer is designated by a `UserRef`: their uuid, or a model carrying it, such as the `Created` returned by `client.customer.create` ([User references](../concepts.md#user-references)). `wallets` and `wallet` also take the uuid of your organization (your `scope`) to read its treasury wallets (`type` `WalletType.TREASURY`, read-only); `portfolio` and `withdraw` are for customers only. A customer who is not an activated member of your organization is refused with `403 org_forbidden` ([Activation and identity](../concepts.md#activation-and-identity)); another organization, with `403 cross_org_forbidden`.
6
+
7
+ ## Methods
8
+
9
+ | Method | What it does | Returns |
10
+ |---|---|---|
11
+ | `wallets(user)` | Lists the wallets of a customer, or of your organization | `Wallet[]` |
12
+ | `wallet(user, asset)` | Reads one wallet with its EUR value curve — provisions it on first read | `Wallet` |
13
+ | `portfolio(user)` | Reads the EUR value curve of the whole custody of a customer | `CustodyPortfolio` |
14
+ | `withdraw(user, params)` | Sends crypto from a wallet to an external address | `{ transaction }` |
15
+
16
+ TypeScript types of this resource, exported by the package: `Wallet`, `CustodyPortfolio`, `TravelRule`, `CustodyWithdrawParams` — the constants `WalletState`, `WalletType` (also types) — plus the shared `UserRef`, `AssetRef`, `AssetInput`, `Amount`.
17
+
18
+ ## Wallets
19
+
20
+ ```
21
+ client.custody.wallets(user: UserRef): Promise<Wallet[]>
22
+ ```
23
+
24
+ ```ts
25
+ const wallets = await client.custody.wallets('CUSTOMER_UUID')
26
+
27
+ for (const wallet of wallets) {
28
+ console.log(wallet.asset.iso, wallet.balance, wallet.address) // 'ETH' '0.5' '0xabc…'
29
+ }
30
+
31
+ const treasury = await client.custody.wallets('YOUR_SCOPE_UUID') // the treasury wallets of your organization
32
+ ```
33
+
34
+ Returns the wallets without their `history`:
35
+
36
+ | Field | Description |
37
+ |---|---|
38
+ | `uuid` | The wallet |
39
+ | `state` | `WalletState.CREATED` or `WalletState.FROZEN` |
40
+ | `type` | `WalletType.USER` for a customer, `WalletType.TREASURY` for your organization |
41
+ | `address` | The deposit address (or `null`) |
42
+ | `addressLegacy` | The same deposit address in the legacy format of the chain, for networks that have two address formats; `null` otherwise |
43
+ | `tag` | The memo / tag of the address, for the assets that use one (XRP, XLM…) — or `null` |
44
+ | `balance` | The exact quantity, as a string |
45
+ | `asset` | `AssetRef`: `{ uuid, iso, label }` ([Assets](../concepts.md#assets) — compare `iso` case-insensitively) |
46
+ | `history` | Only on `wallet`: the EUR value curve, a `History` ([Timestamps and histories](../concepts.md#timestamps-and-histories)) — `{}` on a new wallet until the curve has been computed |
47
+
48
+ ## Wallet
49
+
50
+ ```
51
+ client.custody.wallet(user: UserRef, asset: AssetInput): Promise<Wallet>
52
+ ```
53
+
54
+ | Parameter | Type | Description |
55
+ |---|---|---|
56
+ | `asset` | `AssetInput` | The asset, by uuid or ISO code (`Asset.ETH`) or by model ([Assets](../concepts.md#assets)) — never the uuid of the wallet |
57
+
58
+ ```ts
59
+ import { Asset } from '@bitgen/sdk'
60
+
61
+ const wallet = await client.custody.wallet('CUSTOMER_UUID', Asset.ETH)
62
+
63
+ // Show the customer where to send their ETH
64
+ console.log(wallet.address) // '0xabc…'
65
+ console.log(wallet.tag) // null — a memo / tag only for assets that need one
66
+ console.log(wallet.balance) // '0.5'
67
+ console.log(wallet.history?.d) // EUR value over the last 24 hours — only on this unit read
68
+ ```
69
+
70
+ When the customer has no wallet for this asset yet, the API **provisions** it: a deposit address is created at the custodian. The customer must be activated, not frozen (`403 account_frozen`), with a validated identity if your organization uses BITGEN's identity verification (`403 kyc_not_validated` — [Activation and identity](../concepts.md#activation-and-identity)) and no active compliance alert (`423 blocked_by_alert`). Returns the `Wallet` with its `history`.
71
+
72
+ ## Portfolio
73
+
74
+ ```
75
+ client.custody.portfolio(user: UserRef): Promise<CustodyPortfolio>
76
+ ```
77
+
78
+ ```ts
79
+ const portfolio = await client.custody.portfolio('CUSTOMER_UUID')
80
+
81
+ console.log(portfolio.history.m) // EUR value of the custody, one point per day over the last month
82
+ ```
83
+
84
+ Returns `{ uuid, type, history }` — `uuid` is the custody account of the customer, `type` is `WalletType.USER` (a customer) or `WalletType.TREASURY` (the organization) — or a flat `{ history }` at zero while the customer has no custody. Customers only: your organization's uuid is refused with `415 custody_portfolio_treasury_unsupported`.
85
+
86
+ ## Withdraw
87
+
88
+ ```
89
+ client.custody.withdraw(user: UserRef, params: CustodyWithdrawParams): Promise<{ transaction: string | null }>
90
+ ```
91
+
92
+ | Parameter | Type | Description |
93
+ |---|---|---|
94
+ | `params.asset` | `AssetInput` | The asset, by uuid or ISO code (`Asset.ETH`) or by model |
95
+ | `params.amount` | `Amount` | The quantity to send, as a string: more than 0, at most the decimals of the asset (`baseUnit`) — sent untouched; the EUR value of the quantity must reach a minimum — `416 withdraw_below_minimum` below it ([Amounts](../concepts.md#amounts)) |
96
+ | `params.targetAddress` | `string` | The destination address |
97
+ | `params.targetTag` | `string` | The destination memo / tag, for the assets that need one |
98
+ | `params.idempotencyKey` | `string` | Optional, 64 characters max, unique per customer: replaying the same key returns the same transaction |
99
+ | `params.travelRule` | `TravelRule` | Optional travel rule information on the destination: a person `{ firstname?, lastname?, address? }` **or** a platform `{ platform }` — one form or the other, 255 characters max per field |
100
+
101
+ ```ts
102
+ import { Asset } from '@bitgen/sdk'
103
+
104
+ const { transaction } = await client.custody.withdraw('CUSTOMER_UUID', {
105
+ asset: Asset.ETH,
106
+ amount: '0.05', // string: up to 18 decimals, sent as is — above the asset's minimum (see Errors)
107
+ targetAddress: '0xabc…',
108
+ idempotencyKey: 'withdraw-42',
109
+ travelRule: { platform: 'Kraken' }, // or { firstname: 'Jean', lastname: 'Valjean', address: '…' }
110
+ })
111
+
112
+ if (transaction !== null) {
113
+ const movement = await client.transaction.get(transaction) // follow it in the transaction journal
114
+ }
115
+ ```
116
+
117
+ Customers only: your organization's uuid is refused with `415 custody_treasury_withdraw_unsupported`. The EUR value of the withdrawal must reach the minimum (`416 withdraw_below_minimum` — [Amounts](../concepts.md#amounts)). Returns the uuid of the `Transaction` created for the withdrawal ([Transactions](transaction.md)) — `null` while the analysis has not created it yet.
118
+
119
+ ## Errors
120
+
121
+ In addition to the [common errors](../errors.md#common-errors):
122
+
123
+ | Status | `code` | Meaning |
124
+ |---|---|---|
125
+ | `400` | `invalid_amount` | The amount is not valid |
126
+ | `400` | `invalid_travel_rule` | `travelRule` mixes the two forms, or a field is too long |
127
+ | `403` | `org_forbidden` | The customer is not an activated member of your organization |
128
+ | `403` | `cross_org_forbidden` | The uuid belongs to another organization |
129
+ | `403` | `account_frozen` | The customer's account is frozen |
130
+ | `403` | `kyc_not_validated` | Your organization uses BITGEN's identity verification and the customer's identity is not validated ([Activation and identity](../concepts.md#activation-and-identity)) |
131
+ | `403` | `wallet_frozen` | The wallet is frozen |
132
+ | `403` | `user_actions_disabled` | Customer actions are disabled for your organization (`user_can_actions` flag) |
133
+ | `404` | `unknown_asset` | Unknown asset — the wallet uuid is not accepted |
134
+ | `404` | `unknown_organization` | The organization is unknown |
135
+ | `404` | `withdraw_organization_unresolved` | The organization of the withdrawal is unresolved |
136
+ | `409` | `duplicate_withdraw` | Duplicate withdrawal |
137
+ | `412` | `custody_not_enabled` | The `CUSTODY` connector of your organization is not enabled |
138
+ | `415` | `custody_portfolio_treasury_unsupported` | `portfolio` on your organization |
139
+ | `415` | `custody_treasury_withdraw_unsupported` | `withdraw` on your organization |
140
+ | `416` | `amount_precision_exceeded` | More decimals than the asset allows |
141
+ | `416` | `withdraw_below_minimum` | The EUR value of the quantity is below the minimum |
142
+ | `416` | `withdraw_price_unavailable` | No price is available to value the withdrawal |
143
+ | `416` | `requested_amount_error` | Insufficient balance |
144
+ | `416` | `custody_vault_insufficient` | The custody vault is insufficient |
145
+ | `416` | `withdraw_target_too_long` | `targetAddress` is too long |
146
+ | `422` | `withdraw_target_invalid` | `targetAddress` is not valid |
147
+ | `422` | `withdraw_target_tag_required` | The asset needs a `targetTag` |
148
+ | `422` | `withdraw_target_address_required` | `targetAddress` is missing |
149
+ | `422` | `invalid_idempotency_key` | `idempotencyKey` is not valid (64 characters max) |
150
+ | `422` | `asset_not_supported` | The custodian does not support this asset |
151
+ | `422` | `asset_address_unavailable` | No deposit address is available for this asset |
152
+ | `423` | `blocked_by_alert` | An active compliance alert blocks the customer |
153
+ | `423` | `custody_lock_unavailable` | The custody is locked by a concurrent operation |
154
+ | `503` | `custody_vault_unavailable` | The custodian's vault is unavailable |
155
+ | `503` | `custody_gas_unavailable` | Gas is unavailable at the custodian |
156
+ | `503` | `custody_address_unverifiable` | The destination address could not be verified |
157
+
158
+ ## Related
159
+
160
+ - [Assets](../concepts.md#assets) — uuid or ISO code, case
161
+ - [Amounts](../concepts.md#amounts) — crypto amounts as strings, minimums
162
+ - [Assets catalogue](asset.md) — the decimals (`baseUnit`) and state of each asset
163
+ - [Trading](trading.md) — sales take crypto from custody
164
+ - [Staking](staking.md) — staking moves crypto from custody to the provider
165
+ - [Transactions](transaction.md) — the journal where deposits and withdrawals appear
166
+ - [Webhooks](webhooks.md) — `custody.wallet.created`, `custody.received`, `custody.sent`, `custody.transaction`
@@ -0,0 +1,210 @@
1
+ # Customers
2
+
3
+ A customer is an end user of your organization on the BITGEN platform: a person (KYC) or a business (KYB) with a login, an identity file, settings and — once activated and verified — an EUR account, custody wallets, orders and staking positions. `client.customer` creates customers, lists them, and reads or updates an account.
4
+
5
+ Examples use `client`, a configured `BitgenClient` ([Configuration](../configuration.md)). A customer is designated by a `UserRef`: their uuid, or a model carrying it — the `Created` returned by `create`, a `Customer` of `list`, an `Account` of `get` ([User references](../concepts.md#user-references)).
6
+
7
+ ![Activation and identity: from the creation of a customer to the financial resources](../media/activation.svg)
8
+
9
+ ## Methods
10
+
11
+ | Method | What it does | Returns |
12
+ |---|---|---|
13
+ | `create(params)` | Creates a customer in your organization and sends them the activation email | `Created` |
14
+ | `list(params?)` | Lists the customers of your organization | `Page<Customer>` |
15
+ | `get(user)` | Reads one account: identity files, details, settings | `Account` |
16
+ | `update(user, params)` | Updates the settings a key may write: theme, locale, notifications | `void` |
17
+
18
+ TypeScript types of this resource, exported by the package: `KycIdentity`, `KybIdentity`, `Identity`, `CustomerAccount`, `CustomerClient`, `CustomerSetup`, `CollaboratorLink`, `ManagerLink`, `CustomerAlert`, `CustomerBusiness`, `Customer`, `AccountAddress`, `Account`, `CreateCustomerParams`, `CustomerListParams`, `UpdateCustomerParams` — the constants `Locale`, `CustomerState`, `IdentityState`, `IdentityMode`, `OrganizationCategory` (also types) — plus the shared `UserRef`, `Created`.
19
+
20
+ ## Create
21
+
22
+ ```
23
+ client.customer.create(params: CreateCustomerParams): Promise<Created>
24
+ ```
25
+
26
+ | Parameter | Type | Description |
27
+ |---|---|---|
28
+ | `params.account.email` | `string` | Login of the customer — required |
29
+ | `params.account.firstname` | `string` | Optional |
30
+ | `params.account.lastname` | `string` | Optional |
31
+ | `params.account.fin` | `string` | Tax identification number of the customer — optional, 100 characters max |
32
+ | `params.account.needActivation` | `boolean` | Default `true`: BITGEN emails the customer an activation link and the account stays `CustomerState.CREATED` (the bank, custody, trading and staking resources refuse it) until they activate. `false`: the account is usable right away and BITGEN sends no email — for an organization that handles activation and notifications with its own system, or through webhooks |
33
+ | `params.account.notify` | `boolean` | Default `true`: the customer receives BITGEN's emails (newsletter). `false`: none |
34
+ | `params.group.manager` | `string` | uuid of the collaborator of your organization who follows this customer — required; the customer is created in your organization |
35
+ | `params.locale` | `Locale` | `Locale.FR` (default) or `Locale.EN` |
36
+ | `params.organization` | `OrganizationCategory` | Category: `OrganizationCategory.CUSTOMER` (default) or `OrganizationCategory.B2B` — `B2B` also opens a KYB file |
37
+
38
+ ```ts
39
+ import { Locale, OrganizationCategory } from '@bitgen/sdk'
40
+
41
+ const created = await client.customer.create({
42
+ account: { email: 'jean@valjean.fr', firstname: 'Jean', lastname: 'Valjean' },
43
+ group: { manager: 'MANAGER_UUID' },
44
+ locale: Locale.FR,
45
+ organization: OrganizationCategory.B2B, // a business: a KYB file is opened too — CUSTOMER by default
46
+ })
47
+
48
+ const account = await client.customer.get(created) // a `Created` is a `UserRef`
49
+ ```
50
+
51
+ Returns a `Created` — the uuid of the customer, a `UserRef` for every other method. By default the API creates the account and sends the customer an activation email. Until they click it, the account stays `CustomerState.CREATED` (`setup.needActivation` is `true`) and the bank, custody, trading and staking resources do not accept it — only `list`, where it appears as `CREATED`, and `get` see it ([Activation and identity](../concepts.md#activation-and-identity)).
52
+
53
+ ```ts
54
+ const { uuid } = await client.customer.create({
55
+ account: { email: 'jean@valjean.fr', needActivation: false, notify: false }, // you handle onboarding yourself
56
+ group: { manager: 'MANAGER_UUID' },
57
+ })
58
+ ```
59
+
60
+ With `needActivation: false` the account is usable right away and BITGEN sends no activation email — for an organization that handles activation and notifications with its own system, or through webhooks ([Webhooks](webhooks.md)); with `notify: false` the customer receives no BITGEN email at all.
61
+
62
+ When the email already belongs to an active account whose KYC is validated, that account is **attached** to your organization instead of being created. An active account without a validated KYC cannot be attached (`412 user_not_attachable`), an account already attached to another organization is refused (`409 user_already_assigned`), and so is an account still being created, for 15 minutes (`409 account_unavailable`).
63
+
64
+ ## List
65
+
66
+ ```
67
+ client.customer.list(params?: CustomerListParams): Promise<Page<Customer>>
68
+ ```
69
+
70
+ | Parameter | Type | Description |
71
+ |---|---|---|
72
+ | `params.offset`, `params.limit` | `number` | [Pagination](../concepts.md#pagination) |
73
+ | `params.includeClosed` | `boolean` | Also returns the `CustomerState.CLOSED` customers — default `false` ([Query booleans](../concepts.md#query-booleans)) |
74
+ | `params.manager` | `string` | Only the customers whose direct manager is this collaborator (uuid) |
75
+
76
+ ```ts
77
+ import { CustomerState } from '@bitgen/sdk'
78
+
79
+ const { count, items } = await client.customer.list({ offset: 0, limit: 50 })
80
+
81
+ for (const customer of items) {
82
+ console.log(customer.login, customer.state === CustomerState.ENABLED) // 'jean@valjean.fr' true
83
+ }
84
+ ```
85
+
86
+ Returns a page of `Customer`:
87
+
88
+ | Field | Description |
89
+ |---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
90
+ | `uuid`, `createdAt` | Identifier and creation time (epoch seconds) |
91
+ | `state` | `CustomerState.CREATED` (activation pending), `ENABLED`, `CLOSED` or `FROZEN` |
92
+ | `isAvailable` | `false` until the customer has activated their account, then `true` |
93
+ | `canLogin` | Whether the customer may sign in to the BITGEN web application |
94
+ | `login` | The email |
95
+ | `account` | `email`, `firstname`, `lastname`, `fin` (tax identification number), `birthdate` (date of birth, epoch seconds, or `null`), `phoneZone` and `phoneNumber` (dialing code, `+33` by default, and the number as an integer), `address` (`{ uuid, state, address }` or `null` — `state` is the state of the address record), `referralCode` (the customer's own referral code, generated at creation) |
96
+ | `client` | `roles` (platform roles of the account — always `ROLE_USER` for a customer), `hasTfa` (two-factor authentication enabled), `hasPhishing` (anti-phishing code enabled), `isValid` (`true` once the account has been activated) |
97
+ | `action.setup` | `theme` (theme of the BITGEN web application, `light` by default), `currency` (display currency, `EUR`), `locale` (language of the web application and of the emails, `Locale.FR` or `Locale.EN`), `choosenOrganization` (category chosen at signup: `OrganizationCategory.CUSTOMER`, `B2B` — a string, compare it with the constants), `needActivation` (activation email pending), `notify` (whether the customer accepts BITGEN emails), `onboarding` (whether the web onboarding has been completed) |
98
+ | `identity` | The KYC or KYB file of the customer ([Identity](#identity)) |
99
+ | `business` | The businesses of the customer, each with its KYB file: `{ identity }[]` |
100
+ | `collaborations.collaborator` | The customer's attachment to your organization: `uuid`, `state` (`WAIT` until activation, then `ENABLED`; `REVOKED` once removed), `roles` (`ROLE_USER` for a customer), `organization` (its name), `organizationUuid`, `manager` (uuid of the collaborator in charge of them) |
101
+ | `collaborations.manager` | Attachments where this account manages other people — always empty for a customer (`mandate`, `mandatedUntil`: CRM data, not needed for an integration) |
102
+ | `alert` | Active compliance alerts: `uuid`, `state` (`OPEN`, `DECLARATED`, `CONFIRMED`), `severity` (`SUCCESS`, `WARNING`, `CRITICAL`), `sources` (the observations behind the alert — analysis data) |
103
+
104
+ ## Get
105
+
106
+ ```
107
+ client.customer.get(user: UserRef): Promise<Account>
108
+ ```
109
+
110
+ `user` is the customer, by uuid or model.
111
+
112
+ ```ts
113
+ import { IdentityState } from '@bitgen/sdk'
114
+
115
+ const account = await client.customer.get('CUSTOMER_UUID')
116
+
117
+ console.log(account.setup.needActivation) // true until the activation email is clicked
118
+ console.log(account.identity.state === IdentityState.VALIDATED) // true once the verification is done
119
+ ```
120
+
121
+ Returns an `Account`:
122
+
123
+ | Field | Description |
124
+ |---|---|
125
+ | `uuid` | The customer |
126
+ | `identity` | The KYC or KYB file of the customer ([Identity](#identity)) |
127
+ | `business` | The businesses of the customer, each with its KYB file: `{ identity }[]` |
128
+ | `account` | The same fields as `Customer.account`, with `address` reduced to `{ uuid, address }` (or `null`) |
129
+ | `notifications` | Email preferences: `login` (login-related emails), `newsletter` (BITGEN newsletter) |
130
+ | `setup` | The same fields as `Customer.action.setup`: theme, display currency, language, category chosen at signup, activation pending, BITGEN emails accepted, onboarding completed |
131
+
132
+ An unknown customer answers `404 unknown_user`.
133
+
134
+ ### Identity
135
+
136
+ `Identity` is the verification file of a person (`mode` `IdentityMode.KYC`) or of a business (`IdentityMode.KYB`). The verification itself — questionnaire, documents — is not part of this SDK: read its progress here. Whether a validated identity is required before the financial resources depends on your organization ([Activation and identity](../concepts.md#activation-and-identity)).
137
+
138
+ | Field | Description |
139
+ |---|---|
140
+ | `uuid` | The file |
141
+ | `state` | `IdentityState.CREATED`, `IN_PROGRESS`, `WAIT`, `PENDING`, `VALIDATED`, `REJECTED`, `FROZEN`, `EXPIRED` or `CLOSED` |
142
+ | `mode` | `IdentityMode.KYC` or `IdentityMode.KYB` |
143
+ | `form` | KYC — the answers of the KYC questionnaire: `european_residency` (boolean), `ppe` (politically exposed person, boolean), `ppp` (relative of a politically exposed person, boolean), `source_income`, `net_income`, `experience` (crypto experience); plus `score` (internal scoring) and `submittedAt` — KYB: `activity` (business activity), `score`, `submittedAt` |
144
+ | `data.steps` | One entry per step, `{ status, submittedAt }` — KYC: `info`, `selfie`, `identity`, `residency`; KYB: `info`, `kbis`, `status`, `domiciliation`, `rbe` |
145
+ | `data.verificationUrl` | URL of the identity verification when the provider hosts it, `null` otherwise |
146
+ | `data.hosted` | Whether the verification is hosted by the provider |
147
+ | `data.notifications` | Internal flag |
148
+ | `validatedAt`, `expiresAt` | Epoch seconds, or `null` |
149
+ | `renewalNotifiedAt` | When the renewal reminder was sent (epoch seconds, or `null`) — an identity expires after 12 months (6 for a politically exposed person) |
150
+
151
+ In TypeScript, `Identity` is the union `KycIdentity | KybIdentity`, discriminated on `mode`: narrow on it to type `form`.
152
+
153
+ ```ts
154
+ import { IdentityMode } from '@bitgen/sdk'
155
+
156
+ const { identity } = await client.customer.get('CUSTOMER_UUID')
157
+
158
+ if (identity.mode === IdentityMode.KYC) {
159
+ console.log(identity.form.source_income) // KycIdentity
160
+ } else {
161
+ console.log(identity.form.activity) // KybIdentity
162
+ }
163
+ ```
164
+
165
+ ## Update
166
+
167
+ ```
168
+ client.customer.update(user: UserRef, params: UpdateCustomerParams): Promise<void>
169
+ ```
170
+
171
+ `user` is the customer, by uuid or model.
172
+
173
+ | Parameter | Type | Description |
174
+ |---|---|---|
175
+ | `params.theme` | `string` | Theme of the BITGEN web application (`light` by default) |
176
+ | `params.locale` | `Locale` | Language of the web application and of the emails: `Locale.FR` or `Locale.EN` |
177
+ | `params.notifications` | `{ login?: boolean, newsletter?: boolean }` | Email preferences: `login` (login-related emails), `newsletter` (BITGEN newsletter) |
178
+
179
+ ```ts
180
+ import { Locale } from '@bitgen/sdk'
181
+
182
+ await client.customer.update('CUSTOMER_UUID', {
183
+ locale: Locale.EN,
184
+ notifications: { login: true, newsletter: false },
185
+ })
186
+ ```
187
+
188
+ These are the only settings an API key may write — the account details, the identity state and the address are not — and the SDK sends nothing else. The API answers with an empty body: the promise resolves with `undefined`.
189
+
190
+ ## Errors
191
+
192
+ In addition to the [common errors](../errors.md#common-errors):
193
+
194
+ | Status | `code` | Meaning |
195
+ |---|---|---|
196
+ | `400` | `invalid_fin` | `account.fin` (tax identification number) is longer than 100 characters, or not a scalar |
197
+ | `403` | `missing_group_organization_or_manager` | `group.manager` is missing |
198
+ | `404` | `unknown_user` | Unknown customer (`get`), or unknown `manager` (`list`) |
199
+ | `409` | `user_already_assigned` | The email belongs to an account attached to another organization |
200
+ | `409` | `account_unavailable` | The email belongs to an account still being created (less than 15 minutes ago) |
201
+ | `412` | `user_not_attachable` | The email belongs to an active account without a validated KYC |
202
+ | `422` | `invalid_include_closed` | `includeClosed` is not a boolean value |
203
+
204
+ ## Related
205
+
206
+ - [User references](../concepts.md#user-references) — uuid or model (`Created`, `Customer`, `Account`…)
207
+ - [Activation and identity](../concepts.md#activation-and-identity) — what a customer can do before and after activation, and when a validated identity is required
208
+ - [Bank accounts](bank.md) — the EUR account of a customer
209
+ - [Custody wallets](custody.md) — their crypto wallets
210
+ - [Webhooks](webhooks.md) — `user.created` and the `user.identity.*` events