API Add School

From zFairs Contest Management
Revision as of 12:55, 25 July 2026 by Trent (talk | contribs) (Remove username/password API auth; ApiKey only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
FairId Yes Fair GUID from the site URL (f query parameter).
Body Depends Request payload. Use {} when no body fields are needed.


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

  • SchoolType maps to: Public → "Public School", Private → "Private School", Charter → "Charter School", Home → "Home School". Unknown defaults to Public School.
  • Returned Id should be stored for use as SchoolId on projects/participants.


Related APIs