Expenses

Manage expenses

post
CREATE

https://api.pesatime.com/v1/expenses
Record a new expense
Request
Response
Request
Form Data Parameters
description
optional
string
Add any other information here
category
required
string
The category ID
date
required
string
The date of the expense in format YYYY-MM-DD HH:MM
amount
required
number
The expense amount
Response
200: OK
Category successfully created.
{
"status": 1,
"message": "Saved",
"data": {
"_id": "5dce4b8a4d44af36f693cd2b"
}
}
302: Found
Error
{
"status": 0,
"message": "Error message here"
}

put
UPDATE

https://api.pesatime.com/v1/expenses/:expenseId
Update an expense
Request
Response
Request
Path Parameters
expenseId
optional
string
The ID of the expense to update
Form Data Parameters
description
optional
string
New description for the exp
category
optional
string
The new category ID
date
optional
string
Date in format YYYY-MM-DD
amount
optional
number
The new amount
Response
200: OK
Success
{
"status": 1,
"message": "Expense updated successfully"
}
302: Found
Error
{
"status": 0,
"message": "Error description here"
}

get
RETRIEVE - All

https://api.pesatime.com/v1/expenses
Retrieves all expenses
Request
Response
Request
Path Parameters
expenseID
required
string
The ID of the expense to retrieve details for
Query Parameters
description
optional
string
Search part of the description
category
optional
string
The ID of the category
date_to
optional
string
Date expense incurred (YYYY-MM-DD) e.g. 2019-10-14
date_from
optional
string
Date expense incurred (YYYY-MM-DD) e.g. 2019-10-13
Response
200: OK
Success
{
"status": 1,
"data": [
{
"amount": 10001,
"active": true,
"_id": "5dce51d0bf6c524c59a75c96",
"organization": "5db5a64a6cb3e2060a7b864c",
"user": "5cded7f553ea376e8bba6bfd",
"category": {
"_id": "5cdfb75bb8f2b84e5fb55ce6",
"name": "Office supplies"
},
"description": "20 copies ",
"date": "2019-01-23T00:00:00.000Z",
"attachments": [],
"dateCreated": "2019-11-15T07:20:48.818Z",
"__v": 0
},
.......
]
}
302: Found
Expense not found
{
"status": 1,
"data": []
}

get
RETRIEVE - single item

https://api.pesatime.com/v1/expenses/:expenseId
Get details of one item
Request
Response
Request
Path Parameters
expenseId
optional
string
Id of the expense to get details for
Response
200: OK
{
"status": 1,
"data": {
"amount": 10001,
"active": true,
"_id": "5dce51d0bf6c524c59a75c96",
"organization": "5db5a64a6cb3e2060a7b864c",
"user": "5cded7f553ea376e8bba6bfd",
"category": {
"_id": "5cdfb75bb8f2b84e5fb55ce6",
"name": "Office supplies"
},
"description": "20 copies ",
"date": "2019-01-23T00:00:00.000Z",
"attachments": [],
"dateCreated": "2019-11-15T07:20:48.818Z",
"__v": 0
}
}
302: Found
Error
{
"status": 0,
"message": "Expense with this id was not found"
}

delete
DELETE

https://api.pesatime.com/v1/expenses/:expenseId
Delete a category
Request
Response
Request
Path Parameters
expenseId
required
string
The ID of the expense to delete
Response
200: OK
{
"status": 1,
"message": "Expense deleted successfully"
}
302: Found
{
"status": 0,
"message": "Error description"
}