Examples

These snippets match the DeskFlow tutorial. Each section links back to the guide that explains the concept — no new ideas here, just copy-paste starting points for Northwind Studio’s task board on port 8000.

Pick your learning path

Try the tutorial

Build the services behind these curl calls.

Moonlight overview

How service and action map to HTTP.

Documentation hub

All topic sections and layer index.

What these examples cover

ExampleDeskFlow actionLearn more
PingHealth checkIntroduction
List taskstask.listAPI tutorial
Create tasktask.createValidation
Member loginmember.loginSecurity
Filter open taskstask.list + filterFiltering
settings.iniSwitch registrationApplication structure

Ping

curl -s http://127.0.0.1:8000/api/v1/ping
Result
{
  "returnCode": 0,
  "returnMessage": "pong",
  "returnData": { "version": "v1" }
}

List tasks

curl -s -X POST http://127.0.0.1:8000/api/v1/ \
  -H "Content-Type: application/json" \
  -d '{"service":"task","action":"list"}'
Result
{
  "returnCode": 0,
  "returnMessage": "OK",
  "returnData": {
    "tasks": [
      {
        "id": 1,
        "title": "Review homepage mockups",
        "status": "open",
        "assignee": "alex@northwind.studio"
      }
    ]
  }
}

Learn how this is built: API tutorial.

Create a task

curl -s -X POST http://127.0.0.1:8000/api/v1/ \
  -H "Content-Type: application/json" \
  -d '{"service":"task","action":"create","title":"Ship DeskFlow docs","project_id":1}'

Missing title returns HTTP 422 — see Validation.

Member login

curl -s -X POST http://127.0.0.1:8000/api/v1/ \
  -H "Content-Type: application/json" \
  -d '{"service":"member","action":"login","email":"alex@northwind.studio","password":"secret"}'

Use the returned JWT in Authorization: Bearer … for protected actions — Security.

Filter open tasks

curl -s -X POST http://127.0.0.1:8000/api/v1/ \
  -H "Content-Type: application/json" \
  -d '{"service":"task","action":"list","status":"open"}'

Sample settings.ini

[app_switches]
v1=Application\Switches\MainSwitch

[app]
DEBUG=true

Full reference: Application structure.

Common mistakes

  • Running curl before php pionia serve — start the dev server on port 8000 first.
  • Wrong Content-Type — Moonlight POST dispatch requires Content-Type: application/json.
  • Forgetting to register the servicetask.list fails until TaskService is on MainSwitch.
  • Copying v2 uppercase keys — use lowercase "service" and "action" in every payload.

What’s next

Tutorial Step 3

Implement task.list in TaskService.

Services

Register DeskFlow services on MainSwitch.

Resources

Packages, CLI cheatsheet, and community links.