All data sent and received is in JSON format. All responses are in Jsend format. This is the baseURL for all endpoints.
POST Login a user
Allows an authorized user to login.The body is a json object as sampled below. The login method gives the user a token that enables them to perfom some of the routes/endpoints enlisted below.
Sample Request
curl --request POST
url
/api/users/login
Sample data
{
"email": "mercy.muchai@andela.com"
}
Sample Response
{
"message": "You were successfully logged in",
"user": {
"id": "U7LHY6W4B",
"email": "mercy.muchai@andela.com",
"username": "Mercy Muchai",
"imageUrl": "https://secure.gravatar.com/avatar/cf493cf28e96f654602b2f71e4d655e2.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0003-48.png",
"createdAt": "2018-05-06T09:00:48.164Z",
"updatedAt": "2018-05-06T09:00:48.164Z",
"locationId": "cjee24xnn0000i2xsh9qauyn5",
"roleId": 2
},
"userToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlU3TEhZNlc0QiIsInJvbGVJZCI6MiwiaWF0IjoxNTI1NTk3NzUzLCJleHAiOjE1MjU2ODQxNTN9.mZOVACZrDguQklJZXx57Eu2rNTMF9hMoYEYf74Pxozo",
"expiresIn": "24h"
}
POST Incident
Allows a user to post an incident. The body is a json object as sampled below. Some of the values can be left out when posting. These include: witnesses and levelId
Sample Request
curl --request POST
url
/api/incidents
Sample data
{
"subject": "Harrassment",
"description": "something happened and I didnt like it at all",
"dateOccurred": "12-7-2017",
"incidentReporter": {
"userId": "brian",
"email": "brian@g.com",
"username": "brian",
"imageUrl": "brian.jpeg",
"reporterLocation": {"name": "Again", "centre": "Nairobi", "country": "Kenya"}
},
"location": {
"name": "bottle",
"centre": "lagos",
"country": "kenya"
},
"witnesses": [
{
"userId": "2nd",
"email": "person2@gmail.com",
"username": "person2",
"imageUrl": "person2.jpeg",
"witnessLocation": {"name": "new", "centre": "Nairobi", "country": "Kenya"}
},
{
"userId": "3rd",
"email": "person3@gmail.com",
"username": "person3",
"imageUrl": "person3.jpeg",
"witnessLocation": {"name": "Another", "centre": "Nairobi", "country": "Kenya"}
}
]
}
The response of the POST method is similar to a GET incident method below.
GET Incidents
To get all existing incidents
curl --request GET
url
/api/incidents
Sample Response
{
"data": {
"incidents": [
{
"id": "cjgxo8kr400010w3kypkj24hv",
"description": "something happened and I didnt like it at all",
"subject": "Harrassment",
"dateOccurred": "2017-07-12T00:00:00.000Z",
"createdAt": "2018-05-08T12:48:49.936Z",
"updatedAt": "2018-05-08T12:48:49.936Z",
"categoryId": null,
"statusId": 1,
"locationId": "cjgxo8kqc00000w3kxjh1gf31",
"levelId": 3,
"Level": {
"name": "Green"
},
"Status": {
"status": "Pending"
},
"Location": {
"name": "bottle",
"centre": "lagos",
"country": "kenya"
},
"assignees": [],
"reporter": {
"id": "brian",
"email": "brian@g.com",
"username": "brian",
"imageUrl": "brian.jpeg",
"createdAt": "2018-05-08T12:48:49.967Z",
"updatedAt": "2018-05-08T12:48:49.967Z",
"locationId": "cjgxo8krj00020w3k8oenlg5k",
"roleId": 1
},
"witnesses": [
{
"id": "3rd",
"email": "person3@g.com",
"username": "person3",
"imageUrl": "person3.jpeg",
"createdAt": "2018-05-08T12:48:50.039Z",
"updatedAt": "2018-05-08T12:48:50.039Z",
"locationId": "cjgxo8kte00040w3k6v96gwes",
"roleId": 1
},
{
"id": "2nd",
"email": "person2@g.com",
"username": "person2",
"imageUrl": "person2.jpeg",
"createdAt": "2018-05-08T12:48:50.027Z",
"updatedAt": "2018-05-08T12:48:50.027Z",
"locationId": "cjgxo8ksw00030w3kz0r2inkn",
"roleId": 1
}
]
},
{
"id": "cjfkubrlv0001tgxs3mre",
"description": "Someone said some things to me I cannot even type",
"subject": "Abusive Language",
"dateOccurred": "2017-12-10T00:00:00.000Z",
"createdAt": "2018-05-08T08:19:00.958Z",
"updatedAt": "2018-05-08T08:19:00.958Z",
"categoryId": 2,
"statusId": 2,
"locationId": "cjee256gt0000ioxs69v4870x",
"levelId": 1,
"Level": {
"name": "Red"
},
"Status": {
"status": "In Progress"
},
"Location": {
"name": "Bootcamp Room",
"centre": "Kampala",
"country": "Uganda"
},
"assignees": [],
"reporter": {
"id": "U7LHY6W4B",
"email": "mercy.muchai@andela.com",
"username": "Mercy Muchai",
"imageUrl": "https://secure.gravatar.com/avatar/cf493cf28e96f654602b2f71e4d655e2.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0003-48.png",
"createdAt": "2018-05-08T08:19:02.241Z",
"updatedAt": "2018-05-08T08:19:02.241Z",
"locationId": "cjee24xnn0000i2xsh9qauyn5",
"roleId": 2
},
"witnesses": [
{
"id": "U7LEPG8LF",
"email": "batian.muthoga@andela.com",
"username": "Batian Muthoga",
"imageUrl": "https://avatars.slack-edge.com/2018-01-31/308111298950_b15a779680c4d2bb093c_48.png",
"createdAt": "2018-05-08T08:19:02.241Z",
"updatedAt": "2018-05-08T08:19:02.241Z",
"locationId": "cjee24xnn0000i2xsh9qauyn5",
"roleId": 2
}
]
},
{
"id": "cjfkubrlv0001tsjksuis3",
"description": "Someone said something that was discriminative to my gender",
"subject": "Discrimination",
"dateOccurred": "2018-02-03T00:00:00.000Z",
"createdAt": "2018-05-08T08:19:00.958Z",
"updatedAt": "2018-05-08T08:19:00.958Z",
"categoryId": 15,
"statusId": 3,
"locationId": "cjee241h20000g7xsfzd572sl",
"levelId": 3,
"Level": {
"name": "Green"
},
"Status": {
"status": "Resolved"
},
"Location": {
"name": "Cafeteria",
"centre": "Nairobi",
"country": "Kenya"
},
"assignees": [],
"reporter": {
"id": "U7LEPG8LF",
"email": "batian.muthoga@andela.com",
"username": "Batian Muthoga",
"imageUrl": "https://avatars.slack-edge.com/2018-01-31/308111298950_b15a779680c4d2bb093c_48.png",
"createdAt": "2018-05-08T08:19:02.241Z",
"updatedAt": "2018-05-08T08:19:02.241Z",
"locationId": "cjee24xnn0000i2xsh9qauyn5",
"roleId": 2
},
"witnesses": [
{
"id": "U7LHY6W4B",
"email": "mercy.muchai@andela.com",
"username": "Mercy Muchai",
"imageUrl": "https://secure.gravatar.com/avatar/cf493cf28e96f654602b2f71e4d655e2.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0003-48.png",
"createdAt": "2018-05-08T08:19:02.241Z",
"updatedAt": "2018-05-08T08:19:02.241Z",
"locationId": "cjee24xnn0000i2xsh9qauyn5",
"roleId": 2
}
]
}
]
},
"status": "success"
}
GET one Incident
To get one existing incident
curl --request GET
url
/api/incidents/<incidentId>
PUT Incident
This endpoint is made use of when updating an assignee to an incident. Can only take one assignee and multiple CCD users. It's also made use of when updating the status from Pending to In progress/Resolved or the level.
curl --request PUT
url
/api/incidents/<incidentId>
Sample Request
{
"assignee":
{
"userId": "abcdef"
}
}
It can also be an array of users to CC. i.e
{
"ccd":
[
{
"userId": "abcdef"
},
{
"userId": "ijklm"
}
]
}
It could also be:
{
"levelId": "2",
"statusId": "2"
}
POST chat
Allows a user to post a chat.
Sample Request
curl --request POST
url
/api/incidents/<incidentId>/chats
Sample data
{
"userEmail": "batian.muthoga@andela.com",
"chat": "chat1"
}
GET chats
To get all existing chats to an incident
curl --request GET
url
/api/incidents/<incidentId>/chats
Sample Response
{
"data": {
"chats": [
{
"id": "cjfjgiroz0001lexs5h8kx4d5",
"chat": "New note",
"createdAt": "2018-04-03T09:24:19.763Z",
"updatedAt": "2018-04-03T09:24:19.763Z",
"incidentId": "cjfcbhngw00013dxsfm2nufln",
"userEmail": "batian.muthoga@andela.com",
"User": {
"id": "U7LEPG8LF",
"imageUrl": "https://avatars.slack-edge.com/2018-01-31/308111298950_b15a779680c4d2bb093c_48.png",
"username": "Batian Muthoga"
}
}
]
},
"status": "success"
}
GET one chat
To get one chat on a specific incident.
curl --request GET
url
/api/chats/<chatId>
PUT chat
Allows a user to edit a chat using the chat id.
Sample Request
curl --request PUT
url
/api/chats/<chatId>
Sample data
{
"userEmail": "batian.muthoga@andela.com",
"chat": "edited chat1"
}
DELETE chat
Allows a user to delete a chat posted using the chat id.
Sample Request
curl --request DELETE
url
/api/chats/<chatId>
POST note
Allows a user to post a note on an incident.
Sample Request
curl --request POST
url
/api/incidents/<incidentId>/notes
Sample data
{
"userEmail": "batian.muthoga@andela.com",
"note": "This is a sample note"
}
GET notes
To get all existing notes to an incident
curl --request GET
url
/api/incidents/<incidentId>/notes
Sample Response
{
"data": {
"notes": [
{
"id": "cjfcblwwx00023dxsr13zj408",
"note": "New note",
"createdAt": "2018-03-29T09:32:25.185Z",
"updatedAt": "2018-03-29T09:32:25.185Z",
"incidentId": "cjfcbhngw00013dxsfm2nufln",
"userEmail": "batian.muthoga@andela.com",
"User": {
"id": "U7LEPG8LF",
"imageUrl": "https://avatars.slack-edge.com/2018-01-31/308111298950_b15a779680c4d2bb093c_48.png",
"username": "Batian Muthoga"
}
}
]
},
"status": "success"
}
GET one note
To get a specific note to an existing incident
curl --request GET
url
/api/notes/<noteId>
PUT note
Allows a user to edit a note using the note id.
Sample Request
curl --request PUT
url
/api/notes/<noteId>
Sample data
{
"userEmail": "batian.muthoga@andela.com",
"note": "edited sample note"
}
DELETE note
Allows a user to delete a note posted using the note id.
Sample Request
curl --request DELETE
url
/api/notes/<noteId>