Developers

API Reference

Use the Selfbase REST API to manage your pages and content programmatically. Authenticate with an API key and integrate Selfbase into your own tools, automations, or AI agents.

Overview

The Selfbase API is a REST API available at https://selfba.se. All responses are JSON. Endpoints that modify data require authentication.

Base URL
https://selfba.se
Auth
Bearer token
Format
application/json

Authentication

All API requests must include your API key as a Bearer token in the Authorization header.

Creating an API key

  1. Log in to your Selfbase account at selfba.se
  2. Go to Profile → API Keys
  3. Enter a name for your key and click Generate
  4. Copy the token immediately — it is shown only once

You can have up to 5 API keys per account. Keys do not expire by default.

Using your API key

Include the key in every request:

Authorization: Bearer YOUR_API_KEY

Example request

curl https://selfba.se/api/pages \ -H "Authorization: Bearer YOUR_API_KEY"

Pages

A page is the core object in Selfbase — it's what your audience visits at selfba.se/your-slug. You can list, create, inspect, and configure pages through the API.

GET/api/pages

Returns a paginated list of your pages.

Query parameters

pageoptional
number

Page number (default: 1)

pageSizeoptional
number

Results per page (default: 10)

searchoptional
string

Filter by title or slug

Response

{ "pages": [ { "id": "3f1a...", "title": "My Page", "slug": "my-page", "description": "My Selfbase page", "avatar": null, "is_premium": false, "created_at": "2025-01-15T10:00:00.000Z" } ], "total": 1 }

Example

curl https://selfba.se/api/pages \ -H "Authorization: Bearer YOUR_API_KEY"
GET/api/pages/:slug

Returns details of a single page by its slug.

Response

{ "id": "3f1a...", "title": "My Page", "slug": "my-page", "description": "My Selfbase page", "avatar": null, "published_at": "2025-01-16T08:00:00.000Z", "is_premium": false, "styles": {}, "meta": {} }

Example

curl https://selfba.se/api/pages/my-page \ -H "Authorization: Bearer YOUR_API_KEY"
POST/api/pages

Creates a new page with the given slug and title.

Request body

slug
string

URL slug for the page, e.g. my-page

title
string

Display title of the page

Response

{ "id": "3f1a...", "slug": "my-page", "title": "My Page" }

Example

curl -X POST https://selfba.se/api/pages \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"slug": "my-page", "title": "My Page"}'
PUT/api/pages/:slug/settings

Updates page settings. The section field determines which settings group to update. The API applies only the fields you provide within data.

Request body

section
"general" | "seo" | "analytics"

Which settings group to update

data
object

Key/value pairs for the chosen section (see below)

General section fields

publishedoptional
boolean

true makes the page public, false hides it (Private)

titleoptional
string

Page display title

slugoptional
string

New URL slug (must be unique)

avataroptional
string

URL of the page-level profile photo

Response

{ "success": true }

Example

# Publish a page curl -X PUT https://selfba.se/api/pages/my-page/settings \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"section": "general", "data": {"published": true}}' # Unpublish a page curl -X PUT https://selfba.se/api/pages/my-page/settings \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"section": "general", "data": {"published": false}}'

Blocks

Blocks are the content units on a page — links, text, images, forms, etc. They are hierarchical: a block can have child blocks via parent_id. Order is controlled by the position field.

Block types

The name field identifies what kind of block it is. Common types:

headerHeading text
textRich text paragraph
buttonSingle link button
linksGroup of link buttons
social_linksSocial media icons
avatarProfile photo (content block)
cardCard with title and text
embedEmbeddable URL (video, map…)
mediaImage or video
profile_heroProfile hero section
formContact / custom form
tip_jarTip / donation widget
product_saleProduct for sale
GET/api/pages/:slug/blocks

Returns all blocks for a page as a recursive tree (children nested under their parent).

Response

[ { "id": "b1a2...", "name": "header", "title": "My header", "content": { "text": "Hello world" }, "position": 1, "is_active": true, "parent_id": null, "children": [] } ]

Example

curl https://selfba.se/api/pages/my-page/blocks \ -H "Authorization: Bearer YOUR_API_KEY"
POST/api/pages/:slug/blocks

Adds a new block to the page. The block is appended at the end by default.

Request body

block.name
string

Block type identifier (e.g. header, button)

block.label
string

Human-readable label for the block

contentoptional
object

Initial content for the block

parentIdoptional
string

ID of the parent block (for nested blocks)

Response

{ "id": "b1a2...", "name": "header", "position": 2, "is_active": false }

Example

curl -X POST https://selfba.se/api/pages/my-page/blocks \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "block": { "name": "header", "label": "Header" }, "content": { "text": "Welcome to my page" } }'
PUT/api/pages/:slug/blocks/:id

Updates one or more fields on an existing block. Pass only the fields you want to change.

Request body

contentoptional
object

Block content (merged with existing)

stylesoptional
object

Block styles (merged with existing)

is_activeoptional
boolean

Show (true) or hide (false) the block

positionoptional
number

Sort order

Response

{ "success": true }

Example

curl -X PUT https://selfba.se/api/pages/my-page/blocks/b1a2... \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"content": {"text": "Updated heading"}}'
DELETE/api/pages/:slug/blocks/:id

Permanently removes a block and all its children.

Response

{ "success": true }

Example

curl -X DELETE https://selfba.se/api/pages/my-page/blocks/b1a2... \ -H "Authorization: Bearer YOUR_API_KEY"

Claude / MCP integration

Selfbase ships a Model Context Protocol (MCP) server that lets you manage your page through Claude or any other MCP-compatible AI assistant. The server exposes all API operations as natural-language tools — no code needed.

Connecting to Claude

  1. In Claude, open Settings → Connectors → Add custom connector
  2. Paste the server URL shown below
  3. Sign in to Selfbase when the OAuth window opens
  4. The Selfbase tools appear in your conversation immediately
mcp.selfba.se

Authentication is handled via OAuth — no API key needed for MCP. Other MCP-compatible clients should work the same way: paste the server URL, complete the OAuth flow, done.

Available tools

list_pagesList all pages in your account
get_pageGet details of a page by slug
create_pageCreate a new page with a slug and title
publish_pageMake a page publicly visible
unpublish_pageHide a page from public access
set_page_avatarSet the page-level profile photo
list_blocksList all blocks on a page
get_blockGet details of a specific block
add_blockAdd a new block to a page
update_blockUpdate content, styles, or visibility of a block
delete_blockPermanently remove a block and its children

Example prompts

💬

"Create a new page called "Portfolio" with slug "portfolio" and add a profile hero block at the top"

💬

"List my pages and show me which ones are currently published"

💬

"Add a links block to my "portfolio" page with three links: GitHub, LinkedIn, and my website"

💬

"Unpublish my "test-page" and publish "my-main-page""

Errors

The API uses standard HTTP status codes. Error responses include a statusMessage field describing the issue.

StatusMeaning
400Bad request — missing or invalid parameters
401Unauthorized — API key missing or invalid
403Forbidden — you do not own this resource
404Not found — page or block does not exist
429Too many requests — rate limit exceeded (150 req/min)
500Server error — try again or contact support