API Add School
From zFairs Contest Management
Contents
Add School
Creates or updates a school on the client. If Id is set to an existing school id, the school is updated; otherwise a new school is created.
Authentication
All data API calls are POST (unless noted) with JSON body:
| Field | Required | Description |
|---|---|---|
ApiKey |
Yes* | Private API key for your site. Prefer this over username/password. |
Username / Password |
Yes* | Alternate auth if not using ApiKey. |
FairId |
Yes | Fair GUID from the site URL (f query parameter).
|
Body |
Depends | Request payload. Use {} when no body fields are needed.
|
- Provide either
ApiKeyorUsername+Password.
Calls must be run server-side — do not expose your API key in a browser.
Response envelope
Most endpoints return:
{
Success: true,
Message: null, // error text when Success is false
Body: { ... } // endpoint-specific payload
}
Request
fetch('/api/data/school', {
method:'POST',
headers:{'Content-Type': 'application/json'},
body: JSON.stringify({
ApiKey:'<Private key>',
FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', // value of f in your URL
Body: {
Id: 0, // 0 or omit for new; existing id to update
Name: "Example School",
Address: "100 School Rd",
Address2: "",
City: "Ogden",
State: "UT",
Zip: "84401",
County: "Weber",
Phone: "801-555-0100",
WebsiteUrl: "https://example.edu",
SchoolType: "Public", // Public | Private | Charter | Home
PrincipalName: "Pat Principal",
PrincipalPhone: "801-555-0101",
PrincipalEmail: "principal@example.edu",
ContactFirstName: "Casey",
ContactLastName: "Contact",
ContactPhone: "801-555-0102",
ContactEmail: "contact@example.edu",
GradeLow: 6,
GradeHigh: 12,
Fax: "",
SchoolPaysFees: false,
IsFeeWaiverSchool: false,
SchoolCode: "EX001",
Active: true,
Affiliated: true,
RegionName: "North",
EducationAgencyName: "North Agency"
}
})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});Response
On success Body is the school object with Id populated:
{
Success: true,
Message: null,
Body: { Id: 24, Name: "Example School", ... }
}
Field notes
SchoolTypemaps to: Public → "Public School", Private → "Private School", Charter → "Charter School", Home → "Home School". Unknown defaults to Public School.- Returned
Idshould be stored for use asSchoolIdon projects/participants.
Related APIs