Difference between revisions of "API Add Person"
From zFairs Contest Management
(Remove username/password API auth; ApiKey only) |
|||
| (16 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| − | == Add Person== | + | == Add Person == |
| − | + | Creates a person (teacher, judge, staff, admin, volunteer, or student placeholder) for the client/fair. Also supports judge preferences and optional roles. | |
| + | === Authentication === | ||
| + | All data API calls are <code>POST</code> (unless noted) with JSON body: | ||
| + | |||
| + | {| class="wikitable" | ||
| + | |- | ||
| + | ! Field !! Required !! Description | ||
| + | |- | ||
| + | | <code>ApiKey</code> || Yes || Private API key for your site. | ||
| + | |- | ||
| + | | <code>FairId</code> || Yes || Fair GUID from the site URL (<code>f</code> query parameter). | ||
| + | |- | ||
| + | | <code>Body</code> || Depends || Request payload. Use <code>{}</code> 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: | ||
| + | |||
| + | <pre> | ||
| + | { | ||
| + | Success: true, | ||
| + | Message: null, // error text when Success is false | ||
| + | Body: { ... } // endpoint-specific payload | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | === Request === | ||
<syntaxhighlight lang="JavaScript" line> | <syntaxhighlight lang="JavaScript" line> | ||
| − | |||
fetch('/api/data/person', { | fetch('/api/data/person', { | ||
method:'POST', | method:'POST', | ||
headers:{'Content-Type': 'application/json'}, | headers:{'Content-Type': 'application/json'}, | ||
body: JSON.stringify({ | body: JSON.stringify({ | ||
| − | + | ApiKey:'<Private key>', | |
| − | + | FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', // value of f in your URL | |
| − | FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', // | ||
Body: { | Body: { | ||
| − | + | FirstName: "Jane", | |
| − | + | LastName: "Smith", | |
| − | + | Email: "jsmith@example.edu", | |
| − | + | Email1: "jsmith.alt@example.edu", | |
| − | + | Phone: "801-555-0200", | |
| − | + | Phone1: "801-555-0201", | |
| − | + | Address: "12 Oak St", | |
| − | + | Address2: "", | |
| − | + | City: "Ogden", | |
| − | + | State: "UT", | |
| − | + | Zip: "84401", | |
| − | + | Role: "Teacher", // Teacher | Judge | Staff | Admin | Volunteer | Student | |
| − | + | Username: "jsmith", // optional | |
| − | + | Password: "temp-pass", // optional | |
| − | + | RequirePasswordChange: true, | |
| + | SchoolsTeachesAt: [24], // school ids for teachers | ||
| + | Prefix: "Dr", | ||
| + | MiddleName: "A", | ||
| + | Gender: "F", | ||
| + | Race: "", | ||
| + | Ethnicity: "", | ||
| + | FullLegalName: "Jane A Smith", | ||
| + | DateOfBirth: null, | ||
| + | HighestLevelOfEducation: "MS", | ||
| + | JobTitle: "Science Teacher", | ||
| + | Employer: "Example School", | ||
| + | ExternalId: "HR-123", | ||
| + | IsSpecialAwardJudge: false, | ||
| + | IsInterpreter: false, | ||
| + | IsModerator: false, | ||
| + | Language: "Spanish", | ||
| + | JudgesPreferences: { // optional, for judges | ||
| + | Category1: 12, | ||
| + | Category2: 13, | ||
| + | Category3: null, | ||
| + | PreviouslyJudged: true, | ||
| + | JudgingSessions: [1, 2] | ||
| + | } | ||
| + | } | ||
}) | }) | ||
}) | }) | ||
| Line 32: | Line 84: | ||
.then(data=>{console.log('Success: ',data);}) | .then(data=>{console.log('Success: ',data);}) | ||
.catch((error)=>{console.log('Error: ', error);}); | .catch((error)=>{console.log('Error: ', error);}); | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | === Response === | ||
| + | On success <code>Body</code> echoes the person with assigned <code>Id</code> and <code>Username</code>: | ||
| + | |||
| + | <pre> | ||
| + | { | ||
| + | Success: true, | ||
| + | Message: null, | ||
| + | Body: { Id: "person-guid", Username: "jsmith", FirstName: "Jane", ... } | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | === Field notes === | ||
| + | * <code>Role</code> is applied after registration via role change. | ||
| + | * For judges, <code>JudgesPreferences</code> category ids and session ids must exist on the fair ([[API Get Info]]). | ||
| + | * Special award judges with an <code>Employer</code> may get a virtual room named after the employer. | ||
| + | * Students on projects are usually created via [[API Add Project]] participants rather than this endpoint. | ||
| − | |||
| + | === Related APIs === | ||
| + | * [[API Get Teachers]] / [[API Get Judges]] | ||
| + | * [[API Get Info]] | ||
| + | * [[API Add Project]] | ||
| + | * [[API SSO]] | ||
| − | |||
| − | |||
| − | + | <br/><br/> | |
| − | + | [[Category: API]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 12:55, 25 July 2026
Contents
Add Person
Creates a person (teacher, judge, staff, admin, volunteer, or student placeholder) for the client/fair. Also supports judge preferences and optional roles.
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/person', {
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: {
FirstName: "Jane",
LastName: "Smith",
Email: "jsmith@example.edu",
Email1: "jsmith.alt@example.edu",
Phone: "801-555-0200",
Phone1: "801-555-0201",
Address: "12 Oak St",
Address2: "",
City: "Ogden",
State: "UT",
Zip: "84401",
Role: "Teacher", // Teacher | Judge | Staff | Admin | Volunteer | Student
Username: "jsmith", // optional
Password: "temp-pass", // optional
RequirePasswordChange: true,
SchoolsTeachesAt: [24], // school ids for teachers
Prefix: "Dr",
MiddleName: "A",
Gender: "F",
Race: "",
Ethnicity: "",
FullLegalName: "Jane A Smith",
DateOfBirth: null,
HighestLevelOfEducation: "MS",
JobTitle: "Science Teacher",
Employer: "Example School",
ExternalId: "HR-123",
IsSpecialAwardJudge: false,
IsInterpreter: false,
IsModerator: false,
Language: "Spanish",
JudgesPreferences: { // optional, for judges
Category1: 12,
Category2: 13,
Category3: null,
PreviouslyJudged: true,
JudgingSessions: [1, 2]
}
}
})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});Response
On success Body echoes the person with assigned Id and Username:
{
Success: true,
Message: null,
Body: { Id: "person-guid", Username: "jsmith", FirstName: "Jane", ... }
}
Field notes
Roleis applied after registration via role change.- For judges,
JudgesPreferencescategory ids and session ids must exist on the fair (API Get Info). - Special award judges with an
Employermay get a virtual room named after the employer. - Students on projects are usually created via API Add Project participants rather than this endpoint.
Related APIs