# Students

## POST /students

> Create a new student.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students":{"post":{"tags":["Students"],"description":"Create a new student.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["site","first_name","last_name","location"],"properties":{"site":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"}}}}}},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"_id":{"type":"string"},"site":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"},"record_name":{"type":"string"},"type":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"photo_url":{"type":"string"}},"required":["_id","site","first_name","last_name","location","student_id","record_name","type","created_at","updated_at"]}}}}}}}}}
```

## DELETE /students/{siteId}/{userId}

> Delete a student from a site.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students/{siteId}/{userId}":{"delete":{"tags":["Students"],"description":"Delete a student from a site.","parameters":[{"schema":{"type":"string"},"in":"path","name":"siteId","required":true},{"schema":{"type":"string"},"in":"path","name":"userId","required":true}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}}}}}}}
```

## PATCH /students/{siteId}/{userId}

> Update a student.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students/{siteId}/{userId}":{"patch":{"tags":["Students"],"description":"Update a student.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["first_name","last_name","location"],"properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"},"welfare_flag":{"type":"boolean"},"flags":{"type":"array","items":{"type":"string"}},"welfare_state":{"type":["string","null"]}}}}}},"parameters":[{"schema":{"type":"string"},"in":"path","name":"siteId","required":true},{"schema":{"type":"string"},"in":"path","name":"userId","required":true}],"responses":{"200":{"description":"Default Response"}}}}}}
```

## GET /students/{site}/export-csv

> Export a list of students as a CSV file.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students/{site}/export-csv":{"get":{"tags":["Students"],"description":"Export a list of students as a CSV file.","parameters":[{"schema":{"type":"string","enum":["first_name","last_name","location"]},"in":"query","name":"sortBy","required":false},{"schema":{"type":"string"},"in":"path","name":"site","required":true}],"responses":{"200":{"description":"Default Response"}}}}}}
```

## GET /students/{site}/export

> Export a list of students as a PDF.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students/{site}/export":{"get":{"tags":["Students"],"description":"Export a list of students as a PDF.","parameters":[{"schema":{"type":"string","enum":["first_name","last_name","location"]},"in":"query","name":"sortBy","required":false},{"schema":{"type":"boolean","default":false},"in":"query","name":"includePhoto","required":false},{"schema":{"type":"string"},"in":"path","name":"siteId","required":true}],"responses":{"200":{"description":"Default Response"}}}}}}
```

## POST /students/{site}/import

> Import a list of students.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students/{site}/import":{"post":{"tags":["Students"],"description":"Import a list of students.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"students":{"type":"array","items":{"type":"object","required":["first_name","last_name","location"],"properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"}}}},"type":{"type":"string","enum":["full","partial"]}},"required":["students","type"]}}}},"parameters":[{"schema":{"type":"string"},"in":"path","name":"site","required":true}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"students":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"},"site":{"type":"string"},"active":{"type":"boolean"}}},"required":["_id","first_name","last_name","location","student_id","site","active"]},"exceptions":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"},"cause":{"type":"string"},"existing_record_id":{"type":"string"}},"required":["first_name","last_name","location","student_id","cause"]}}}}}}}}}}}}
```

## GET /students/{siteId}

> Retrieve all students from a site.

```json
{"openapi":"3.0.3","info":{"title":"Incident Tracker API","version":"1.0.0"},"servers":[{"url":"https://api.kitehouse.co.uk"}],"paths":{"/students/{siteId}":{"get":{"tags":["Students"],"description":"Retrieve all students from a site.","parameters":[{"schema":{"type":"string"},"in":"path","name":"siteId","required":true}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"record_name":{"type":"string"},"location":{"type":"string"},"student_id":{"type":"string"},"floor":{"type":"string"},"email":{"type":"string"},"photo_url":{"type":"string"},"site":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"active":{"type":"boolean"},"welfare_flag":{"type":"boolean"},"flags":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"},"colour":{"type":"string"}},"required":["_id","name","colour"]}},"welfare_state":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"},"colour":{"type":"string"}},"required":["_id","name","colour"]}},"required":["_id","first_name","last_name","record_name","location","site","created_at","updated_at","type","active","welfare_flag"]}}}}}}}}}}
```
