Create Measurement
curl --request POST \
--url https://connect.withvayu.com/measurements \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customerId": "<string>",
"meterId": "<string>",
"usageDate": {
"year": 1,
"month": 6,
"day": 16
},
"value": 123
}
'import requests
url = "https://connect.withvayu.com/measurements"
payload = {
"customerId": "<string>",
"meterId": "<string>",
"usageDate": {
"year": 1,
"month": 6,
"day": 16
},
"value": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: '<string>',
meterId: '<string>',
usageDate: {year: 1, month: 6, day: 16},
value: 123
})
};
fetch('https://connect.withvayu.com/measurements', 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://connect.withvayu.com/measurements",
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([
'customerId' => '<string>',
'meterId' => '<string>',
'usageDate' => [
'year' => 1,
'month' => 6,
'day' => 16
],
'value' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://connect.withvayu.com/measurements"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"meterId\": \"<string>\",\n \"usageDate\": {\n \"year\": 1,\n \"month\": 6,\n \"day\": 16\n },\n \"value\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://connect.withvayu.com/measurements")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"meterId\": \"<string>\",\n \"usageDate\": {\n \"year\": 1,\n \"month\": 6,\n \"day\": 16\n },\n \"value\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://connect.withvayu.com/measurements")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"<string>\",\n \"meterId\": \"<string>\",\n \"usageDate\": {\n \"year\": 1,\n \"month\": 6,\n \"day\": 16\n },\n \"value\": 123\n}"
response = http.request(request)
puts response.read_body{
"measurement": {
"customerId": "<string>",
"meterId": "<string>",
"usageDate": {
"year": 1,
"month": 6,
"day": 16
},
"value": 123,
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"params": [
{
"param": "<string>",
"message": "<string>"
}
]
}{
"type": "authentication_error",
"code": "authentication_failed",
"message": "<string>"
}{
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"message": "<string>"
}{
"type": "api_error",
"code": "internal_error",
"message": "<string>"
}Measurements
Create Measurement
Create a new Measurement.
POST
/
measurements
Create Measurement
curl --request POST \
--url https://connect.withvayu.com/measurements \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customerId": "<string>",
"meterId": "<string>",
"usageDate": {
"year": 1,
"month": 6,
"day": 16
},
"value": 123
}
'import requests
url = "https://connect.withvayu.com/measurements"
payload = {
"customerId": "<string>",
"meterId": "<string>",
"usageDate": {
"year": 1,
"month": 6,
"day": 16
},
"value": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: '<string>',
meterId: '<string>',
usageDate: {year: 1, month: 6, day: 16},
value: 123
})
};
fetch('https://connect.withvayu.com/measurements', 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://connect.withvayu.com/measurements",
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([
'customerId' => '<string>',
'meterId' => '<string>',
'usageDate' => [
'year' => 1,
'month' => 6,
'day' => 16
],
'value' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://connect.withvayu.com/measurements"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"meterId\": \"<string>\",\n \"usageDate\": {\n \"year\": 1,\n \"month\": 6,\n \"day\": 16\n },\n \"value\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://connect.withvayu.com/measurements")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"meterId\": \"<string>\",\n \"usageDate\": {\n \"year\": 1,\n \"month\": 6,\n \"day\": 16\n },\n \"value\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://connect.withvayu.com/measurements")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"<string>\",\n \"meterId\": \"<string>\",\n \"usageDate\": {\n \"year\": 1,\n \"month\": 6,\n \"day\": 16\n },\n \"value\": 123\n}"
response = http.request(request)
puts response.read_body{
"measurement": {
"customerId": "<string>",
"meterId": "<string>",
"usageDate": {
"year": 1,
"month": 6,
"day": 16
},
"value": 123,
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"params": [
{
"param": "<string>",
"message": "<string>"
}
]
}{
"type": "authentication_error",
"code": "authentication_failed",
"message": "<string>"
}{
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"message": "<string>"
}{
"type": "api_error",
"code": "internal_error",
"message": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The customer for whom usage will be attributed
Pattern:
^[0-9a-fA-F]{24}$The meter/product that is being measured
Pattern:
^[0-9a-fA-F]{24}$The day the usage took place
Show child attributes
Show child attributes
The updated value of product units consumed by the customer, for the product for given day
Response
RequestSuccess
Show child attributes
Show child attributes
⌘I
