Skip to content

Latest commit

 

History

History
130 lines (103 loc) · 10.6 KB

api.md

File metadata and controls

130 lines (103 loc) · 10.6 KB

HTTP API

Everything the dashboard does goes through this API, so you can script it too. Types named here (Space, Testimonial, Wall, …) are defined in packages/shared/src/types.ts, and request bodies are validated by the schemas in packages/shared/src/schemas.ts.

Conventions

  • JSON in and out, except uploads (multipart/form-data) and media.

  • Errors always look like this, with fields when a request body failed validation:

    {
      "error": {
        "code": "invalid_input",
        "message": "Check the highlighted fields.",
        "fields": { "name": "Name the space." }
      }
    }

    Codes: invalid_input (400), signed_out (401), forbidden (403), not_found (404), conflict (409), too_large (413), unsupported_file (415), form_expired and too_fast (422), rate_limited (429), internal (500).

  • Signing in sets an HTTP-only cookie, kindwall_session (SameSite=Lax, Secure on https).

  • Changing something (any method but GET/HEAD) with that cookie also needs the header X-Kindwall-Client: dashboard. Public endpoints don't need it.

  • Lists that can grow are pages: { "items": [...], "nextCursor": "…" | null }; pass ?before=<nextCursor> for the next page.

Server

Method Path Response
GET /api/health { status: "ok", version, checks: { database, storage } } (503 when a check fails)
GET /api/server ServerConfig: sign-up allowed, video and email available, upload limits

Account

Method Path Body Response
POST /api/account/signup { name, email, password } Account (signs you in; creates your first workspace)
POST /api/account/login { email, password } Account
POST /api/account/logout 204
GET /api/account Account, or 401
PATCH /api/account { name?, notifyNewTestimonials? } Account

Workspaces

Everything below works on the current workspace (Account.workspace).

Method Path Body / query Response Who
POST /api/workspaces { name } Account (switched to the new one) anyone
POST /api/workspaces/:id/switch Account its members
GET /api/workspace/overview Overview members
GET /api/workspace/members { items: Member[] } members
POST /api/workspace/members { email, role } Member owners, admins
PATCH /api/workspace/members/:userId { role } Member owners, admins
DELETE /api/workspace/members/:userId 204 owners, admins, or yourself
GET /api/workspace/activity ?before Page<ActivityItem> owners, admins
GET /api/workspace/export ?format=json|csv a file download owners, admins

A workspace always keeps at least one owner. Only owners can make someone an owner.

Spaces

Method Path Body Response Who
GET /api/spaces { items: Space[] } members
POST /api/spaces { name, slug? } Space owners, admins
GET /api/spaces/:id Space members
PUT /api/spaces/:id SpaceSettings Space owners, admins
DELETE /api/spaces/:id 204 (deletes its testimonials, files and walls) owners, admins
PUT /api/spaces/:id/logo multipart file (PNG, JPEG, WebP) Space owners, admins
DELETE /api/spaces/:id/logo Space owners, admins
GET /api/spaces/:id/logo the image anyone (logos are public)
POST /api/spaces/:id/webhook/test WebhookTestResult owners, admins
POST /api/spaces/:id/webhook/secret Space with a new secret owners, admins

Space.webhookSecret is null for members who aren't owners or admins. A new space's slug comes from its name (with a short suffix if it's taken) unless you pass one.

Testimonials

Method Path Body / query Response Who
GET /api/testimonials ?status&spaceId&q&featured&before&limit Page<Testimonial> members
GET /api/testimonials/:id Testimonial members
PATCH /api/testimonials/:id TestimonialUpdate Testimonial members
POST /api/testimonials/bulk { ids, action: approve|reject|pending|delete } { updated: n } members; delete needs owners, admins
DELETE /api/testimonials/:id 204 owners, admins
POST /api/testimonials/import multipart: ImportInput fields, optional avatar Testimonial (approved) members
GET /api/testimonials/:id/avatar the image members
GET /api/testimonials/:id/video supports Range the video members

Lists are newest first. q searches the text, author, title and company. Changing body marks the testimonial as edited.

Walls

Method Path Body Response Who
GET /api/walls { items: Wall[] } members
POST /api/walls { name, spaceId, slug? } Wall members
GET /api/walls/:id Wall members
PUT /api/walls/:id WallSettings Wall members
DELETE /api/walls/:id 204 members
POST /api/walls/preview WallSettings PublicWall members

preview returns exactly what the embed would get with those settings, without saving them.

Public endpoints

No sign-in. Spaces and walls are found by slug. Only approved testimonials are ever returned, and never private fields (author email, consent details).

Method Path Response
GET /api/public/spaces/:slug PublicSpace, including a fresh formToken
POST /api/public/spaces/:slug/testimonials multipart PublicSubmission fields, optional avatar and video files → 201 SubmissionReceipt
GET /api/public/walls/:slug PublicWall (Access-Control-Allow-Origin: *)
GET /api/public/testimonials/:id/avatar the image, if the testimonial is approved
GET /api/public/testimonials/:id/video the video, if approved; supports Range
GET /embed.js the widget script

Submissions are limited per IP address (SUBMISSIONS_PER_HOUR), must arrive at least MIN_FORM_SECONDS after the form was loaded (too_fast) and within 24 hours (form_expired), and must include a video when the space only takes video, or text when it only takes text.