openapi: 3.1.0 info: title: Docwell API version: 0.0.1 license: name: AGPL-3.0-or-later identifier: AGPL-3.0-or-later description: | Public API of docwell-server. This file is the source of truth: the Go handlers and the TypeScript and Dart clients are generated from it. servers: - url: http://localhost:8080 paths: /healthz: get: operationId: getHealth summary: Liveness probe responses: "200": description: Server process is up content: application/json: schema: { $ref: "#/components/schemas/Status" } /readyz: get: operationId: getReadiness summary: Readiness probe (checks the database) responses: "200": description: Ready content: application/json: schema: { $ref: "#/components/schemas/Status" } "503": description: A dependency is unavailable content: application/json: schema: { $ref: "#/components/schemas/Status" } /api/v1/version: get: operationId: getVersion summary: Server name and version responses: "200": description: OK content: application/json: schema: { $ref: "#/components/schemas/Version" } /api/v1/auth/methods: get: operationId: getAuthMethods tags: [auth] summary: Enabled sign-in methods responses: "200": description: OK content: application/json: schema: { $ref: "#/components/schemas/AuthMethods" } /api/v1/auth/signup: post: operationId: signup tags: [auth] summary: Create an account and sign in (the first account becomes the instance admin) requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/SignupRequest" } responses: "200": { $ref: "#/components/responses/Session" } "400": { $ref: "#/components/responses/Error" } "403": { $ref: "#/components/responses/Error" } /api/v1/auth/login: post: operationId: login tags: [auth] summary: Sign in with email and password description: Returns 401 with error "mfa_required" and an mfaId when a second factor is needed. requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/LoginRequest" } responses: "200": { $ref: "#/components/responses/Session" } "401": { $ref: "#/components/responses/Error" } /api/v1/auth/otp/request: post: operationId: requestOtp tags: [auth] summary: Email a one-time sign-in code requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/EmailRequest" } responses: "200": description: OK content: application/json: schema: type: object required: [otpId] properties: otpId: { type: string } /api/v1/auth/otp/login: post: operationId: loginWithOtp tags: [auth] summary: Sign in with an emailed one-time code requestBody: required: true content: application/json: schema: type: object required: [otpId, code] properties: otpId: { type: string } code: { type: string } mfaId: { type: string } responses: "200": { $ref: "#/components/responses/Session" } "401": { $ref: "#/components/responses/Error" } /api/v1/auth/refresh: post: operationId: refreshSession tags: [auth] summary: Exchange a valid token for a new one security: [{ bearer: [] }] responses: "200": { $ref: "#/components/responses/Session" } "401": { $ref: "#/components/responses/Error" } /api/v1/auth/me: get: operationId: getMe tags: [auth] summary: The signed-in user security: [{ bearer: [] }] responses: "200": description: OK content: application/json: schema: { $ref: "#/components/schemas/User" } "401": { $ref: "#/components/responses/Error" } /api/v1/auth/password-reset/request: post: operationId: requestPasswordReset tags: [auth] summary: Email a password reset link (succeeds for unknown emails too) requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/EmailRequest" } responses: "204": { description: Sent } /api/v1/auth/password-reset/confirm: post: operationId: confirmPasswordReset tags: [auth] summary: Set a new password with the emailed token requestBody: required: true content: application/json: schema: type: object required: [token, password] properties: token: { type: string } password: { type: string, minLength: 8 } responses: "204": { description: Password changed } "400": { $ref: "#/components/responses/Error" } /api/v1/auth/verification/request: post: operationId: requestVerification tags: [auth] summary: Email an address verification link requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/EmailRequest" } responses: "204": { description: Sent } /api/v1/auth/verification/confirm: post: operationId: confirmVerification tags: [auth] summary: Confirm an email address with the emailed token requestBody: required: true content: application/json: schema: type: object required: [token] properties: token: { type: string } responses: "204": { description: Verified } "400": { $ref: "#/components/responses/Error" } /api/v1/admin/users: get: operationId: listUsers tags: [admin] summary: List accounts (instance admins only) security: [{ bearer: [] }] parameters: - { name: page, in: query, schema: { type: integer, minimum: 1 } } - { name: perPage, in: query, schema: { type: integer, minimum: 1, maximum: 200 } } - { name: q, in: query, description: Search in email and name, schema: { type: string } } responses: "200": description: OK content: application/json: schema: { $ref: "#/components/schemas/UserList" } "401": { $ref: "#/components/responses/Error" } "403": { $ref: "#/components/responses/Error" } components: securitySchemes: bearer: type: http scheme: bearer description: PocketBase auth token returned by login, signup and refresh. responses: Session: description: Signed in content: application/json: schema: { $ref: "#/components/schemas/Session" } Error: description: Error content: application/json: schema: { $ref: "#/components/schemas/Error" } schemas: Error: type: object required: [error] properties: error: type: string description: >- invalid_json, validation, invalid_credentials, mfa_required, unauthorized, forbidden, account_disabled, signup_disabled, domain_not_allowed, invalid_token, internal fields: type: object additionalProperties: { type: string } mfaId: { type: string } User: type: object required: [id, email, name, avatar, locale, theme, status, isAdmin, verified, created] properties: id: { type: string } email: { type: string, format: email } name: { type: string } avatar: { type: string } locale: { type: string } theme: { type: string } status: { type: string, enum: [active, invited, disabled] } isAdmin: { type: boolean } verified: { type: boolean } created: { type: string } Session: type: object required: [token, user] properties: token: { type: string } user: { $ref: "#/components/schemas/User" } UserList: type: object required: [items, page, perPage, totalItems] properties: items: { type: array, items: { $ref: "#/components/schemas/User" } } page: { type: integer } perPage: { type: integer } totalItems: { type: integer } AuthMethods: type: object required: [password, otp, mfa, oauth2, signup] properties: password: { type: boolean } otp: { type: boolean } mfa: { type: boolean } oauth2: { type: array, items: { type: string } } signup: { type: boolean } SignupRequest: type: object required: [email, password, name] properties: email: { type: string, format: email } password: { type: string, minLength: 8 } name: { type: string } LoginRequest: type: object required: [email, password] properties: email: { type: string, format: email } password: { type: string } mfaId: { type: string } EmailRequest: type: object required: [email] properties: email: { type: string, format: email } Status: type: object required: [status] properties: status: { type: string, enum: [ok, unavailable] } db: { type: string } Version: type: object required: [name, version] properties: name: { type: string } version: { type: string }