Skip to content

Publish Insight

Getting Started

Begin your journey with Palzin Track by publishing your very first insight. Insights are customizable widgets designed to display real-time information and are extremely versatile for tracking various metrics and statuses.

Making a POST Request

To publish your event to Palzin Track, you'll be utilizing HTTP POST requests to the designated log endpoint. Here's how to get started:

TIP

The project and channel values should be lowercase! Alphabet characters, digits, and dashes "-" are accepted. Validation Regex: ^[a-z0-9]+(?:-[a-z0-9]+)*$

POST https://api.palzin.live/v1/insight

Publish Event

To publish an event on Palzin Track, make use of the designated API route. Craft your request following the guidelines below:

Parameters:

Header

Content-TypeHeaderapplication/json
AuthorizationHeaderYour Authorization Token

Body

project*StringProject name
title*StringChannel name
value*StringEvent name
change*Stringincrement, decrement, update
prefixStringString like $, €, ₹, £ or ¥
suffixStringString like Users, Tenants, etc.
iconEmojiSingle emoji as the event icon
Responses (200: OK)
js
{
   // Response   
}
{
   // Response   
}

TIP

Important: Fields ending with an (*) are required in your request!

Usage of Prefix and Suffix

Within the context of every insight, users often find it valuable to clearly associate and understand the significance of displayed values. To enhance this understanding, we have introduced an option that enables users to append both prefix and suffix to numerical or textual values. This feature serves to provide additional context and clarity when reviewing dashboards or insights, making it straightforward for users to identify the specific metric or data point being presented. By incorporating custom prefixes and suffixes, users can effortlessly attribute meaning to the values and enhance the overall interpretability of the information presented on the dashboard. This flexibility ensures that the insights provided are not only informative but also easily comprehensible, empowering users to derive actionable conclusions from the data.

Maintaining Insight Consistency and Status Representation

In the context of each insight, it's essential to maintain consistency in the title throughout all updates. However, you have the flexibility to modify either the value or the icon associated with the insight, depending on its current status. For instance, if you opt to showcase the status of a service, you have the option to switch the icon to 🟢 when the service is operational and 🔴 when it's experiencing an outage. This approach ensures that despite potential changes, the core title remains steady, offering a reliable reference point while adapting to evolving insights.

Code Snippet for Shell

shell
curl --location --request POST 'https://api.palzin.live/v1/insight' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "project": "my-website",
    "title": "Today's Revenue",
    "value": 1234.56,
    "change": "increment",
    "icon": "💰",
    
}'
curl --location --request POST 'https://api.palzin.live/v1/insight' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "project": "my-website",
    "title": "Today's Revenue",
    "value": 1234.56,
    "change": "increment",
    "icon": "💰",
    
}'

Code Snippet for Python

python
import http.client
import json

conn = http.client.HTTPSConnection("palzin.live")
payload = json.dumps({
  "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
})
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN',
  'Content-Type': 'application/json'
}
conn.request("POST", "/v1/insight", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import http.client
import json

conn = http.client.HTTPSConnection("palzin.live")
payload = json.dumps({
  "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
})
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN',
  'Content-Type': 'application/json'
}
conn.request("POST", "/v1/insight", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
python
import requests
import json

url = "https://api.palzin.live/v1/insight"

payload = json.dumps({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
  "icon": "💰"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
import requests
import json

url = "https://api.palzin.live/v1/insight"

payload = json.dumps({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
  "icon": "💰"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Code Snippet for Javascript

javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer YOUR_API_TOKEN");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
});

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("https://api.palzin.live/v1/insight", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer YOUR_API_TOKEN");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
});

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("https://api.palzin.live/v1/insight", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));
jquery
var settings = {
  "url": "https://api.palzin.live/v1/insight",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_TOKEN"
  },
  "data": JSON.stringify({
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",    
  "icon": "💰"
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
var settings = {
  "url": "https://api.palzin.live/v1/insight",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_TOKEN"
  },
  "data": JSON.stringify({
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",    
  "icon": "💰"
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
javascript
// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
    "change": "increment",
  "icon": "💰"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.palzin.live/v1/insight");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer YOUR_API_TOKEN");

xhr.send(data);
// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
    "change": "increment",
  "icon": "💰"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.palzin.live/v1/insight");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer YOUR_API_TOKEN");

xhr.send(data);

Code Snippet for NodeJs

javascript
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
   'method': 'POST',
   'hostname': 'palzin.live',
   'path': '/api/v1/insight',
   'headers': {
      'Authorization': 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json'
   },
   'maxRedirects': 20
};

var req = https.request(options, function (res) {
   var chunks = [];

   res.on("data", function (chunk) {
      chunks.push(chunk);
   });

   res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
   });

   res.on("error", function (error) {
      console.error(error);
   });
});

