Api Usage
This page provides a detailed explanation of how to use the Occupi API. The Occupi API is a RESTful API that allows you to interact with the Occupi platform programmatically. The API provides endpoints for creating, reading, updating, and deleting resources. The API also allows you to retrieve information about these resources.
Table of Contents
- Api Usage
- Table of Contents
- Base URL
- Api
- Resources
- Book Room
- View Bookings
- View Rooms
- Cancel Booking
- Check In
- Get User Details
- Update User Details
- Get Users
- Get Notifications
- Get push tokens
- UpdateSecuritySettings
- Get Security Settings
- Update Notification Settings
- Get Notification Settings
- Upload Profile Image
- Download Profile Image
- Delete Profile Image
- Image ID
- Upload Image
- Upload Room Image
- Delete Room Image
- Add Room
- Available slots
- Toggle on site
- Create user
- Get IP information
- Add IP Address
- Remove IP Address
- Toggle Allow Anonymous IP
Base URL
The base URL for the Occupi API is https://occupi.tech
, https://dev.occupi.tech
or http://localhost:8080
if you are in develop mode.
Api
The API endpoints are used to interact with the Occupi platform. Mainly GET, POST, PUT, DELETE requests are used.
Resources
The resources endpoints are used to create, read, update, and delete resources.
-
URL
/api/resources
-
Method
GET
-
Success Response
- Code: 200
- Content:
{ "message": "Resources fetched successfully" }
-
Error Response
- Code: 400
- Content:
{ "message": "Bad Request" }
-
Error Response
- Code: 500
- Content:
{ "message": "Internal server error" }
Example json to send:
{}
BookRoom
This endpoint is used to book a room in the Occupi system. The client needs to provide the room ID, slot, a list of email addresses, the creator's email, and the floor number. Upon a successful booking, a unique booking ID is generated, and a confirmation email is sent to all specified recipients. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/book-room
-
Method
POST
-
Request Body
-
Content
{
"roomId": "string",
"emails": ["string"],
"creator": "string",
"floorNo": "integer",
"date": "string",
"start": "string",
"end": "string"
}
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully booked!", "data": {"1234567890"}, }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"missing field required: <name of field>"}, }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to save booking", "error": {"code":"INTERNAL_SERVER_ERROR","details":"Failed to save booking","message":"Failed to save booking"} }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to send confirmation emails", "error": {"code":"INTERNAL_SERVER_ERROR","details":"Failed to send confirmation emails","message":"Failed to send confirmation emails"} }
ViewBookings
This endpoint is used to view all bookings made by a user. The client needs to provide the user's email address. Upon a successful request, a list of all bookings made by the user is returned. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/view-bookings
-
Method
GET
-
Request Body
-
Content
{
"operator": "eq", // eq, ne, gt, gte, lt, lte, in, nin default to eq
"filter": {
"email": "[email protected]" // the email is required
},
"order_asc": "creator", // column to sort in ascending order
"order_desc": "floor", // column to sort in descending order
"projection": ["floor"], // this is which columns you want returned
"limit": 50, // default is 50 and is the maximum
"page": 1 // default is 1, but can be incremented to get the next page
}
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully fetched bookings!", "data": null }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Expected Email Address"}, }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to get bookings", "error": {"code":"INTERNAL_SERVER_ERROR","details":"Failed to get bookings","message":"Failed to get bookings"} }
View Rooms
This endpoint is used to view all rooms in the Occupi system. Upon a successful request, a list of all rooms is returned.
-
URL
/api/view-rooms
-
Method
GET
-
Request Body
-
Content
{
"operator": "eq", // eq, ne, gt, gte, lt, lte, in, nin default to eq
"filter": {
"floorNo": 3 // this is a filter to filter by
},
"order_asc": "description", // column to sort in ascending order
"order_desc": "floor", // column to sort in descending order
"projection": ["floor"], // this is which columns you want returned
"limit": 50, // default is 50 and is the maximum
"page": 1 // default is 1, but can be incremented to get the next page
}
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully fetched bookings!", "data": null }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Expected Email Address"}, }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to get bookings", "error": {"code":"INTERNAL_SERVER_ERROR","details":"Failed to get bookings","message":"Failed to get bookings"} }
CancelBooking
This endpoint is used to cancel a booking made by a user. The client needs to provide the booking ID and the person who booked. Upon a successful request, the booking is canceled, and a confirmation email is sent to all recipients. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/cancel-booking
-
Method
POST
-
Request Body
-
Content
{
"bookingId": "string",
"roomId": "string",
"emails": ["string"],
"creator": "string",
"floorNo": "integer",
"date": "string",
"start": "string",
"end": "string"
}
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully cancelled booking!", "data":null }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"missing field required: <name of field>"}, }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Invalid JSON payload"}, }
Error Response
- Code: 404
- Content:
{ "status": 404, "message": "Booking not found", "error": {"code":"BAD_REQUEST","details":null,"message":"Booking not found"}, }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to cancel booking", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to save booking"} }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Failed to send confirmation emails", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"An error occured"} }
CheckIn
This endpoint is used to check-in a user who has booked a room. The client needs to provide the booking ID and their email. Upon a successful request, the user is checked in. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/check-in
-
Method
POST
-
Request Body
-
Content
{
"bookingId": "string",
"email": "string"
}
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully checked in!", "data":null }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"missing field required: <name of field>"}, }
Error Response
- Code: 404
- Content:
{ "status": 404, "message": "Booking not found", "error": {"code":"BAD_REQUEST","details":null,"message":"Booking not found"}, }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to check in", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to checkin"} }
GetUserDetails
This endpoint is used to view the details of a user in the Occupi system. Upon a successful request, the details of the user are returned. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/[email protected]
-
Method
GET
-
Request Body
-
Content
{
"email": "string"
}
if you are logged in, the email is not required, it will be fetched from the token, but passing in an email allows you to fetch details for any user
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully fetched user details!", "data": {"user details"} }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"missing field required: <name of field>"}, }
Error Response
- Code: 404
- Content:
{ "status": 404, "message": "User not found", "error": {"code":"BAD_REQUEST","details":null,"message":"User not found"} }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to get user details", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to get user details"} }
UpdateUserDetails
This endpoint is used to update the details of a user in the Occupi system. The client needs to provide the user's email address and the details to be updated. Upon a successful request, the user's details are updated. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/update-user
-
Method
POST
-
Request Body
-
Content
-
Add fields that you want to update. Always include session_email field.
{
"email": "[email protected]", //new email to update to, this will set verification status to false, meaning when you login again, you'll have to verify the email
"name": "john doe",
"dob": "2002-03-08 00:00:00 +0000 UTC",
"gender": "male",
"session_email": "[email protected]", // this is the email we use to identify you in the system
"employeeid": "OCCUPI20240000",
"number": "000 000 0000",
"pronouns": "he/him"
}
Success Response
- Code: 200
- Content:
{ "status": 200, "message": "Successfully updated user details!", "data": nil }
Error Response
- Code: 400
- Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"missing field required: <name of field>"}, }
Error Response
- Code: 404
- Content:
{ "status": 404, "message": "User not found", "error": {"code":"BAD_REQUEST","details":null,"message":"User not found"} }
Error Response
- Code: 500
- Content:
{ "status": 500, "message": "Failed to update user details", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to update user details"} }
Get Users
This endpoint is used to get users in the Occupi system. The client can provide a filter criteria if they want to. Upon a successful request, a list of users that match the filter criteria is returned. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/get-users
-
Method
GET
-
Request Body
-
Content
{
"operator": "eq", // eq, ne, gt, gte, lt, lte, in, nin default to eq
"filter": {
"onSite": true // this is a filter to filter by
},
"order_asc": "role", // column to sort in ascending order
"order_desc": "email", // column to sort in descending order
"projection": ["email", "role"], // this is which columns you want returned
"limit": 50, // default is 50 and is the maximum
"page": 1 // default is 1, but can be incremented to get the next page
}
or as a url(note that the order in which you place the parameters does not matter, place them as you please)
https://dev.occupi.tech/api/filter-users?filter={"onSite": true}&projection=email,role&limit=50&page=1
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched users!", "data": ["list of all users"], "meta": {"currentPage": 1,"totalPages": 20,"totalResults": 7}, }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Failed to get users", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to get users"} }
Get Notifications
This endpoint is used to get notifications in the Occupi system. The client can provide a filter criteria if they want to. Upon a successful request, a list of notifications that match the filter criteria is returned. If there are any errors during the process, appropriate error messages are returned.
-
URL
/api/get-notifications
-
Method
GET
-
Request Body
-
Content
{
"operator": "eq", // eq, ne, gt, gte, lt, lte, in, nin default to eq
"filter": {
"emails": ["[email protected]"] // this is a filter to filter by
},
"order_asc": "message", // column to sort in ascending order
"order_desc": "title", // column to sort in descending order
"projection": ["message", "title", "unreadEmails"], // this is which columns you want returned
"limit": 50, // default is 50 and is the maximum
"page": 1 // default is 1, but can be incremented to get the next page
}
or as a url(note that the order in which you place the parameters does not matter, place them as you please)
https://dev.occupi.tech/api/get-notifications?filter={"emails": ["[email protected]"]}&projection=message,title,unreadEmails&limit=50&page=1
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched notifications!", "data": ["list of all notifications"], "meta": {"currentPage": 1,"totalPages": 20,"totalResults": 7}, }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Failed to get notifications", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to get notifications"} }
Get push tokens
This endpoint is used to get the expo push tokens for the given emails
-
URL
/api/get-push-tokens
-
Method
GET
-
Request Body
-
Content
{
"emails": ["[email protected]"]
}
or as a url(note that the order in which you place the parameters does not matter, place them as you please)
https://dev.occupi.tech/api/[email protected],[email protected],[email protected]
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched tokens!", "data": ["list of all tokens"] }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Failed to get tokens", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to get tokens"} }
UpdateSecuritySettings
This endpoint is used to update the security settings of a user in the Occupi system.
-
URL
/api/update-security-settings
-
Method
POST
-
Request Body
-
Content
{
"email": "[email protected]", // required
"mfa": "on", // optional "on" or "off"
"currentPassword": "password", // required if "newPassword" and "newPasswordConfirm" are provided
"newPassword": "newPassword", // required if "currentPassword" and "newPasswordConfirm" are provided
"newPasswordConfirm": "newPassword" // required if "currentPassword" and "newPassword" are provided
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully updated security settings!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to update settings"} }
GetSecuritySettings
This endpoint is used to get the security settings of a user in the Occupi system.
-
URL
/api/get-security-settings
-
Method
GET
-
Request Body
-
Content
{
"email": "[email protected]", // required
}
or
/api/[email protected]
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched security settings!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to update settings"} }
UpdateNotificationSettings
This endpoint is used to update the notification settings of a user in the Occupi system.
-
URL
/api/update-notification-settings
-
Method
GET
-
Request Body
-
Content
{
"email": "[email protected]", // required
"invites": "on", // optional "on" or "off"
"bookingReminder": "on", // optional "on" or "off"
}
or
/api/[email protected]&invites=on&bookingReminder=on
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully updated notification settings!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to update settings"} }
GetNotificationSettings
This endpoint is used to get the notification settings of a user in the Occupi system.
-
URL
/api/get-notification-settings
-
Method
GET
-
Request Body
-
Content
{
"email": "[email protected]", // required
}
or
/api/[email protected]
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched notification settings!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Failed to update settings"} }
UploadProfileImage
This endpoint is used to upload a profile image for a user in the Occupi system. Images must be in jpg, jpeg, or png format otherwise an error will be returned.
-
URL
/api/upload-profile-image
-
Method
POST
-
Send request as Form-Data NOT JSON body or url parameters
-
Content
"image": image_data, // required
"email": "[email protected]" // optional if you are logged in
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully uploaded image!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
DownloadProfileImage
This endpoint is used to download a profile image for a user in the Occupi system.
-
URL
/api/download-profile-image
-
Method
GET
-
Request JSON Data
-
Content
"email": "[email protected]" // optional if you are logged in
"quality": "mid" // optional, can be "thumbnail", "low", "medium", "high but defaults to mid
or
/api/[email protected]&quality=mid
note that the higher quality, the longer it will take to download
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched image!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
DeleteProfileImage
This endpoint is used to delete a profile image for a user in the Occupi system.
-
URL
/api/delete-profile-image
-
Method
DELETE
-
Request JSON Data
-
Content
"email": "[email protected]" // optional if you are logged in
or
/api/[email protected]
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully deleted image!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Image ID
This endpoint is used to get the image in the Occupi system given an image ID as a url parameter.
-
URL
/api/image/:id
-
Method
GET
-
Request JSON Data
-
Content
"quality": "mid" // optional, can be "thumbnail", "low", "medium", "high but defaults to mid
or
/api/image/000000000000000000?quality=mid
the id is the id of the image which you will get when you get a room and is required for all requests on this endpoint alternatively, if the id is not known, you pass null and the system will return the default image eg /api/image/null?quality=mid
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched image!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Upload Room Image
This endpoint is used to upload an image for a room in the Occupi system. Only Admins can upload images.
-
URL
/api/upload-room-image
-
Method
POST
-
Request Form Data
-
Content
"image": image_data, // required
"roomId": "RM000" // required
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully uploaded image!", "data": {"id": "000000000000000000000"} }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Delete Room Image
This endpoint is used to delete an image for a room in the Occupi system. Only Admins can delete images.
-
URL
/api/delete-room-image
-
Method
DELETE
-
Request JSON Data
-
Content
"roomId": "RM000" // required
"imageId": "000000000000000000000" // required
or
/api/delete-room-image?roomId=RM000&imageId=000000000000000000000
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully deleted image!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Add Room
This endpoint is used to add a room in the Occupi system. Only Admins can add rooms.
-
URL
/api/add-room
-
Method
PUT
-
Request Body
-
Content
{
"roomId": "RM000", // required ensure that the room id is unique and starts with RM and no room with the same id exists
"roomNo": "1", // required ensure that the room number is unique and no room with the same number exists
"floorNo": 3, // required
"minOccupancy": 1, // required
"maxOccupancy": 10, // required
"description": "This is a room", // required
"resources": ["projector", "whiteboard"], // required
"roomName": "Room 1", // required
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully added room!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Available Slots
This endpoint is used to get the available slots for a room in the Occupi system.
-
URL
/api/available-slots
-
Method
GET
-
Request Body
-
Content
{
"roomId": "RM000", // required
"date": "2024-07-01T00:00:00.000Z", // required
}
or
/api/available-slots?roomId=RM000&date=2024-07-01T00:00:00.000Z
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched available slots!", "data": ["list of available slots"] }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Error Response
-
Code: 400
-
Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Invalid JSON payload"} }
Toggle On Site
This endpoint is used to toggle the on site status of a user in the Occupi system. That is whether or not they are in the office Just some notes about this endpoint:
-
If the user is on site, they cannot become on site again and vice versa
-
If the user tries to toggle their status outside of office hours (8am - 5pm)Monday to Friday, they will not be able to do so
-
If the user forgets to toggle their status, the system will automatically limit their hours for the day they had forgotten to toggle their status to 5pm
-
URL
/api/toggle-onsite
-
Method
PUT
-
Request Body
-
Content
{
"email": "[email protected]", // this is not explicitly required as it can be determined by the system
"onSite": "Yes" // required, can be "Yes" or "No" (exact match)
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully toggled on site status!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Error Response
-
Code: 400
-
Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Invalid JSON payload"} }
Create User
This endpoint is used to create a user in the Occupi system. Only Admins can create users.
-
URL
/api/create-user
-
Method
POST
-
Request Body
-
Content
{
"employee_id": "OCCUPI20240000", // required
"password": "password", // required
"email": "[email protected]", // required
"role": "admin", // optional or you can set the role to "basic" but defaults to "basic"
"details": {
"contactNo": "000 000 0000", // optional
"name": "John Doe", // optional
"dob": "2002-03-08 00:00:00 +0000 UTC", // optional defaults to current
"gender": "Male", // optional
"pronouns": "he/him" // optional
},
"notifications": {
"invites": "on", // optional
"bookingReminder": "on" // optional
},
"status": "active", // optional
"position": "Software Engineer", // optional
"departmentNo": 1, // optional
"expoPushToken": "ExponentPushToken[000000000000000000000000]", // optional
"blockAnonymousIPAddress": false // optional, this blocks this account from adding new login locations
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully created user!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Get IP Information
This endpoint is used to get the IP information of this IP address(which is currently your real IP address). Only Admins can get IP information.
-
URL
/api/get-ip-info
-
Method
GET
-
Request Body
-
Content
{
// your ip address is inferred from the request
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully fetched IP information!", "data": {"ip information"} }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Add IP Address
This endpoint is used to add an IP address to the Occupi system. Only Admins can add IP addresses.
-
URL
/api/add-ip
-
Method
POST
-
Request Body
-
Content
{
"ip": "10.0.0.4", // required
"emails": ["email 1", "email 2"] // required, these are the emails that can use this ip address for logging in
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully added IP address!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Delete IP Address
This endpoint is used to delete an IP address from the Occupi system. Only Admins can delete IP addresses.
-
URL
/api/remove-ip
-
Method
DELETE
-
Request Body
-
Content
{
"ip": "10.0.0.4", // required
"emails": ["email 1", "email 2"] // required, these are the emails that will not be able to use this ip for logging in anymore
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully removed IP address!", "data": null }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }
Toggle Allow anonymous IP
This endpoint is used to toggle the allow anonymous IP status of a user in the Occupi system. That is whether or not they can add new login locations
-
URL
/api/toggle-allow-anonymous-ip
-
Method
PUT
-
Request Body
-
Content
{
"emails": ["email 1", "email 2"], // required, these are the emails that will have their status toggled
"allowAnonymousIPAddress": true // required, can be true or false
}
Success Response
-
Code: 200
-
Content:
{ "status": 200, "message": "Successfully toggled allow anonymous IP status!", "data": null }
Error Response
-
Code: 400
-
Content:
{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Invalid JSON payload"} }
Error Response
-
Code: 500
-
Content:
{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }