openapi.yaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. openapi: 3.0.1
  2. info:
  3. title: SFTPGo
  4. description: 'SFTPGo REST API'
  5. version: 1.2.0
  6. servers:
  7. - url: /api/v1
  8. paths:
  9. /version:
  10. get:
  11. tags:
  12. - version
  13. summary: Get version details
  14. operationId: get_version
  15. responses:
  16. 200:
  17. description: successful operation
  18. content:
  19. application/json:
  20. schema:
  21. type: array
  22. items:
  23. $ref : '#/components/schemas/VersionInfo'
  24. /providerstatus:
  25. get:
  26. tags:
  27. - providerstatus
  28. summary: Get data provider status
  29. operationId: get_provider_status
  30. responses:
  31. 200:
  32. description: successful operation
  33. content:
  34. application/json:
  35. schema:
  36. $ref: '#/components/schemas/ApiResponse'
  37. example:
  38. status: 200
  39. message: "Alive"
  40. error: ""
  41. 500:
  42. description: Provider Error
  43. content:
  44. application/json:
  45. schema:
  46. $ref: '#/components/schemas/ApiResponse'
  47. example:
  48. status: 500
  49. message: ""
  50. error: "Error description if any"
  51. /connection:
  52. get:
  53. tags:
  54. - connections
  55. summary: Get the active users and info about their uploads/downloads
  56. operationId: get_connections
  57. responses:
  58. 200:
  59. description: successful operation
  60. content:
  61. application/json:
  62. schema:
  63. type: array
  64. items:
  65. $ref : '#/components/schemas/ConnectionStatus'
  66. /connection/{connectionID}:
  67. delete:
  68. tags:
  69. - connections
  70. summary: Terminate an active connection
  71. operationId: close_connection
  72. parameters:
  73. - name: connectionID
  74. in: path
  75. description: ID of the connection to close
  76. required: true
  77. schema:
  78. type: string
  79. responses:
  80. 200:
  81. description: successful operation
  82. content:
  83. application/json:
  84. schema:
  85. $ref: '#/components/schemas/ApiResponse'
  86. example:
  87. status: 200
  88. message: "Connection closed"
  89. error: ""
  90. 400:
  91. description: Bad request
  92. content:
  93. application/json:
  94. schema:
  95. $ref: '#/components/schemas/ApiResponse'
  96. example:
  97. status: 400
  98. message: ""
  99. error: "Error description if any"
  100. 404:
  101. description: Not Found
  102. content:
  103. application/json:
  104. schema:
  105. $ref: '#/components/schemas/ApiResponse'
  106. example:
  107. status: 404
  108. message: ""
  109. error: "Error description if any"
  110. 500:
  111. description: Internal Server Error
  112. content:
  113. application/json:
  114. schema:
  115. $ref: '#/components/schemas/ApiResponse'
  116. example:
  117. status: 500
  118. message: ""
  119. error: "Error description if any"
  120. /quota_scan:
  121. get:
  122. tags:
  123. - quota
  124. summary: Get the active quota scans
  125. operationId: get_quota_scans
  126. responses:
  127. 200:
  128. description: successful operation
  129. content:
  130. application/json:
  131. schema:
  132. type: array
  133. items:
  134. $ref : '#/components/schemas/QuotaScan'
  135. post:
  136. tags:
  137. - quota
  138. summary: start a new quota scan
  139. description: A quota scan update the number of files and their total size for the given user
  140. operationId: start_quota_scan
  141. requestBody:
  142. required: true
  143. content:
  144. application/json:
  145. schema:
  146. $ref : '#/components/schemas/User'
  147. responses:
  148. 201:
  149. description: successful operation
  150. content:
  151. application/json:
  152. schema:
  153. $ref: '#/components/schemas/ApiResponse'
  154. example:
  155. status: 201
  156. message: "Scan started"
  157. error: ""
  158. 400:
  159. description: Bad request
  160. content:
  161. application/json:
  162. schema:
  163. $ref: '#/components/schemas/ApiResponse'
  164. example:
  165. status: 400
  166. message: ""
  167. error: "Error description if any"
  168. 403:
  169. description: Forbidden
  170. content:
  171. application/json:
  172. schema:
  173. $ref: '#/components/schemas/ApiResponse'
  174. example:
  175. status: 403
  176. message: ""
  177. error: "Error description if any"
  178. 404:
  179. description: Not Found
  180. content:
  181. application/json:
  182. schema:
  183. $ref: '#/components/schemas/ApiResponse'
  184. example:
  185. status: 404
  186. message: ""
  187. error: "Error description if any"
  188. 409:
  189. description: Another scan is already in progress for this user
  190. content:
  191. application/json:
  192. schema:
  193. $ref: '#/components/schemas/ApiResponse'
  194. example:
  195. status: 409
  196. message: "Another scan is already in progress"
  197. error: "Error description if any"
  198. 500:
  199. description: Internal Server Error
  200. content:
  201. application/json:
  202. schema:
  203. $ref: '#/components/schemas/ApiResponse'
  204. example:
  205. status: 500
  206. message: ""
  207. error: "Error description if any"
  208. /user:
  209. get:
  210. tags:
  211. - users
  212. summary: Returns an array with one or more users
  213. description: For security reasons hashed passwords are omitted in the response
  214. operationId: get_users
  215. parameters:
  216. - in: query
  217. name: offset
  218. schema:
  219. type: integer
  220. minimum: 0
  221. default: 0
  222. required: false
  223. - in: query
  224. name: limit
  225. schema:
  226. type: integer
  227. minimum: 1
  228. maximum: 500
  229. default: 100
  230. required: false
  231. description: The maximum number of items to return. Max value is 500, default is 100
  232. - in: query
  233. name: order
  234. required: false
  235. description: Ordering users by username
  236. schema:
  237. type: string
  238. enum:
  239. - ASC
  240. - DESC
  241. example: ASC
  242. - in: query
  243. name: username
  244. required: false
  245. description: Filter by username, extact match case sensitive
  246. schema:
  247. type: string
  248. responses:
  249. 200:
  250. description: successful operation
  251. content:
  252. application/json:
  253. schema:
  254. type: array
  255. items:
  256. $ref : '#/components/schemas/User'
  257. 400:
  258. description: Bad request
  259. content:
  260. application/json:
  261. schema:
  262. $ref: '#/components/schemas/ApiResponse'
  263. example:
  264. status: 400
  265. message: ""
  266. error: "Error description if any"
  267. 403:
  268. description: Forbidden
  269. content:
  270. application/json:
  271. schema:
  272. $ref: '#/components/schemas/ApiResponse'
  273. example:
  274. status: 403
  275. message: ""
  276. error: "Error description if any"
  277. 500:
  278. description: Internal Server Error
  279. content:
  280. application/json:
  281. schema:
  282. $ref: '#/components/schemas/ApiResponse'
  283. example:
  284. status: 500
  285. message: ""
  286. error: "Error description if any"
  287. post:
  288. tags:
  289. - users
  290. summary: Adds a new SFTP/SCP user
  291. operationId: add_user
  292. requestBody:
  293. required: true
  294. content:
  295. application/json:
  296. schema:
  297. $ref : '#/components/schemas/User'
  298. responses:
  299. 200:
  300. description: successful operation
  301. content:
  302. application/json:
  303. schema:
  304. $ref : '#/components/schemas/User'
  305. 400:
  306. description: Bad request
  307. content:
  308. application/json:
  309. schema:
  310. $ref: '#/components/schemas/ApiResponse'
  311. example:
  312. status: 400
  313. message: ""
  314. error: "Error description if any"
  315. 403:
  316. description: Forbidden
  317. content:
  318. application/json:
  319. schema:
  320. $ref: '#/components/schemas/ApiResponse'
  321. example:
  322. status: 403
  323. message: ""
  324. error: "Error description if any"
  325. 500:
  326. description: Internal Server Error
  327. content:
  328. application/json:
  329. schema:
  330. $ref: '#/components/schemas/ApiResponse'
  331. example:
  332. status: 500
  333. message: ""
  334. error: "Error description if any"
  335. /user/{userID}:
  336. get:
  337. tags:
  338. - users
  339. summary: Find user by ID
  340. description: For security reasons the hashed password is omitted in the response
  341. operationId: get_user_by_id
  342. parameters:
  343. - name: userID
  344. in: path
  345. description: ID of the user to retrieve
  346. required: true
  347. schema:
  348. type: integer
  349. format: int32
  350. responses:
  351. 200:
  352. description: successful operation
  353. content:
  354. application/json:
  355. schema:
  356. $ref : '#/components/schemas/User'
  357. 400:
  358. description: Bad request
  359. content:
  360. application/json:
  361. schema:
  362. $ref: '#/components/schemas/ApiResponse'
  363. example:
  364. status: 400
  365. message: ""
  366. error: "Error description if any"
  367. 403:
  368. description: Forbidden
  369. content:
  370. application/json:
  371. schema:
  372. $ref: '#/components/schemas/ApiResponse'
  373. example:
  374. status: 403
  375. message: ""
  376. error: "Error description if any"
  377. 404:
  378. description: Not Found
  379. content:
  380. application/json:
  381. schema:
  382. $ref: '#/components/schemas/ApiResponse'
  383. example:
  384. status: 404
  385. message: ""
  386. error: "Error description if any"
  387. 500:
  388. description: Internal Server Error
  389. content:
  390. application/json:
  391. schema:
  392. $ref: '#/components/schemas/ApiResponse'
  393. example:
  394. status: 500
  395. message: ""
  396. error: "Error description if any"
  397. put:
  398. tags:
  399. - users
  400. summary: Update an existing user
  401. operationId: update_user
  402. parameters:
  403. - name: userID
  404. in: path
  405. description: ID of the user to update
  406. required: true
  407. schema:
  408. type: integer
  409. format: int32
  410. requestBody:
  411. required: true
  412. content:
  413. application/json:
  414. schema:
  415. $ref : '#/components/schemas/User'
  416. responses:
  417. 200:
  418. description: successful operation
  419. content:
  420. application/json:
  421. schema:
  422. $ref : '#/components/schemas/ApiResponse'
  423. example:
  424. status: 200
  425. message: "User updated"
  426. error: ""
  427. 400:
  428. description: Bad request
  429. content:
  430. application/json:
  431. schema:
  432. $ref: '#/components/schemas/ApiResponse'
  433. example:
  434. status: 400
  435. message: ""
  436. error: "Error description if any"
  437. 403:
  438. description: Forbidden
  439. content:
  440. application/json:
  441. schema:
  442. $ref: '#/components/schemas/ApiResponse'
  443. example:
  444. status: 403
  445. message: ""
  446. error: "Error description if any"
  447. 404:
  448. description: Not Found
  449. content:
  450. application/json:
  451. schema:
  452. $ref: '#/components/schemas/ApiResponse'
  453. example:
  454. status: 404
  455. message: ""
  456. error: "Error description if any"
  457. 500:
  458. description: Internal Server Error
  459. content:
  460. application/json:
  461. schema:
  462. $ref: '#/components/schemas/ApiResponse'
  463. example:
  464. status: 500
  465. message: ""
  466. error: "Error description if any"
  467. delete:
  468. tags:
  469. - users
  470. summary: Delete an existing user
  471. operationId: delete_user
  472. parameters:
  473. - name: userID
  474. in: path
  475. description: ID of the user to delete
  476. required: true
  477. schema:
  478. type: integer
  479. format: int32
  480. responses:
  481. 200:
  482. description: successful operation
  483. content:
  484. application/json:
  485. schema:
  486. $ref : '#/components/schemas/ApiResponse'
  487. example:
  488. status: 200
  489. message: "User deleted"
  490. error: ""
  491. 400:
  492. description: Bad request
  493. content:
  494. application/json:
  495. schema:
  496. $ref: '#/components/schemas/ApiResponse'
  497. example:
  498. status: 400
  499. message: ""
  500. error: "Error description if any"
  501. 403:
  502. description: Forbidden
  503. content:
  504. application/json:
  505. schema:
  506. $ref: '#/components/schemas/ApiResponse'
  507. example:
  508. status: 403
  509. message: ""
  510. error: "Error description if any"
  511. 404:
  512. description: Not Found
  513. content:
  514. application/json:
  515. schema:
  516. $ref: '#/components/schemas/ApiResponse'
  517. example:
  518. status: 404
  519. message: ""
  520. error: "Error description if any"
  521. 500:
  522. description: Internal Server Error
  523. content:
  524. application/json:
  525. schema:
  526. $ref: '#/components/schemas/ApiResponse'
  527. example:
  528. status: 500
  529. message: ""
  530. error: "Error description if any"
  531. components:
  532. schemas:
  533. Permission:
  534. type: string
  535. enum:
  536. - '*'
  537. - list
  538. - download
  539. - upload
  540. - overwrite
  541. - delete
  542. - rename
  543. - create_dirs
  544. - create_symlinks
  545. - chmod
  546. - chown
  547. description: >
  548. Permissions:
  549. * `*` - all permissions are granted
  550. * `list` - list items is allowed
  551. * `download` - download files is allowed
  552. * `upload` - upload files is allowed
  553. * `overwrite` - overwrite an existing file, while uploading, is allowed. upload permission is required to allow file overwrite
  554. * `delete` - delete files or directories is allowed
  555. * `rename` - rename files or directories is allowed
  556. * `create_dirs` - create directories is allowed
  557. * `create_symlinks` - create links is allowed
  558. * `chmod` changing file or directory permissions is allowed
  559. * `chown` changing file or directory owner and group is allowed
  560. User:
  561. type: object
  562. properties:
  563. id:
  564. type: integer
  565. format: int32
  566. minimum: 1
  567. status:
  568. type: integer
  569. enum:
  570. - 0
  571. - 1
  572. description: >
  573. status:
  574. * `0` user is disabled, login is not allowed
  575. * `1` user is enabled
  576. username:
  577. type: string
  578. expiration_date:
  579. type: integer
  580. format: int64
  581. description: expiration date as unix timestamp in milliseconds. An expired account cannot login. 0 means no expiration
  582. password:
  583. type: string
  584. nullable: true
  585. description: password or public key are mandatory. If the password has no known hashing algo prefix it will be stored using argon2id. You can send a password hashed as bcrypt or pbkdf2 and it will be stored as is. For security reasons this field is omitted when you search/get users
  586. public_keys:
  587. type: array
  588. items:
  589. type: string
  590. nullable: true
  591. description: a password or at least one public key are mandatory.
  592. home_dir:
  593. type: string
  594. description: path to the user home directory. The user cannot upload or download files outside this directory. SFTPGo tries to automatically create this folder if missing. Must be an absolute path
  595. uid:
  596. type: integer
  597. format: int32
  598. minimum: 0
  599. maximum: 65535
  600. description: if you run sftpgo as root user the created files and directories will be assigned to this uid. 0 means no change, the owner will be the user that runs sftpgo. Ignored on windows
  601. gid:
  602. type: integer
  603. format: int32
  604. minimum: 0
  605. maximum: 65535
  606. description: if you run sftpgo as root user the created files and directories will be assigned to this gid. 0 means no change, the group will be the one of the user that runs sftpgo. Ignored on windows
  607. max_sessions:
  608. type: integer
  609. format: int32
  610. description: limit the sessions that an user can open. 0 means unlimited
  611. quota_size:
  612. type: integer
  613. format: int64
  614. description: quota as size in bytes. 0 menas unlimited. Please note that quota is updated if files are added/removed via SFTP/SCP otherwise a quota scan is needed
  615. quota_files:
  616. type: integer
  617. format: int32
  618. description: quota as number of files. 0 menas unlimited. Please note that quota is updated if files are added/removed via SFTP/SCP otherwise a quota scan is needed
  619. permissions:
  620. type: array
  621. items:
  622. $ref: '#/components/schemas/Permission'
  623. minItems: 1
  624. used_quota_size:
  625. type: integer
  626. format: int64
  627. used_quota_file:
  628. type: integer
  629. format: int32
  630. last_quota_update:
  631. type: integer
  632. format: int64
  633. description: last quota update as unix timestamp in milliseconds
  634. upload_bandwidth:
  635. type: integer
  636. format: int32
  637. description: Maximum upload bandwidth as KB/s, 0 means unlimited
  638. download_bandwidth:
  639. type: integer
  640. format: int32
  641. description: Maximum download bandwidth as KB/s, 0 means unlimited
  642. last_login:
  643. type: integer
  644. format: int64
  645. description: last user login as unix timestamp in milliseconds
  646. Transfer:
  647. type: object
  648. properties:
  649. operation_type:
  650. type: string
  651. enum:
  652. - upload
  653. - download
  654. path:
  655. type: string
  656. description: SFTP/SCP file path for the upload/download
  657. start_time:
  658. type: integer
  659. format: int64
  660. description: start time as unix timestamp in milliseconds
  661. size:
  662. type: integer
  663. format: int64
  664. description: bytes transferred
  665. last_activity:
  666. type: integer
  667. format: int64
  668. description: last transfer activity as unix timestamp in milliseconds
  669. ConnectionStatus:
  670. type: object
  671. properties:
  672. username:
  673. type: string
  674. description: connected username
  675. connection_id:
  676. type: string
  677. description: unique connection identifier
  678. client_version:
  679. type: string
  680. description: SFTP/SCP client version
  681. remote_address:
  682. type: string
  683. description: Remote address for the connected SFTP/SCP client
  684. connection_time:
  685. type: integer
  686. format: int64
  687. description: connection time as unix timestamp in milliseconds
  688. last_activity:
  689. type: integer
  690. format: int64
  691. description: last client activity as unix timestamp in milliseconds
  692. protocol:
  693. type: string
  694. enum:
  695. - SFTP
  696. - SCP
  697. active_transfers:
  698. type: array
  699. items:
  700. $ref : '#/components/schemas/Transfer'
  701. QuotaScan:
  702. type: object
  703. properties:
  704. username:
  705. type: string
  706. description: username with an active scan
  707. start_time:
  708. type: integer
  709. format: int64
  710. description: scan start time as unix timestamp in milliseconds
  711. ApiResponse:
  712. type: object
  713. properties:
  714. status:
  715. type: integer
  716. format: int32
  717. minimum: 200
  718. maximum: 500
  719. example: 200
  720. description: HTTP Status code, for example 200 OK, 400 Bad request and so on
  721. message:
  722. type: string
  723. nullable: true
  724. description: additional message if any
  725. error:
  726. type: string
  727. nullable: true
  728. description: error description if any
  729. VersionInfo:
  730. type: object
  731. properties:
  732. version:
  733. type: string
  734. build_date:
  735. type: string
  736. commit_hash:
  737. type: string