Sync Ops

API Overview

Interactive API Documentation

Swagger UI: http://localhost:5001/api-docs (or /api-docs in production)

Use Swagger UI for interactive API testing and detailed endpoint documentation.

Authentication

Most endpoints require HTTP Basic Auth with API_PASSWORD environment variable.

Endpoint Categories

Funding Endpoints

Manage funding applications (søknader) syncing between ClickUp, Cornerstone, and WordPress.

  • POST /applications/funding - Create/update funding from ClickUp task
  • POST /applications/funding/by-entity-uuid - Create/update funding by entity UUID
  • GET /applications/funding/entity/{task_id} - Get funding entity info
  • GET /applications/funding/summary/{entity_uuid} - Get funding summary
  • POST /applications/funding/create-entity-mapping - Create entity mapping for existing task

Lokallag (Groups) Endpoints

Manage lokallag (organizations) syncing between Cornerstone, ClickUp, and WordPress.

  • POST /applications/create-new - Create new lokallag across all systems
  • POST /applications/sync-lokallag/{task_id} - Sync existing lokallag or create new
  • POST /lokallag/global-sync - Global sync for all lokallag and funding entities

Webhooks

Receive updates from external systems.

  • POST /clickup-webhook/funding?task_id={id} - ClickUp funding webhook
  • POST /webhook?task_id={id} - General webhook for lokallag
  • POST /wordpress-webhook/funding/{post_id} - WordPress funding webhook

Entity Management

Manage entity mappings across systems.

  • GET /entities/{entity_type} - List entities by type (group, funding, profile)
  • POST /entities/{entity_uuid}/resync - Resync specific entity
  • POST /entities/{entity_uuid}/archive - Archive entity

Inspector Endpoints

Debug and fix entity mapping issues.

  • GET /inspector/entities/missing - Find entities missing IDs
  • GET /inspector/entities/{entity_uuid} - Get entity details
  • POST /inspector/entities/{entity_uuid}/fix - Fix entity mapping
  • GET /inspector/report - Generate inspection report
  • GET /inspector/funding/health - Check funding entity health

Monitoring

Track sync status and errors.

  • GET /sync/status - Current sync status
  • GET /sync/logs - Recent sync logs
  • GET /sync/health - System health check
  • GET /sync/errors/by-entity?hours=24 - Errors by entity
  • GET /sync/history?limit=20 - Sync history

Scheduler

Manage scheduled sync operations.

  • GET /scheduler/status - Get scheduler status
  • POST /scheduler/trigger - Trigger manual sync

Grants

BigQuery grants sync operations.

  • POST /grants - Sync grants (incremental)
  • POST /grants/backfill - Full grants backfill
  • GET /grants/status - Grants sync status
  • GET /grants/health - Grants health check

Profiles

Profile management endpoints.

  • POST /profiles/create-wordpress/{task_id} - Create WordPress profile

Utility Endpoints

Helper endpoints for various operations.

  • POST /applications/update-relationship - Update task relationships
  • GET /get-task-id - Get ClickUp task ID by Cornerstone ID
  • POST /applications/set-type - Set task type field

Common Response Format

{
  "status": "success|error",
  "message": "Description",
  "data": {}
}

Error Responses

  • 400 - Bad Request (missing parameters)
  • 404 - Not Found (entity not found)
  • 500 - Internal Server Error