var postData = JSON.stringify({
    "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
});

req.write(postData);

req.end();
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
   'method': 'POST',
   'hostname': 'palzin.live',
   'path': '/api/v1/insight',
   'headers': {
      'Authorization': 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json'
   },
   'maxRedirects': 20
};

var req = https.request(options, function (res) {
   var chunks = [];

   res.on("data", function (chunk) {
      chunks.push(chunk);
   });

   res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
   });

   res.on("error", function (error) {
      console.error(error);
   });
});

var postData = JSON.stringify({
    "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
});

req.write(postData);

req.end();
javascript
const axios = require('axios');
let data = JSON.stringify({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
    "icon": "💰"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.palzin.live/v1/insight',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
const axios = require('axios');
let data = JSON.stringify({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
    "icon": "💰"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.palzin.live/v1/insight',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.palzin.live/v1/insight',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  body: JSON.stringify({
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",    
      "icon": "💰"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.palzin.live/v1/insight',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  body: JSON.stringify({
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",    
      "icon": "💰"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
javascript
var unirest = require('unirest');
var req = unirest('POST', 'https://api.palzin.live/v1/insight')
  .headers({
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_TOKEN'
  })
  .send(JSON.stringify({
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",   
      "icon": "💰"
  }))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });
var unirest = require('unirest');
var req = unirest('POST', 'https://api.palzin.live/v1/insight')
  .headers({
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_TOKEN'
  })
  .send(JSON.stringify({
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",   
      "icon": "💰"
  }))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });

Code Snippet for Php

php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.palzin.live/v1/insight',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
    "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
}',
    CURLOPT_HTTPHEADER => array(
        'Authorization: Bearer YOUR_API_TOKEN',
        'Content-Type: application/json'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.palzin.live/v1/insight',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
    "project": "my-website",
    "title": "User Registered",
    "value": 1,
    "change": "increment",
    "icon": "🔥",
}',
    CURLOPT_HTTPHEADER => array(
        'Authorization: Bearer YOUR_API_TOKEN',
        'Content-Type: application/json'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Code Snippet for Dart

dart
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
};
var request = http.Request('POST', Uri.parse('https://api.palzin.live/v1/insight'));
request.body = json.encode({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
  "icon": "💰"
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
}
else {
  print(response.reasonPhrase);
}
var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_TOKEN'
};
var request = http.Request('POST', Uri.parse('https://api.palzin.live/v1/insight'));
request.body = json.encode({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
  "icon": "💰"
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
}
else {
  print(response.reasonPhrase);
}

Code Snippet for Go

go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.palzin.live/v1/insight"
  method := "POST"

  payload := strings.NewReader(`{"project":"my-project","title":"Today's Revenue","value":"1234.56","icon":"💰"}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.palzin.live/v1/insight"
  method := "POST"

  payload := strings.NewReader(`{"project":"my-project","title":"Today's Revenue","value":"1234.56","icon":"💰"}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer YOUR_API_TOKEN")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Code Snippet for HTTP

http
POST /api/v1/insight HTTP/1.1
Host: palzin.live
Content-Type: application/json
Authorization: Bearer YOUR_API_TOKEN
Content-Length: 74

{"project":"my-project","title":"Today's Revenue","value":"1234.56","change":"increment","icon":"💰"}
POST /api/v1/insight HTTP/1.1
Host: palzin.live
Content-Type: application/json
Authorization: Bearer YOUR_API_TOKEN
Content-Length: 74

{"project":"my-project","title":"Today's Revenue","value":"1234.56","change":"increment","icon":"💰"}

Code Snippet for Java

java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}");
Request request = new Request.Builder()
  .url("https://api.palzin.live/v1/insight")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}");
Request request = new Request.Builder()
  .url("https://api.palzin.live/v1/insight")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();

Code Snippet for C

c
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://api.palzin.live/v1/insight");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Content-Type: application/json");
  headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_TOKEN");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://api.palzin.live/v1/insight");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Content-Type: application/json");
  headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_TOKEN");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

