Create an Expense
curl --request POST \
--url https://cashboard-f5x2.onrender.com/expense/add \
--header 'Content-Type: application/json' \
--data '
{
"desc": "Electricity bill",
"category": "Utility",
"account": "662fbf9eac827e370c18d4b9",
"date": "2/04/2024",
"amount": 1000
}
'import requests
url = "https://cashboard-f5x2.onrender.com/expense/add"
payload = {
"desc": "Electricity bill",
"category": "Utility",
"account": "662fbf9eac827e370c18d4b9",
"date": "2/04/2024",
"amount": 1000
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
desc: 'Electricity bill',
category: 'Utility',
account: '662fbf9eac827e370c18d4b9',
date: '2/04/2024',
amount: 1000
})
};
fetch('https://cashboard-f5x2.onrender.com/expense/add', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cashboard-f5x2.onrender.com/expense/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'desc' => 'Electricity bill',
'category' => 'Utility',
'account' => '662fbf9eac827e370c18d4b9',
'date' => '2/04/2024',
'amount' => 1000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cashboard-f5x2.onrender.com/expense/add"
payload := strings.NewReader("{\n \"desc\": \"Electricity bill\",\n \"category\": \"Utility\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"2/04/2024\",\n \"amount\": 1000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cashboard-f5x2.onrender.com/expense/add")
.header("Content-Type", "application/json")
.body("{\n \"desc\": \"Electricity bill\",\n \"category\": \"Utility\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"2/04/2024\",\n \"amount\": 1000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cashboard-f5x2.onrender.com/expense/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"desc\": \"Electricity bill\",\n \"category\": \"Utility\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"2/04/2024\",\n \"amount\": 1000\n}"
response = http.request(request)
puts response.read_body{
"expenses": [
{
"desc": "Electricity bill",
"category": "Utility",
"date": "2024-02-04T00:00:00.000Z",
"account": "662fbf9eac827e370c18d4b9",
"amount": 1000,
"_id": "662fce008f1d17198913a0ab"
}
]
}{
"status": "error",
"message": "Expense not added"
}Expenses
Create an Expense
This endpoint is used to add an expense for a specific user.
Endpoint: https://cashboard-f5x2.onrender.com/expense/add
Query: User’s UUID
The request body should be a JSON object that includes:
- desc (string): Description of the expense
- category (string): Category of the expense
- account (string): The Account ID that paid for the expense
- date (date): Date of the expense
- amount (number): Amount of the expense
The response to this request will be a JSON schema, with an array of the user’s expenses including the new entry.
Each expense object in the array will have the following properties:
- desc (string): Description of the expense
- category (string): Category of the expense
- date (string): Date of the expense
- account (string): Account associated with the expense
- amount (number): Amount of the expense
- _id (string): Unique identifier for the expense
POST
/
expense
/
add
Create an Expense
curl --request POST \
--url https://cashboard-f5x2.onrender.com/expense/add \
--header 'Content-Type: application/json' \
--data '
{
"desc": "Electricity bill",
"category": "Utility",
"account": "662fbf9eac827e370c18d4b9",
"date": "2/04/2024",
"amount": 1000
}
'import requests
url = "https://cashboard-f5x2.onrender.com/expense/add"
payload = {
"desc": "Electricity bill",
"category": "Utility",
"account": "662fbf9eac827e370c18d4b9",
"date": "2/04/2024",
"amount": 1000
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
desc: 'Electricity bill',
category: 'Utility',
account: '662fbf9eac827e370c18d4b9',
date: '2/04/2024',
amount: 1000
})
};
fetch('https://cashboard-f5x2.onrender.com/expense/add', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cashboard-f5x2.onrender.com/expense/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'desc' => 'Electricity bill',
'category' => 'Utility',
'account' => '662fbf9eac827e370c18d4b9',
'date' => '2/04/2024',
'amount' => 1000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cashboard-f5x2.onrender.com/expense/add"
payload := strings.NewReader("{\n \"desc\": \"Electricity bill\",\n \"category\": \"Utility\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"2/04/2024\",\n \"amount\": 1000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cashboard-f5x2.onrender.com/expense/add")
.header("Content-Type", "application/json")
.body("{\n \"desc\": \"Electricity bill\",\n \"category\": \"Utility\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"2/04/2024\",\n \"amount\": 1000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cashboard-f5x2.onrender.com/expense/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"desc\": \"Electricity bill\",\n \"category\": \"Utility\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"2/04/2024\",\n \"amount\": 1000\n}"
response = http.request(request)
puts response.read_body{
"expenses": [
{
"desc": "Electricity bill",
"category": "Utility",
"date": "2024-02-04T00:00:00.000Z",
"account": "662fbf9eac827e370c18d4b9",
"amount": 1000,
"_id": "662fce008f1d17198913a0ab"
}
]
}{
"status": "error",
"message": "Expense not added"
}Query Parameters
required
Body
application/json
The body is of type object.
Response
OK
The response is of type object.

