POST /custom_statuses
Creates a new custom status.
Example Request
- cURL
- Node
- Ruby
- Go
- PHP
- Python
- C#
- Java
- Rust
curl -X POST "https://api.callbell.eu/v1/custom_statuses" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"name": "Lunch"
}'
import axios from 'axios';
const response = await axios.post(
'https://api.callbell.eu/v1/custom_statuses',
// '{\n "name": "Lunch"\n }',
{
'name': 'Lunch'
},
{
headers: {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json'
}
}
);
require 'net/http'
require 'json'
uri = URI('https://api.callbell.eu/v1/custom_statuses')
req = Net::HTTP::Post.new(uri)
req.content_type = 'application/json'
req['Authorization'] = 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM'
# The object won't be serialized exactly like this
# req.body = "{\n \"name\": \"Lunch\"\n }"
req.body = {
'name' => 'Lunch'
}.to_json
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
package main
import (
"fmt"
"io"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader(`{
"name": "Lunch"
}`)
req, err := http.NewRequest("POST", "https://api.callbell.eu/v1/custom_statuses", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.callbell.eu/v1/custom_statuses');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"name\": \"Lunch\"\n }");
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
'Authorization': 'Bearer test_gshuPaZoeEG6ovbc8M79w0QyM',
'Content-Type': 'application/json',
}
json_data = {
'name': 'Lunch',
}
response = requests.post('https://api.callbell.eu/v1/custom_statuses', headers=headers, json=json_data)
# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{\n "name": "Lunch"\n }'
#response = requests.post('https://api.callbell.eu/v1/custom_statuses', headers=headers, data=data)
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.callbell.eu/v1/custom_statuses");
request.Headers.Add("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
request.Content = new StringContent("{\n \"name\": \"Lunch\"\n }");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("https://api.callbell.eu/v1/custom_statuses");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM");
httpConn.setRequestProperty("Content-Type", "application/json");
httpConn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write("{\n \"name\": \"Lunch\"\n }");
writer.flush();
writer.close();
httpConn.getOutputStream().close();
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}
extern crate reqwest;
use reqwest::header;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = header::HeaderMap::new();
headers.insert("Authorization", "Bearer test_gshuPaZoeEG6ovbc8M79w0QyM".parse().unwrap());
headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::blocking::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.unwrap();
let res = client.post("https://api.callbell.eu/v1/custom_statuses")
.headers(headers)
.body(r#"
{
"name": "Lunch"
}
"#
)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
Response
Parameter | Type | Description |
---|---|---|
name | string | Name of the custom status |
customStatus | CustomStatus[] | The object representing the custom status |
Example Response
response.json
{
"customStatus": {
"name": "Lunch",
"createdAt": "2024-12-04 14:12:14 +0100",
"updatedAt": "2024-12-04 14:12:14 +0100",
"id": "8dbd6f6c-ec09-4b87-a04e-bef1c2ca41db"
}
}