Code Snippet for OCaml

ocaml
open Lwt
open Cohttp
open Cohttp_lwt_unix

let postData = ref "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}";;

let reqBody = 
  let uri = Uri.of_string "https://api.palzin.live/v1/insight" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Content-Type" "application/json"
    |> fun h -> Header.add h "Authorization" "Bearer YOUR_API_TOKEN"
  in
  let body = Cohttp_lwt.Body.of_string !postData in

  Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)
open Lwt
open Cohttp
open Cohttp_lwt_unix

let postData = ref "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}";;

let reqBody = 
  let uri = Uri.of_string "https://api.palzin.live/v1/insight" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Content-Type" "application/json"
    |> fun h -> Header.add h "Authorization" "Bearer YOUR_API_TOKEN"
  in
  let body = Cohttp_lwt.Body.of_string !postData in

  Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)

Code Snippet for Rust

rust
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse()?);
    headers.insert("Authorization", "Bearer YOUR_API_TOKEN".parse()?);

    let data = r#"{
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",   
   "icon": "💰"
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://api.palzin.live/v1/insight")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse()?);
    headers.insert("Authorization", "Bearer YOUR_API_TOKEN".parse()?);

    let data = r#"{
    "project": "my-project",
    "title": "Today's Revenue",
    "value": "1234.56",
  "change": "increment",   
   "icon": "💰"
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://api.palzin.live/v1/insight")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}

Code Snippet for Ruby

ruby
require "uri"
require "json"
require "net/http"

url = URI("https://api.palzin.live/v1/insight")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer YOUR_API_TOKEN"
request.body = JSON.dump({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
  "icon": "💰"
})

response = https.request(request)
puts response.read_body
require "uri"
require "json"
require "net/http"

url = URI("https://api.palzin.live/v1/insight")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer YOUR_API_TOKEN"
request.body = JSON.dump({
  "project": "my-project",
  "title": "Today's Revenue",
  "value": "1234.56",
  "change": "increment",  
  "icon": "💰"
})

response = https.request(request)
puts response.read_body

Code Snippet for Swift

swift
let parameters = "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://api.palzin.live/v1/insight")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer YOUR_API_TOKEN", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()
let parameters = "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://api.palzin.live/v1/insight")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer YOUR_API_TOKEN", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Code Snippet for Kotlin

java
val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}".toRequestBody(mediaType)
val request = Request.Builder()
  .url("https://api.palzin.live/v1/insight")
  .post(body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build()
val response = client.newCall(request).execute()
val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{\"project\":\"my-project\",\"title\":\"Today's Revenue\",\"value\":\"1234.56\",\"change\":\"increment\",\"icon\":\"💰\"}".toRequestBody(mediaType)
val request = Request.Builder()
  .url("https://api.palzin.live/v1/insight")
  .post(body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build()
val response = client.newCall(request).execute()