@@ -1564,6 +1564,216 @@ paths:
15641564 application/json :
15651565 schema :
15661566 $ref : ' #/components/schemas/ErrorResponse'
1567+ /api/auth/2fa/setup :
1568+ post :
1569+ summary : Initiate TOTP 2FA setup
1570+ description : |
1571+ Generates a TOTP secret for the authenticated user and returns an `otpauth://` URI
1572+ for QR-code rendering. 2FA is NOT yet active — the user must call
1573+ `POST /api/auth/2fa/verify` with a valid code to enable it.
1574+ tags :
1575+ - Auth
1576+ security :
1577+ - bearerAuth : []
1578+ responses :
1579+ ' 200 ' :
1580+ description : 2FA setup initiated
1581+ content :
1582+ application/json :
1583+ schema :
1584+ type : object
1585+ properties :
1586+ success :
1587+ type : boolean
1588+ message :
1589+ type : string
1590+ data :
1591+ type : object
1592+ properties :
1593+ otpauthUrl :
1594+ type : string
1595+ description : otpauth:// URI to encode as QR code
1596+ secret :
1597+ type : string
1598+ description : Raw TOTP secret for manual entry
1599+ ' 401 ' :
1600+ description : Missing or invalid auth token
1601+ content :
1602+ application/json :
1603+ schema :
1604+ $ref : ' #/components/schemas/ErrorResponse'
1605+ ' 409 ' :
1606+ description : 2FA is already enabled
1607+ content :
1608+ application/json :
1609+ schema :
1610+ $ref : ' #/components/schemas/ErrorResponse'
1611+ /api/auth/2fa/verify :
1612+ post :
1613+ summary : Verify first TOTP code and enable 2FA
1614+ description : |
1615+ Validates the first TOTP code after setup. On success, enables 2FA and returns
1616+ 10 single-use backup codes (plaintext, shown exactly once — store them safely).
1617+ tags :
1618+ - Auth
1619+ security :
1620+ - bearerAuth : []
1621+ requestBody :
1622+ required : true
1623+ content :
1624+ application/json :
1625+ schema :
1626+ type : object
1627+ required :
1628+ - code
1629+ properties :
1630+ code :
1631+ type : string
1632+ pattern : ' ^\d{6}$'
1633+ description : 6-digit TOTP code from the authenticator app
1634+ responses :
1635+ ' 200 ' :
1636+ description : 2FA enabled successfully
1637+ content :
1638+ application/json :
1639+ schema :
1640+ type : object
1641+ properties :
1642+ success :
1643+ type : boolean
1644+ message :
1645+ type : string
1646+ data :
1647+ type : object
1648+ properties :
1649+ backupCodes :
1650+ type : array
1651+ items :
1652+ type : string
1653+ description : 10 single-use backup codes (shown once only)
1654+ ' 400 ' :
1655+ description : Invalid or wrong TOTP code, or setup not initiated
1656+ content :
1657+ application/json :
1658+ schema :
1659+ $ref : ' #/components/schemas/ErrorResponse'
1660+ ' 401 ' :
1661+ description : Missing or invalid auth token
1662+ content :
1663+ application/json :
1664+ schema :
1665+ $ref : ' #/components/schemas/ErrorResponse'
1666+ ' 409 ' :
1667+ description : 2FA already enabled
1668+ content :
1669+ application/json :
1670+ schema :
1671+ $ref : ' #/components/schemas/ErrorResponse'
1672+ ' 429 ' :
1673+ description : Too many verification attempts (rate-limited)
1674+ content :
1675+ application/json :
1676+ schema :
1677+ type : object
1678+ properties :
1679+ success :
1680+ type : boolean
1681+ message :
1682+ type : string
1683+ retryAfter :
1684+ type : integer
1685+ data :
1686+ nullable : true
1687+ /api/auth/2fa :
1688+ delete :
1689+ summary : Disable 2FA
1690+ description : |
1691+ Disables 2FA on the account after verifying the user's current password.
1692+ Clears the TOTP secret and all backup codes.
1693+ tags :
1694+ - Auth
1695+ security :
1696+ - bearerAuth : []
1697+ requestBody :
1698+ required : true
1699+ content :
1700+ application/json :
1701+ schema :
1702+ type : object
1703+ required :
1704+ - password
1705+ properties :
1706+ password :
1707+ type : string
1708+ description : Current account password
1709+ responses :
1710+ ' 200 ' :
1711+ description : 2FA disabled successfully
1712+ content :
1713+ application/json :
1714+ schema :
1715+ type : object
1716+ properties :
1717+ success :
1718+ type : boolean
1719+ message :
1720+ type : string
1721+ data :
1722+ nullable : true
1723+ ' 400 ' :
1724+ description : 2FA is not enabled on this account
1725+ content :
1726+ application/json :
1727+ schema :
1728+ $ref : ' #/components/schemas/ErrorResponse'
1729+ ' 401 ' :
1730+ description : Incorrect password or missing/invalid auth token
1731+ content :
1732+ application/json :
1733+ schema :
1734+ $ref : ' #/components/schemas/ErrorResponse'
1735+ /api/auth/2fa/backup-codes/regenerate :
1736+ post :
1737+ summary : Regenerate backup codes
1738+ description : |
1739+ Invalidates all existing backup codes and issues 10 new single-use codes.
1740+ Requires 2FA to be enabled.
1741+ tags :
1742+ - Auth
1743+ security :
1744+ - bearerAuth : []
1745+ responses :
1746+ ' 200 ' :
1747+ description : New backup codes generated
1748+ content :
1749+ application/json :
1750+ schema :
1751+ type : object
1752+ properties :
1753+ success :
1754+ type : boolean
1755+ message :
1756+ type : string
1757+ data :
1758+ type : object
1759+ properties :
1760+ backupCodes :
1761+ type : array
1762+ items :
1763+ type : string
1764+ description : 10 new single-use backup codes (shown once only)
1765+ ' 400 ' :
1766+ description : 2FA is not enabled on this account
1767+ content :
1768+ application/json :
1769+ schema :
1770+ $ref : ' #/components/schemas/ErrorResponse'
1771+ ' 401 ' :
1772+ description : Missing or invalid auth token
1773+ content :
1774+ application/json :
1775+ schema :
1776+ $ref : ' #/components/schemas/ErrorResponse'
15671777 /api/auth/api-keys/{organizationId} :
15681778 get :
15691779 summary : List API keys for an organization
0 commit comments