openapi.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. openapi: 3.0.0
  2. info:
  3. title: BYOM Core API
  4. version: '1.0'
  5. description: API for managing BYOM Core services
  6. contact:
  7. name: BYOM Support
  8. servers:
  9. - url: /api/v1/core
  10. description: BYOM Core API
  11. components:
  12. securitySchemes:
  13. BearerAuth:
  14. type: http
  15. scheme: bearer
  16. bearerFormat: JWT
  17. schemas:
  18. Error:
  19. type: object
  20. properties:
  21. error:
  22. type: string
  23. example: "Error message description"
  24. Message:
  25. type: object
  26. properties:
  27. message:
  28. type: string
  29. example: "Success message description"
  30. User:
  31. type: object
  32. properties:
  33. id:
  34. type: string
  35. format: uuid
  36. email:
  37. type: string
  38. format: email
  39. name:
  40. type: string
  41. phone_number:
  42. type: string
  43. role:
  44. type: string
  45. enum: [owner, admin, member]
  46. status:
  47. type: string
  48. enum: [active, pending, inactive]
  49. created_at:
  50. type: string
  51. format: date-time
  52. updated_at:
  53. type: string
  54. format: date-time
  55. Workspace:
  56. type: object
  57. properties:
  58. id:
  59. type: string
  60. format: uuid
  61. name:
  62. type: string
  63. created_at:
  64. type: string
  65. format: date-time
  66. updated_at:
  67. type: string
  68. format: date-time
  69. Profile:
  70. type: object
  71. properties:
  72. id:
  73. type: string
  74. format: uuid
  75. name:
  76. type: string
  77. workspace_id:
  78. type: string
  79. format: uuid
  80. Invite:
  81. type: object
  82. properties:
  83. id:
  84. type: string
  85. format: uuid
  86. email:
  87. type: string
  88. format: email
  89. workspace_id:
  90. type: string
  91. format: uuid
  92. role:
  93. type: string
  94. enum: [owner, admin, member]
  95. status:
  96. type: string
  97. enum: [pending, accepted, expired, cancelled]
  98. expires_at:
  99. type: string
  100. format: date-time
  101. created_at:
  102. type: string
  103. format: date-time
  104. paths:
  105. /health:
  106. get:
  107. summary: Health check endpoint
  108. responses:
  109. '200':
  110. description: Service is healthy
  111. content:
  112. application/json:
  113. schema:
  114. type: object
  115. properties:
  116. status:
  117. type: string
  118. example: "ok"
  119. /auth/login:
  120. post:
  121. summary: Authenticate user
  122. requestBody:
  123. required: true
  124. content:
  125. application/json:
  126. schema:
  127. type: object
  128. required:
  129. - email
  130. - password
  131. properties:
  132. email:
  133. type: string
  134. format: email
  135. password:
  136. type: string
  137. format: password
  138. responses:
  139. '200':
  140. description: Login successful
  141. content:
  142. application/json:
  143. schema:
  144. type: object
  145. properties:
  146. token:
  147. type: string
  148. user:
  149. $ref: '#/components/schemas/User'
  150. '400':
  151. description: Invalid credentials
  152. content:
  153. application/json:
  154. schema:
  155. $ref: '#/components/schemas/Error'
  156. /users/current:
  157. get:
  158. summary: Get current user information
  159. security:
  160. - BearerAuth: []
  161. responses:
  162. '200':
  163. description: Current user information
  164. content:
  165. application/json:
  166. schema:
  167. type: object
  168. properties:
  169. user:
  170. $ref: '#/components/schemas/User'
  171. workspaces:
  172. type: array
  173. items:
  174. $ref: '#/components/schemas/Workspace'
  175. put:
  176. summary: Update current user
  177. security:
  178. - BearerAuth: []
  179. requestBody:
  180. required: true
  181. content:
  182. application/json:
  183. schema:
  184. type: object
  185. required:
  186. - name
  187. properties:
  188. name:
  189. type: string
  190. phone_number:
  191. type: string
  192. responses:
  193. '200':
  194. description: User updated successfully
  195. content:
  196. application/json:
  197. schema:
  198. type: object
  199. properties:
  200. user:
  201. $ref: '#/components/schemas/User'
  202. /workspaces:
  203. post:
  204. summary: Create new workspace
  205. security:
  206. - BearerAuth: []
  207. requestBody:
  208. required: true
  209. content:
  210. application/json:
  211. schema:
  212. type: object
  213. required:
  214. - name
  215. properties:
  216. name:
  217. type: string
  218. responses:
  219. '201':
  220. description: Workspace created
  221. content:
  222. application/json:
  223. schema:
  224. $ref: '#/components/schemas/Workspace'
  225. /workspaces/owners/init:
  226. post:
  227. summary: Initialize workspace owner
  228. description: First step of workspace owner creation - creates a pending owner account
  229. requestBody:
  230. required: true
  231. content:
  232. application/json:
  233. schema:
  234. type: object
  235. required:
  236. - email
  237. - name
  238. properties:
  239. email:
  240. type: string
  241. format: email
  242. name:
  243. type: string
  244. phone_number:
  245. type: string
  246. responses:
  247. '201':
  248. description: Workspace owner initialized
  249. content:
  250. application/json:
  251. schema:
  252. type: object
  253. properties:
  254. user:
  255. $ref: '#/components/schemas/User'
  256. '400':
  257. description: Invalid request
  258. content:
  259. application/json:
  260. schema:
  261. $ref: '#/components/schemas/Error'
  262. '409':
  263. description: User already exists
  264. content:
  265. application/json:
  266. schema:
  267. $ref: '#/components/schemas/Error'
  268. /workspaces/owners:
  269. put:
  270. summary: Complete workspace owner creation
  271. description: Second step of workspace owner creation - sets password and activates the account
  272. requestBody:
  273. required: true
  274. content:
  275. application/json:
  276. schema:
  277. type: object
  278. required:
  279. - email
  280. - name
  281. - password
  282. properties:
  283. email:
  284. type: string
  285. format: email
  286. name:
  287. type: string
  288. phone_number:
  289. type: string
  290. password:
  291. type: string
  292. format: password
  293. responses:
  294. '201':
  295. description: Workspace owner created
  296. content:
  297. application/json:
  298. schema:
  299. type: object
  300. properties:
  301. user:
  302. $ref: '#/components/schemas/User'
  303. '400':
  304. description: Invalid request
  305. content:
  306. application/json:
  307. schema:
  308. $ref: '#/components/schemas/Error'
  309. '404':
  310. description: Pending owner not found
  311. content:
  312. application/json:
  313. schema:
  314. $ref: '#/components/schemas/Error'
  315. '409':
  316. description: Email does not match pending owner
  317. content:
  318. application/json:
  319. schema:
  320. $ref: '#/components/schemas/Error'
  321. /workspaces/{id}/members:
  322. post:
  323. summary: Add member to workspace
  324. security:
  325. - BearerAuth: []
  326. parameters:
  327. - name: id
  328. in: path
  329. required: true
  330. schema:
  331. type: string
  332. format: uuid
  333. requestBody:
  334. required: true
  335. content:
  336. application/json:
  337. schema:
  338. type: object
  339. required:
  340. - role
  341. properties:
  342. role:
  343. type: string
  344. enum: [admin, member]
  345. responses:
  346. '200':
  347. description: Member added successfully
  348. content:
  349. application/json:
  350. schema:
  351. $ref: '#/components/schemas/Message'
  352. /profiles:
  353. get:
  354. summary: List profiles
  355. security:
  356. - BearerAuth: []
  357. responses:
  358. '200':
  359. description: List of profiles
  360. content:
  361. application/json:
  362. schema:
  363. type: object
  364. properties:
  365. profiles:
  366. type: array
  367. items:
  368. $ref: '#/components/schemas/Profile'
  369. post:
  370. summary: Create new profile
  371. security:
  372. - BearerAuth: []
  373. requestBody:
  374. required: true
  375. content:
  376. application/json:
  377. schema:
  378. type: object
  379. required:
  380. - name
  381. - workspace_id
  382. properties:
  383. name:
  384. type: string
  385. workspace_id:
  386. type: string
  387. format: uuid
  388. responses:
  389. '201':
  390. description: Profile created
  391. content:
  392. application/json:
  393. schema:
  394. type: object
  395. properties:
  396. profile:
  397. $ref: '#/components/schemas/Profile'
  398. /profiles/{id}:
  399. parameters:
  400. - name: id
  401. in: path
  402. required: true
  403. schema:
  404. type: string
  405. format: uuid
  406. get:
  407. summary: Get profile by ID
  408. security:
  409. - BearerAuth: []
  410. responses:
  411. '200':
  412. description: Profile details
  413. content:
  414. application/json:
  415. schema:
  416. type: object
  417. properties:
  418. profile:
  419. $ref: '#/components/schemas/Profile'
  420. put:
  421. summary: Update profile
  422. security:
  423. - BearerAuth: []
  424. requestBody:
  425. required: true
  426. content:
  427. application/json:
  428. schema:
  429. type: object
  430. required:
  431. - name
  432. properties:
  433. name:
  434. type: string
  435. responses:
  436. '200':
  437. description: Profile updated
  438. content:
  439. application/json:
  440. schema:
  441. type: object
  442. properties:
  443. profile:
  444. $ref: '#/components/schemas/Profile'
  445. delete:
  446. summary: Delete profile
  447. security:
  448. - BearerAuth: []
  449. responses:
  450. '200':
  451. description: Profile deleted
  452. content:
  453. application/json:
  454. schema:
  455. $ref: '#/components/schemas/Message'
  456. /invitations:
  457. post:
  458. summary: Create invitation
  459. security:
  460. - BearerAuth: []
  461. requestBody:
  462. required: true
  463. content:
  464. application/json:
  465. schema:
  466. type: object
  467. required:
  468. - email
  469. - workspace_id
  470. - role
  471. properties:
  472. email:
  473. type: string
  474. format: email
  475. workspace_id:
  476. type: string
  477. format: uuid
  478. role:
  479. type: string
  480. enum: [admin, member]
  481. responses:
  482. '201':
  483. description: Invitation created
  484. content:
  485. application/json:
  486. schema:
  487. $ref: '#/components/schemas/Invite'
  488. /invitations/accept:
  489. post:
  490. summary: Accept invitation
  491. requestBody:
  492. required: true
  493. content:
  494. application/json:
  495. schema:
  496. type: object
  497. required:
  498. - email
  499. - name
  500. - password
  501. - token
  502. properties:
  503. email:
  504. type: string
  505. format: email
  506. name:
  507. type: string
  508. phone_number:
  509. type: string
  510. password:
  511. type: string
  512. format: password
  513. token:
  514. type: string
  515. responses:
  516. '201':
  517. description: Invitation accepted
  518. content:
  519. application/json:
  520. schema:
  521. type: object
  522. properties:
  523. user:
  524. $ref: '#/components/schemas/User'
  525. workspace_id:
  526. type: string
  527. format: uuid
  528. /invitations/validate:
  529. get:
  530. summary: Validate invitation token
  531. parameters:
  532. - name: token
  533. in: query
  534. required: true
  535. schema:
  536. type: string
  537. responses:
  538. '200':
  539. description: Token validation result
  540. content:
  541. application/json:
  542. schema:
  543. type: object
  544. properties:
  545. valid:
  546. type: boolean
  547. workspace_id:
  548. type: string
  549. format: uuid
  550. email:
  551. type: string
  552. format: email