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.
https://selfba.seBearer tokenapplication/jsonAuthentication
All API requests must include your API key as a Bearer token in the Authorization header.
Creating an API key
- Log in to your Selfbase account at selfba.se
- Go to Profile → API Keys
- Enter a name for your key and click Generate
- 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_KEYExample 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.
/api/pagesReturns a paginated list of your pages.
Query parameters
pageoptionalnumberPage number (default: 1)
pageSizeoptionalnumberResults per page (default: 10)
searchoptionalstringFilter 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"/api/pages/:slugReturns 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"/api/pagesCreates a new page with the given slug and title.
Request body
slugstringURL slug for the page, e.g. my-page
titlestringDisplay 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"}'/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
dataobjectKey/value pairs for the chosen section (see below)
General section fields
publishedoptionalbooleantrue makes the page public, false hides it (Private)
titleoptionalstringPage display title
slugoptionalstringNew URL slug (must be unique)
avataroptionalstringURL 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 texttextRich text paragraphbuttonSingle link buttonlinksGroup of link buttonssocial_linksSocial media iconsavatarProfile photo (content block)cardCard with title and textembedEmbeddable URL (video, map…)mediaImage or videoprofile_heroProfile hero sectionformContact / custom formtip_jarTip / donation widgetproduct_saleProduct for sale/api/pages/:slug/blocksReturns 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"/api/pages/:slug/blocksAdds a new block to the page. The block is appended at the end by default.
Request body
block.namestringBlock type identifier (e.g. header, button)
block.labelstringHuman-readable label for the block
contentoptionalobjectInitial content for the block
parentIdoptionalstringID 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" } }'/api/pages/:slug/blocks/:idUpdates one or more fields on an existing block. Pass only the fields you want to change.
Request body
contentoptionalobjectBlock content (merged with existing)
stylesoptionalobjectBlock styles (merged with existing)
is_activeoptionalbooleanShow (true) or hide (false) the block
positionoptionalnumberSort 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"}}'/api/pages/:slug/blocks/:idPermanently 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
- In Claude, open Settings → Connectors → Add custom connector
- Paste the server URL shown below
- Sign in to Selfbase when the OAuth window opens
- The Selfbase tools appear in your conversation immediately
mcp.selfba.seAuthentication 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 accountget_pageGet details of a page by slugcreate_pageCreate a new page with a slug and titlepublish_pageMake a page publicly visibleunpublish_pageHide a page from public accessset_page_avatarSet the page-level profile photolist_blocksList all blocks on a pageget_blockGet details of a specific blockadd_blockAdd a new block to a pageupdate_blockUpdate content, styles, or visibility of a blockdelete_blockPermanently remove a block and its childrenExample 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.
| Status | Meaning |
|---|---|
400 | Bad request — missing or invalid parameters |
401 | Unauthorized — API key missing or invalid |
403 | Forbidden — you do not own this resource |
404 | Not found — page or block does not exist |
429 | Too many requests — rate limit exceeded (150 req/min) |
500 | Server error — try again or contact support |