-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2fauth-api-latest.yaml
More file actions
3796 lines (3762 loc) · 128 KB
/
2fauth-api-latest.yaml
File metadata and controls
3796 lines (3762 loc) · 128 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.1.0
info:
title: 2FAuth API
version: 1.10.0
description: |-
This is the definition (following OpenAPI 3.1 specification) of the REST API of [2FAuth](https://github.com/Bubka/2FAuth), a web app to manage your Two-Factor Authentication (2FA) accounts and generate their security passwords.
The API is available once you installed 2FAuth on your server.
contact:
name: Bubka
url: 'https://github.com/Bubka'
email: contact@2fauth.app
license:
name: AGPL-3.0
url: 'https://www.gnu.org/licenses/agpl-3.0.en.html'
servers:
- url: 'https://demo.2fauth.app'
description: Demo server
paths:
/api/v1/twofaccounts:
get:
summary: Get all 2FA accounts
tags:
- twofaccounts
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountCollection'
examples:
Example without secret:
value:
- id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
period: 30
counter: null
- id: 2
group_id: 1
service: MyOtherSite
account: john.doe
icon: 1pawLLuMx4bOQkrZxM5CIQyFtVq25dtgMkU3rtST.png
otp_type: hotp
digits: 8
algorithm: sha1
period: null
counter: 15
Example with secret:
value:
- id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
secret: GJTGC5LUNA
period: 30
counter: null
- id: 2
group_id: 1
service: MyOtherSite
account: john.doe
icon: 1pawLLuMx4bOQkrZxM5CIQyFtVq25dtgMkU3rtST.png
otp_type: hotp
digits: 8
algorithm: sha1
secret: QD5TG6UUJ89F44GV
period: null
counter: 15
Example with otp object:
value:
- id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
period: 30
counter: null
otp:
password: '045698'
next_password: '255745'
generated_at: 1701788671
- id: 2
group_id: 1
service: MyOtherSite
account: john.doe
icon: 1pawLLuMx4bOQkrZxM5CIQyFtVq25dtgMkU3rtST.png
otp_type: hotp
digits: 8
algorithm: sha1
period: null
counter: 15
Example with account shared with me:
value:
- id: 25
group_id: 8
service: AnotherSite
account: jane.doe
icon: p0TmC8xswemEgQe3YRT8g0ohBxT7hHpvp0TmC8xswe.png
otp_type: totp
digits: 6
algorithm: sha1
period: 30
counter: null
is_borrowed: true
shared_by: Jane
- id: 2
group_id: 1
service: MyOtherSite
account: john.doe
icon: 1pawLLuMx4bOQkrZxM5CIQyFtVq25dtgMkU3rtST.png
otp_type: hotp
digits: 8
algorithm: sha1
period: null
counter: 15
Example with account I share:
value:
- id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
secret: GJTGC5LUNA
period: 30
counter: null
is_shared: true
is_shared_with_all: true
- id: 2
group_id: 1
service: MyOtherSite
account: john.doe
icon: 1pawLLuMx4bOQkrZxM5CIQyFtVq25dtgMkU3rtST.png
otp_type: hotp
digits: 8
algorithm: sha1
secret: QD5TG6UUJ89F44GV
period: null
counter: 15
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
operationId: get-twofaccounts
description: |-
Find all 2FA accounts.
The returned accounts can be either those owned by the authenticated user or accounts shared with him (when sharing is enabled).
Specific properties are presents in the response payload depending on the context (see available examples bellow):
- The `secret` property is present when `withSecret` query param is set to `true`.
- The `otp` array is present when `withOtp` query param is set to `true`.
- The `is_borrowed` and `shared_by` properties are presents when the account is shared with the authenticated user (the Sharing feature must be globally enabled).
- The `is_shared` and `is_shared_with_all` properties are presents when the account is shared by the authenticated user (the Sharing feature must be globally enabled).
parameters:
- $ref: '#/components/parameters/withSecret'
- schema:
type: string
example: '1,20,9,456'
in: query
name: ids
description: Comma-separated list of IDs used to filter 2FA accounts returned in the response
- $ref: '#/components/parameters/withOtp'
parameters: []
post:
summary: Create 2FA account
tags:
- twofaccounts
operationId: post-twofaccounts
description: Creates a new 2FA account for the authenticated user.
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/2FAccountStore'
- $ref: '#/components/schemas/OtpauthUri'
examples:
Example with properties:
value:
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
secret: GJTGC5LUNA
period: 30
counter: null
Example with URI:
value:
uri: 'otpauth://totp/MySite:john.doe?secret=GJTGC5LUNA&issuer=MySite&period=30&algorithm=sha1&digits=6&image=https://www.example.com/image.png'
description: |-
This endpoint accepts 2 different body schemas to create a new 2FA account:
- A full JSON object with some properties
- An URI based on the otpauth format
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountRead'
examples:
Example:
value:
id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
secret: GJTGC5LUNA
digits: 6
algorithm: sha1
period: 30
counter: null
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/ValidationError'
parameters: []
delete:
summary: Mass delete 2FA accounts
operationId: delete-twofaccounts
responses:
'204':
description: No Content
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/ValidationError'
tags:
- twofaccounts
description: |-
Mass deletes 2FA accounts of the authenticated user matching the IDs passed as query parameter.
A `204 — No Content` response will be returned even if some resources no longer exist before delete.
parameters:
- $ref: '#/components/parameters/ids'
'/api/v1/twofaccounts/{id}':
parameters:
- $ref: '#/components/parameters/id'
get:
summary: Find 2FA account by ID
tags:
- twofaccounts
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountRead'
examples:
Example without secret:
value:
id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
period: 30
counter: null
Example with secret:
value:
id: 1
group_id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
secret: GJTGC5LUNA
digits: 6
algorithm: sha1
period: 30
counter: null
Example for account shared with me:
value:
id: 1
service: MySite
account: jane.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
secret: VHIGC5PLKM
digits: 6
algorithm: sha1
period: 30
counter: null
group_id: 5
is_borrowed: true
shared_by: Jane
Example for account shared by me:
value:
id: 1
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
secret: GJTGC5LUNA
digits: 6
algorithm: sha1
period: 30
counter: null
group_id: 1
is_shared: true
is_shared_with_all: true
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
operationId: get-twofaccounts-id
description: |-
Returns a single 2FA account.
The returned account can be an account owned by the authenticated user or an account shared with him (when Sharing is enabled).
Specific properties are presents in the response payload depending on the context (see available examples bellow):
- The `secret` property is present when `withSecret` query param is set to `true`.
- The `otp` array is present when `withOtp` query param is set to `true`.
- The `is_borrowed` and `shared_by` properties are presents when the account is shared with the authenticated user (the Sharing feature must be globally enabled).
- The `is_shared` and `is_shared_with_all` properties are presents when the account is shared by the authenticated user (the Sharing feature must be globally enabled).
parameters:
- $ref: '#/components/parameters/withSecret'
- $ref: '#/components/parameters/withOtp'
put:
summary: Update 2FA account
operationId: put-twofaccounts-id
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountRead'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/ValidationError'
description: Updates a 2FA account of the authenticated user.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountUpdate'
examples:
Example:
value:
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
digits: 6
algorithm: sha1
secret: GJTGC5LUNA
period: 30
tags:
- twofaccounts
delete:
summary: Delete 2FA account
operationId: delete-twofaccounts-id
responses:
'204':
description: No Content
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
tags:
- twofaccounts
description: Deletes a 2FA account of the authenticated user.
'/api/v1/twofaccounts/{id}/otp':
parameters:
- $ref: '#/components/parameters/id'
get:
summary: Get a One-Time password
tags:
- one-time password
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Otp'
examples:
Example for TOTP:
value:
password: '225897'
otp_type: totp
generated_at: 1631304659
period: 30
Example for HOTP:
value:
password: '225897'
otp_type: hotp
counter: 5
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
operationId: get-twofaccounts-id-otp
description: |-
Returns a fresh One-Time Password for the 2FA account matching the specified ID.
The account can be an account owned by the authenticated user or an account shared with him (when Sharing is enabled).
'/api/v1/twofaccounts/{id}/owner':
patch:
summary: Transfer ownership
operationId: patch-twofaccounts-id-owner
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
twofaccount_id:
type: integer
x-stoplight:
id: 2ryavv4mib7o8
minimum: 1
description: ID of the patched 2FA account
owner_id:
type: integer
x-stoplight:
id: 0kndoov4k1f1q
minimum: 1
description: User ID of the new owner
required:
- twofaccount_id
- owner_id
examples:
Example:
value:
twofaccount_id: 1
owner_id: 1
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/ValidationError'
description: |-
Transfers the ownership of a 2FA account to another user of the 2FAuth instance.
> #### Important
> This endpoint can only be used if the app setting `enableSharing` is enabled. It will return a `403 Forbidden` response otherwise.
parameters: []
tags:
- twofaccounts
requestBody:
content:
application/json:
schema:
type: object
properties:
new_owner_id:
type: integer
x-stoplight:
id: ic99lni10sedl
minimum: 1
description: ID of the new owner
example: 5
confirm_password:
type: string
x-stoplight:
id: bgbmfb55n5udm
description: Password of the authenticated user that make the request
example: P4s$w0rD
required:
- new_owner_id
- confirm_password
examples:
Example:
value:
new_owner_id: 5
confirm_password: P4s$w0rD
description: ''
parameters:
- $ref: '#/components/parameters/id'
'/api/v1/twofaccounts/{id}/qrcode':
parameters:
- $ref: '#/components/parameters/id'
get:
summary: Encode a 2FA account in a QR code
tags:
- qrcode
responses:
'200':
description: OK
content:
application/json:
schema:
description: ''
type: object
x-examples:
example-1:
qrcode: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASgAAAEoCAIAAABkZftOAAAABnRSTlMA/wD/AP83WBt9AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGFUlEQVR4nO3dsbJbJxRA0SiT//9lp7BbipOBbHhaq37WlWTtoTgDfH79+vUX8P/6u34D8I2EBwHhQUB4EBAeBIQHAeFBQHgQEB4EhAcB4UFAeBAQHgSEBwHhQeCf6T/4fD4n3sd2p/cZVt/D6nNN38/0+zn9+rueW5l+XiseBIQHAeFBQHgQEB4EhAcB4UFgPMdbqc7n3DXneWUOtnqd09//rvnhrvf/+u/NigcB4UFAeBAQHgSEBwHhQUB4ENg2x1vZNfeo5lRTp+dst+0zvG3e+MrvzYoHAeFBQHgQEB4EhAcB4UFAeBA4Pse7TTVfOm3X/G3XvruVn/r9T1nxICA8CAgPAsKDgPAgIDwICA8CXzfHWzl93mO1T2/13Oq+O36z4kFAeBAQHgSEBwHhQUB4EB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1+nuidw5bb5pBUPAsKDgPAgIDwICA8CwoOA8CCQzfFWpvOZ6lzH284XvW0f2ulzR18553PFigcB4UFAeBAQHgSEBwHhQUB4EDg+xzs9b7ltXnR6v99tc61XzkedPnf699P/dyseBIQHAeFBQHgQEB4EhAcB4UHgc/r+salX5mDOh/xvbtsvV32fVjwICA8CwoOA8CAgPAgIDwLCg8B4P95tc6TT87TqHr9dTs8JT++rnKr2H9qPBw8QHgSEBwHhQUB4EBAeBIQHgfEc77b9VCvV3Oynzjmnr1+dt7nL6eda8SAgPAgIDwLCg4DwICA8CAgPAtvux3tlv9lp0/nPdA52et/gyvT1d833dv2uqvsDV6x4EBAeBIQHAeFBQHgQEB4EhAeBbXO8ldvOXazmZivVeZ675lrVXHEX9+PBFxEeBIQHAeFBQHgQEB4EhAeB43O8b7Nr39rKK3Ozan5bzWOnrHgQEB4EhAcB4UFAeBAQHgSEBwFzvD9O76/bZbqP7vR5mNUccuq2/ZNWPAgIDwLCg4DwICA8CAgPAsKDwPE5XrXfaeW2edT0dV7/+9vmkNPX2fV7tuJBQHgQEB4EhAcB4UFAeBAQHgS2zfGq+8122fX+d821dj13qno/1bz39FxxxYoHAeFBQHgQEB4EhAcB4UFAeBD43LZfDr6BFQ8CwoOA8CAgPAgIDwLCg4DwICA8CAgPAsKDgPAgIDwICA8CwoOA8CDwLzF4/0kW8W0CAAAAAElFTkSuQmCC'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
operationId: get-twofaccounts-id-qrcode
description: Returns a QR code that represents a 2FA account owned by the authenticated user.
'/api/v1/twofaccounts/{id}/recipients':
parameters:
- $ref: '#/components/parameters/id'
get:
summary: Get users with whom to share a 2FA account
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/2FAccountShareRecipient'
x-stoplight:
id: 95aw8enerpwau
examples:
Example:
value:
- id: 1
name: John DOE
is_shared_with: true
is_shared_since: 'Thu, May 2, 2024 6:32 AM'
- id: 1
name: Jane DOE
is_shared_with: false
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
operationId: get-twofaccounts-id-recipients
description: |-
Find users who can be set as recipients for a new 2FA account sharing.
This endpoint only returns something if:
- the user email address matches the query parameter value exactly
- the username matches the query parameter value partially.
parameters:
- schema:
type: string
example: '?filter[name]=do'
in: query
name: 'filter[nameOrEmail]'
description: String used to retrieve user by name or by email
required: true
tags:
- twofaccounts
- sharing
'/api/v1/twofaccounts/{id}/shares':
parameters:
- $ref: '#/components/parameters/id'
get:
summary: Get sharing details
tags:
- twofaccounts
- sharing
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountShares'
examples:
Example for account shared with all users:
value:
twofaccount_id: 1
is_shared_with_all: true
Example for account shared with specific users:
value:
twofaccount_id: 1
is_shared_with_all: false
specific_users:
- id: 2
name: John DOE
is_shared_with: true
is_shared_since: 'Thu, May 2, 2025 6:32 AM'
- id: 3
name: Jane DOE
is_shared_with: true
is_shared_since: 'Thu, May 3, 2026 3:54 AM'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
operationId: get-twofaccounts-id-shares
description: Find all sharings for a 2FA account owned by the authenticated user.
post:
summary: Share a 2FA account
operationId: post-twofaccounts-id-shares
responses:
'200':
description: Received when the 2FA account was already shared with each provided user.
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountShares'
examples:
Example:
value:
twofaccount_id: 1
is_shared_with_all: false
specific_users:
- id: 2
name: John DOE
is_shared_with: true
is_shared_since: 'Thu, May 2, 2025 6:32 AM'
- id: 3
name: Jane DOE
is_shared_with: true
is_shared_since: 'Thu, May 3, 2026 3:54 AM'
'201':
description: Received when the 2FA account was not already shared with at least one of the provided users.
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountShares'
examples:
Example:
value:
twofaccount_id: 1
is_shared_with_all: false
specific_users:
- id: 2
name: John DOE
is_shared_with: true
is_shared_since: 'Thu, May 2, 2025 6:32 AM'
- id: 3
name: Jane DOE
is_shared_with: true
is_shared_since: 'Thu, May 3, 2026 3:54 AM'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'422':
$ref: '#/components/responses/ValidationError'
requestBody:
content:
application/json:
schema:
type: object
properties:
user_ids:
x-stoplight:
id: u9iipzmarg1lm
type: array
description: List of user IDs with whom the 2FA account must be shared
minItems: 1
items:
x-stoplight:
id: l4q842uaszaxv
type: integer
required:
- user_ids
examples:
Example:
value:
user_ids:
- 2
- 3
description: ''
description: |-
Shares a 2FA account owned by the authenticated user with specific users of the 2FAuth instance. This endpoint creates new shares for given users with whom the 2FA account is not already shared.
> The user list provided in the request body is not the comprehensive list of users with whom the 2FA account must be shared.
You can't share an account with specific users if the account has already been shared with all users. You will receive a `409 Conflict` response.
tags:
- twofaccounts
- sharing
delete:
summary: Stop sharing a 2FA account
operationId: delete-twofaccounts-id-shares
responses:
'204':
description: No Content
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
description: 'Revokes any sharing of a 2FA account owned by the authenticated user, whether it''s shared with all users (`All users` scope) or specific users.'
tags:
- twofaccounts
- sharing
'/api/v1/twofaccounts/{id}/shares/all':
parameters:
- $ref: '#/components/parameters/id'
post:
summary: Share a 2FA account with all users
operationId: post-twofaccounts-id-shares-all
responses:
'200':
description: Received when the 2FA account was already shared with all user.
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountShares'
examples:
Example:
value:
twofaccount_id: 1
is_shared_with_all: true
'201':
description: Received when the 2FA account was not already shared with all users.
content:
application/json:
schema:
$ref: '#/components/schemas/2FAccountShares'
examples:
Example:
value:
twofaccount_id: 1
is_shared_with_all: true
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
requestBody:
content: {}
description: ''
description: |-
Shares a 2FA account owned by the authenticated user with all current and future users of the 2FAuth instance, aka the `All users` scope.
Any specific user shares will be canceled.
tags:
- twofaccounts
- sharing
'/api/v1/twofaccounts/{id}/shares/{userid}':
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/userid'
delete:
summary: Stop sharing a 2FA account with a specific user
operationId: delete-twofaccounts-id-shares-userid
responses:
'204':
description: No Content
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
description: |-
Revokes a specific user share of a 2FA account owned by the authenticated user.
You can't stop sharing an account with specific user if the account is currently shared with all users (`All users` scope). You will receive a `409 Conflict` response.
tags:
- twofaccounts
- sharing
/api/v1/twofaccounts/otp:
parameters: []
post:
summary: Get a One-Time password
tags:
- one-time password
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/2FAccountStore'
- $ref: '#/components/schemas/OtpauthUri'
examples: {}
description: |-
This endpoint accepts 2 different body schemas to generate a One-Time Password:
- A JSON object with all properties to define a 2FA account
- An otpauth URI
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Otp'
examples:
Eexample for TOTP:
value:
password: '225897'
otp_type: totp
generated_at: 1631304659
period: 30
Example for HOTP:
value:
password: '225897'
otp_type: hotp
counter: 5
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/ValidationError'
operationId: post-twofaccounts-otp
description: Returns a fresh One-Time password with related parameters for account defined by the provided data
/api/v1/twofaccounts/migration:
post:
summary: Convert a migration resource
operationId: post-twofaccounts-migration
responses:
'200':
description: |-
Ok
> 2FA accounts are always returned with an ID between -2 and 0:
> - `id: -2` means the returned account does not reflect the exact submited data because those data are invalid or unreadable. You should not used this account definition.
> - `id: -1` means the returned account already exists in the authenticated user accounts in database. It's a valid account but probably useless you should discard.
> - `id: 0` means the returned account is successfully migrated and is valid
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/2FAccountMigrated'
examples:
Example:
value:
- id: 0
group_id: null
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
secret: GJTGC5LUNA
digits: 6
algorithm: sha1
period: 30
counter: null
- id: -1
group_id: null
service: MySite
account: john.doe
icon: ZMlzmrPsrWSWVt4fZouFVrt2w38D0PnXiyZQvDcY.png
otp_type: totp
secret: GJTGC5LUNA
digits: 6
algorithm: sha1
period: 30
counter: null
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/ValidationError'
'500':
$ref: '#/components/responses/ServerError'
description: |-
Use this endpoint to convert exported 2FAs from another 2FA app to a list of 2FA resources you can POST using the API to create new 2FA accounts.
> This endpoint does not store anything in database.
requestBody:
content:
application/json:
schema:
type: object
properties:
payload:
type: string
description: The migration payload
required:
- payload
examples:
Example for Google Authenticator:
value:
payload: 'otpauth-migration://offline?data=w0SnrWITY/RFhILYWNjb3VudF9iaXMaC3NlcnZpY2VfYmlzIAEoATACEAEYASAA'
withSecret: true
Example for a list of otpauth URIs:
value:
payload: |-
otpauth://totp/dropbox:john?secret=T5THFHVVRSDF4AWS
otpauth://totp/dropbox:jane?secret=A4GRFHVVRBGY7UIW
withSecret: true
Example for a JSON payload:
value:
payload: |-
{
"version":1,
"header":{
"slots":null,
"params":null
},
"db":{
"version":2,
"entries":[
{
"type":"totp",
"uuid":"5be1c189-240d-5fe1-930b-a78xb669zd86",
"name":"JohnDOE",
"issuer":"Facebook",
"note":"",
"icon":null,
"info":{
"secret":"A4GRFTVVRBGY7UIW",
"algo":"SHA1",
"digits":6,
"period":30,
"counter":30
}
}
]
}
}
withSecret: true
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
description: The migration file
required:
- file
examples:
Example:
value:
file: string
description: |-
This endpoint accepts 2 different body schemas:
- A JSON object which contain a migration payload. Typically the content of an export file or the decoded content of a QR code.
- A multi-part/form-data to submit an export file directly
tags:
- twofaccounts
parameters:
- $ref: '#/components/parameters/withSecret'
parameters: []
/api/v1/twofaccounts/preview:
post: