Skip to content

Hello World — First API Call

This guide walks you through making your first call to the Coaching App backend API.

Prerequisites

  • Docker running with docker compose -f docker-compose.yml -f docker-compose.dev.yml up
  • Database seeded: cd backend && pnpm db:migrate && pnpm db:seed

Service URLs

Service URL Description
Backend API http://localhost:3001 Hono REST API
Mailpit http://localhost:8025 Catch all dev emails
MinIO Console http://localhost:9001 Object storage UI
Drizzle Studio http://localhost:4983 Visual database browser

1. Health Check

curl http://localhost:3001/api/health
# → { "status": "ok" }

2. Sign In

curl -X POST http://localhost:3001/api/auth/sign-in/email \
  -H "Content-Type: application/json" \
  -c /tmp/cookies.txt \
  -d '{"email":"platformadmin@coaching.test","password":"PlatformAdmin1234!"}'

Response:

{
  "user": { "id": "...", "email": "platformadmin@coaching.test", "name": "Platform Admin" },
  "session": { ... }
}

3. Get Your Profile

curl http://localhost:3001/api/me \
  -b /tmp/cookies.txt

Response:

{
  "id": "...",
  "email": "platformadmin@coaching.test",
  "name": "Platform Admin",
  "profile": { "role": "platform_admin", "organizationId": null }
}

4. List Organizations (Platform Admin only)

curl http://localhost:3001/api/organizations \
  -b /tmp/cookies.txt

Response:

[{ "id": "...", "name": "Demo Organization", "slug": "demo-org" }]

5. Sign Out

curl -X POST http://localhost:3001/api/auth/sign-out \
  -b /tmp/cookies.txt -c /tmp/cookies.txt

Troubleshooting

Connection refused:

# Check services are running
docker compose ps

# Check backend logs
docker compose logs backend -f

401 Unauthorized:

  • Make sure you're passing the cookie jar (-b /tmp/cookies.txt)
  • Re-run the sign-in step to get a fresh session

403 Forbidden:

  • The endpoint requires a role the signed-in user doesn't have
  • Try signing in with a platform_admin account

Next Steps