Skip to content

How to Sync Intranet Data

This guide covers the practical steps for pushing data from an external intranet system into the Wippidu app.

Overview

The sync works in two phases:

  1. Push data — External system sends data to the API → stored in staging tables
  2. Process data — Admin triggers processing → staging data transforms into app tables

Prerequisites

  • An API token (created at /admin/tokens)
  • The external system's IP in the token's allowlist (if configured)

Create an API token

  1. Log in as Admin
  2. Navigate to /admin/tokens/new
  3. Set a friendly name (e.g., "Intranet Production")
  4. Optionally set IP allowlist: 10.0.0.0/8, 192.168.1.100
  5. Save and copy the token (shown only once)

Push data via API

All endpoints require Bearer token authentication. Push data in dependency order:

TOKEN="your-api-token-here"
BASE="https://app.example.com"

# 1. Push locations
curl -X POST "$BASE/api/intranet/location" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {"einrichtungs_id": "L001", "name": "Kita Sonnenschein", "adresse": "Hauptstr. 1"}
    ]
  }'

# 2. Push groups (requires locations)
curl -X POST "$BASE/api/intranet/group" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {"gruppen_id": "G001", "einrichtungs_id": "L001", "name": "Schmetterlinge"}
    ]
  }'

# 3. Push persons (children, parents, employees)
curl -X POST "$BASE/api/intranet/person" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {"external_id": "K001", "vorname": "Emma", "nachname": "Müller", "rolle": "1"}
    ]
  }'

# 4. Push group assignments
curl -X POST "$BASE/api/intranet/belegung/krp" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {"id_krp": "B001", "kind_id": "K001", "gruppen_id": "G001", "status": 3}
    ]
  }'

# 5. Push parent-child relationships
curl -X POST "$BASE/api/intranet/parent-child" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {"eltern_id": "P001", "kind_id": "K001", "von": "2023.01.01"}
    ]
  }'

# 6. Push employees, location leads, group leads...

Trigger processing

  1. Navigate to /admin/sync
  2. Review pending record counts
  3. Click "Process All" (processes in dependency order)
  4. Or process individually: Locations → Groups → Children → Child-Group assignments

Testing locally

# Test with a local server
curl -X POST http://localhost:8080/api/intranet/location \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"records": [{"einrichtungs_id": "TEST1", "name": "Test Location"}]}'

# Test with invalid token (expect 401)
curl -X POST http://localhost:8080/api/intranet/location \
  -H "Authorization: Bearer invalid" \
  -H "Content-Type: application/json" \
  -d '{"records": []}'

Error handling

Missing dependency (e.g., group without its location):

{
  "DataType": "group",
  "RecordsTotal": 2,
  "Created": 1,
  "Skipped": 1,
  "Errors": ["Skipped group G002: location L999 not found"]
}

Invalid payload:

{
  "success": false,
  "error": {
    "code": "INVALID_PAYLOAD",
    "message": "Field validation for 'ExternalID' failed on the 'required' tag"
  }
}

Configure daily employee group sync

For real-time group assignments (e.g., substitute teachers), configure the outbound intranet API:

  1. Navigate to /admin/settings
  2. Go to the Intranet tab
  3. Configure:
  4. Enable Intranet Sync: Toggle on
  5. API URL: Full URL to the intranet groups endpoint
  6. API Token: Token for authenticating with the intranet

Test the connection

Use the Test Connection button with a known employee ID to verify: - The API is reachable - The token is valid - The response format is correct

How it works

When an intranet-linked employee (one with ExternalID set) logs in:

  1. App checks if they've been refreshed today
  2. If not, calls the intranet API with their Mitarbeiter_ID
  3. Receives JSON with group assignments and Stammteam flags
  4. Stores assignments in employee_daily_groups
  5. Updates intranet_refresh_date on the user

Troubleshooting

Employee doesn't see their group's children: - Check users.external_id matches the intranet Mitarbeiter_ID - Check groups.external_id matches the intranet Gruppen_ID - Check /admin/settings → Intranet settings are configured - Check the user's intranet_refresh_failed flag

Refresh fails silently: - Enable debug logging to see API request/response details - Check network connectivity to the intranet API - Verify token format (must be accepted as Bearer token AND form field)