-
-
Notifications
You must be signed in to change notification settings - Fork 118
Getting Started Guide
Get up and running with Daptin in minutes.
Always run these commands before starting Daptin:
# Kill all Daptin processes
pkill -9 -f daptin 2>/dev/null || true
pkill -9 -f "go run main" 2>/dev/null || true
# Free both ports
lsof -i :6336 -t | xargs kill -9 2>/dev/null || true # HTTP API
lsof -i :5336 -t | xargs kill -9 2>/dev/null || true # Olric cache
# Verify ports are free
lsof -i :6336 || echo "✓ Port 6336 free"
lsof -i :5336 || echo "✓ Port 5336 free"
sleep 2Why This Matters:
- Port 6336: HTTP API
- Port 5336: Olric distributed cache (stores permissions, admin IDs, user groups)
- Cache TTL: 60 minutes
-
Symptom if forgotten:
become_an_administratorreturns "Unauthorized" even on fresh database
Alternative: Use the test runner script which handles this automatically:
./scripts/testing/test-runner.sh stop
./scripts/testing/test-runner.sh start# Default (SQLite)
go run main.go
# With PostgreSQL
go run main.go -db_type postgres -db_connection_string "host=localhost port=5432 user=postgres password=secret dbname=daptin sslmode=disable"Open http://localhost:6336 to access the dashboard.
On a fresh install, anyone can do anything. You need to claim admin immediately.
# Sign up
curl -X POST http://localhost:6336/action/user_account/signup \
-H "Content-Type: application/json" \
-d '{
"attributes": {
"name": "Admin",
"email": "admin@example.com",
"password": "yourpassword",
"passwordConfirm": "yourpassword"
}
}'
# Sign in and extract token
TOKEN=$(curl -s -X POST http://localhost:6336/action/user_account/signin \
-H "Content-Type: application/json" \
-d '{
"attributes": {
"email": "admin@example.com",
"password": "yourpassword"
}
}' | jq -r '.[] | select(.ResponseType == "client.store.set") | .Attributes.value')
echo "$TOKEN" > /tmp/daptin-token.txt
echo "Token saved to /tmp/daptin-token.txt"
# Become admin (NOTE: action is on "world", not "user_account")
curl -X POST http://localhost:6336/action/world/become_an_administrator \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{}'The server may restart. Sign in again to get a fresh token - you're now admin.
# Get fresh token after server restart
sleep 5
TOKEN=$(curl -s -X POST http://localhost:6336/action/user_account/signin \
-H "Content-Type: application/json" \
-d '{"attributes":{"email":"admin@example.com","password":"yourpassword"}}' | \
jq -r '.[] | select(.ResponseType == "client.store.set") | .Attributes.value')
echo "$TOKEN" > /tmp/daptin-token.txtAfter this: The system locks down. Public signup is disabled. Only you can create new users.
If you get a 403 error on signup, someone already claimed admin. You have two options:
Ask them to create an account for you (see "Admin: Create a User" below).
If this is your own server and you lost access:
# Stop Daptin
# Delete the database file (default: daptin.db)
rm daptin.db
# Restart DaptinThis wipes everything. Start fresh with step 2.
If you get an "Unauthorized" error when trying to become administrator on a fresh database, it's caused by stale Olric cache from a previous Daptin process.
Symptoms:
{
"ResponseType": "client.notify",
"Attributes": {
"message": "Unauthorized",
"title": "failed",
"type": "error"
}
}Root Cause:
- Olric cache (port 5336) stores admin reference IDs with 60-minute TTL
- Old process keeps cache alive even after "stopping" server
- Cache says admin exists → become_an_administrator rejects you
- This happens even with a fresh database!
Solution:
# CRITICAL: Kill port 5336 (Olric cache)
lsof -i :5336 -t | xargs kill -9 2>/dev/null || true
# Also kill all Daptin processes
pkill -9 -f daptin 2>/dev/null || true
pkill -9 -f "go run main" 2>/dev/null || true
# Verify port is free
lsof -i :5336 || echo "✓ Port 5336 is free"
sleep 2
# Now start fresh
./scripts/testing/test-runner.sh startPrevention: Always use the test runner script, which now kills both ports:
./scripts/testing/test-runner.sh stop # Kills ports 6336 AND 5336
./scripts/testing/test-runner.sh startSince signup is disabled after admin setup, create users directly:
# As admin, create a new user
curl -X POST http://localhost:6336/api/user_account \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "user_account",
"attributes": {
"name": "New User",
"email": "user@example.com",
"password": "userpassword"
}
}
}'The user can now sign in with these credentials.
If you want anyone to sign up:
# Find the signup action
ACTION_ID=$(curl --get \
--data-urlencode 'query=[{"column":"action_name","operator":"is","value":"signup"}]' \
-H "Authorization: Bearer $ADMIN_TOKEN" \
"http://localhost:6336/api/action" | jq -r '.data[0].id')
echo "Signup action ID: $ACTION_ID"
# Update permission to allow guest execute (add 32 to guest bits)
curl -X PATCH "http://localhost:6336/api/action/$ACTION_ID" \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "action",
"id": "'$ACTION_ID'",
"attributes": {
"permission": 2085152
}
}
}'Note: After this change, restart the server for the permission update to take effect.
Create a file schema.yaml:
Tables:
- TableName: todo
Columns:
- Name: title
DataType: varchar(500)
ColumnType: label
- Name: completed
DataType: bool
ColumnType: truefalse
DefaultValue: "false"Place schema file in Daptin directory:
# Copy schema file with schema_* prefix
cp schema.yaml schema_todo.yaml
# Restart Daptin to load schema
pkill -f daptin
./daptin &
sleep 10Note: The upload_system_schema action exists but currently does not create tables after upload. Use the file placement method above until this is fixed.
# Create
curl -X POST http://localhost:6336/api/todo \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "todo",
"attributes": {"title": "My first task"}
}
}'
# List
curl http://localhost:6336/api/todo \
-H "Authorization: Bearer $TOKEN"
# Update
curl -X PATCH http://localhost:6336/api/todo/RECORD_ID \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "todo",
"id": "RECORD_ID",
"attributes": {"completed": true}
}
}'
# Delete
curl -X DELETE http://localhost:6336/api/todo/RECORD_ID \
-H "Authorization: Bearer $TOKEN"# Filter (use 0 for false, 1 for true on boolean fields)
curl --get \
--data-urlencode 'query=[{"column":"completed","operator":"is","value":0}]' \
-H "Authorization: Bearer $TOKEN" \
"http://localhost:6336/api/todo"
# Sort (descending with -)
curl 'http://localhost:6336/api/todo?sort=-created_at' \
-H "Authorization: Bearer $TOKEN"
# Paginate
curl 'http://localhost:6336/api/todo?page[number]=1&page[size]=10' \
-H "Authorization: Bearer $TOKEN"| Operator | Meaning |
|---|---|
is |
Equals |
is not |
Not equals |
contains |
Substring match |
begins with |
Starts with |
ends with |
Ends with |
any of |
In list |
is empty |
Is null |
| Problem | Solution |
|---|---|
| 403 on signup | Admin exists. Contact admin or reset database. |
| 401 Unauthorized | Token expired. Sign in again. |
| API returns HTML | Add header: Accept: application/vnd.api+json
|
| "become_an_administrator" fails | Admin already exists. Only first user can claim. |
- Permissions - Control who can access what
- Relationships - Link tables together
- Actions-Overview - Add business logic
- Schema-Definition - Full schema options
- Home
- Installation
- First-Admin-Setup ⭐ NEW
- Common-Errors 🔧 NEW
- Getting-Started-Guide
- Configuration
- Database-Setup
- Walkthrough-Product-Catalog
- Walkthrough-WebSocket-Real-Time ✨ NEW
- Walkthrough-YJS-Collaborative-Editing ✨ NEW
- Actions-Overview
- Action-Permission-Schema-Sync-Technical-KT
- User-Actions
- Admin-Actions
- Data-Actions
- Cloud-Actions
- Email-Actions
- Certificate-Actions
- Custom-Actions
- GraphQL-API ✓ NEW
- State-Machines
- Task-Scheduling ✓ NEW
- Template-Rendering ✓ NEW
- Data-Exchange
- Integrations