Skip to main content

District Sync API

Overview

This ingestion-side route loads district cost data from the upstream source system, maps it into SDAC report structure, and returns the resulting report_id.

Direct ingestion path:

  • POST /sdac/sync

Widget same-origin path:

  • POST /api/ingestion/sdac/sync

This route is also used internally during Session Bootstrap to resolve the latest report for a district.

Authentication and Access Model

This ingestion route does not perform APIM bearer-token or subscription-key validation itself.

  • Browser clients should use the widget same-origin proxy at /api/ingestion/sdac/sync.
  • Direct /sdac/sync access should stay behind private deployment controls or reverse-proxy authentication.
  • Do not expose this route directly to untrusted browser clients.

Request

AttributeValue
EndpointPOST /sdac/sync
Content-Typeapplication/json
ResponseJSON

Request Body

{
"district_id": "12345",
"year": 2026,
"quarter": 1,
"allow_fallback": false,
"force": false
}
FieldTypeRequiredDescription
district_idstringYesDistrict identifier used by the source system
yearintegerNoReporting year. Defaults to the current UTC year
quarterintegerNoQuarter 1 through 4. Defaults to the current UTC quarter
allow_fallbackbooleanNoAllows returning a different available quarter when the requested period has no data. Defaults to false
forcebooleanNoForce a fresh sync even if a recent report already exists

Success Response

{
"report_id": "8201EDC2-2EDE-4CA1-AF44-D0F5AA185CDB",
"status": "success",
"record_count": 21,
"synced": true,
"district_name": "Maplewood Richmond Heights",
"quarter": "Q1",
"year": 2026,
"fallback": false,
"requested_quarter": "Q1",
"requested_year": 2026,
"available_quarters": []
}
FieldDescription
report_idSDAC report identifier when a report was resolved or created
statusSync outcome such as success, duplicate, or empty
record_countNumber of roster rows included in the resolved report
syncedtrue when the service performed a new sync, false when it reused existing data
district_nameResolved district display name when available
quarterQuarter used for the resolved report
yearYear used for the resolved report
fallbacktrue when the service had to use a different available quarter than the one requested
requested_quarterQuarter originally requested by the client
requested_yearYear originally requested by the client
available_quartersDiagnostic list of recent quarters with data when fallback logic was evaluated

Empty Response

{
"report_id": null,
"status": "empty",
"record_count": 0,
"synced": false,
"fallback": false,
"requested_quarter": "Q1",
"requested_year": 2026,
"available_quarters": []
}

Error Cases

StatusDescription
4xxUpstream source-system request failed and was passed through
500Sync failed locally or server-side configuration was incomplete

Example local failure:

{
"error": "THERAPYLOG_API_URL is required.",
"synced": false
}

Side Effects

  • When recent synced data already exists and force is false, the service can return the existing report_id without creating a new report.
  • When fresh data is needed, the service fetches district cost data from the upstream source system, maps it into SDAC report structure, and writes or reuses a THERAPYLOG_SYNC report in the ingestion store.
  • If allow_fallback=true and the requested quarter has no usable data, the service can probe adjacent available quarters and return fallback: true with the actual period used.

Operational Notes

  • If force is not set, the service may return an existing recent report instead of creating a new one.
  • Keep allow_fallback=false for page-context loads. Use fallback only after a user explicitly chooses another available quarter.
  • Use Report Status API or the gateway-facing Report Info API after sync, depending on whether you need ingestion-state detail or review metadata.