API Router Reference
Welcome to the API Router documentation. This API allows you to route requests securely to different backend applications using tenant-based routing.
Authentication & Headers
All API requests require specific headers to identify the tenant and authenticate the request.
| Header | Description | Example |
|---|---|---|
Content-Type |
Must be set to JSON | application/json |
X-Client-ID |
Your unique tenant identifier | client123 |
Authorization |
Bearer token for access | Bearer f17f7e2d1bc9e94e701f10b8d56f06af |
Endpoints
GET
/users
Retrieve a list of users associated with your tenant.
JavaScript
Python
Go
Rust
C#
PHP
const url = 'http://localhost/api_router/index.php/users';
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Client-ID': 'client123',
'Authorization': 'Bearer f17f7e2d1bc9e94e701f10b8d56f06af'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
url = "http://localhost/api_router/index.php/users"
headers = {
"Content-Type": "application/json",
"X-Client-ID": "client123",
"Authorization": "Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
}
response = requests.get(url, headers=headers)
print(response.json())
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://localhost/api_router/index.php/users"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Client-ID", "client123")
req.Header.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
use reqwest::header;
#[tokio::main]
async fn main() -> Result<(), Box> {
let mut headers = header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("X-Client-ID", "client123".parse()?);
headers.insert("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af".parse()?);
let client = reqwest::Client::builder().build()?;
let res = client.get("http://localhost/api_router/index.php/users")
.headers(headers)
.send()
.await?;
println!("{}", res.text().await?);
Ok(())
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api_router/index.php/users");
request.Headers.Add("X-Client-ID", "client123");
request.Headers.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af");
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
<?php
$ch = curl_init("http://localhost/api_router/index.php/users");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Client-ID: client123",
"Authorization: Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
POST
/orders
Create a new order in the system.
JavaScript
Python
Go
Rust
C#
PHP
const url = 'http://localhost/api_router/index.php/orders';
const payload = { orderId: 123, item: "Laptop" };
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Client-ID': 'client123',
'Authorization': 'Bearer f17f7e2d1bc9e94e701f10b8d56f06af'
},
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
url = "http://localhost/api_router/index.php/orders"
headers = {
"Content-Type": "application/json",
"X-Client-ID": "client123",
"Authorization": "Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
}
payload = {
"orderId": 123,
"item": "Laptop"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://localhost/api_router/index.php/orders"
payload := []byte(`{"orderId":123,"item":"Laptop"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Client-ID", "client123")
req.Header.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
use reqwest::header;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box> {
let mut headers = header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("X-Client-ID", "client123".parse()?);
headers.insert("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af".parse()?);
let payload = json!({
"orderId": 123,
"item": "Laptop"
});
let client = reqwest::Client::builder().build()?;
let res = client.post("http://localhost/api_router/index.php/orders")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", res.text().await?);
Ok(())
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api_router/index.php/orders");
request.Headers.Add("X-Client-ID", "client123");
request.Headers.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af");
var json = "{\"orderId\":123,\"item\":\"Laptop\"}";
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
<?php
$ch = curl_init("http://localhost/api_router/index.php/orders");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["orderId" => 123, "item" => "Laptop"]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Client-ID: client123",
"Authorization: Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
PATCH
/orders/123
Update an existing order in the system.
JavaScript
Python
Go
Rust
C#
PHP
const url = 'http://localhost/api_router/index.php/orders/123';
const payload = { status: "shipped" };
fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'X-Client-ID': 'client123',
'Authorization': 'Bearer f17f7e2d1bc9e94e701f10b8d56f06af'
},
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
url = "http://localhost/api_router/index.php/orders/123"
headers = {
"Content-Type": "application/json",
"X-Client-ID": "client123",
"Authorization": "Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
}
payload = {
"status": "shipped"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.json())
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://localhost/api_router/index.php/orders/123"
payload := []byte(`{"status":"shipped"}`)
req, _ := http.NewRequest("PATCH", url, bytes.NewBuffer(payload))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Client-ID", "client123")
req.Header.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
use reqwest::header;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box> {
let mut headers = header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("X-Client-ID", "client123".parse()?);
headers.insert("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af".parse()?);
let payload = json!({
"status": "shipped"
});
let client = reqwest::Client::builder().build()?;
let res = client.patch("http://localhost/api_router/index.php/orders/123")
.headers(headers)
.json(&payload)
.send()
.await?;
println!("{}", res.text().await?);
Ok(())
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("PATCH"), "http://localhost/api_router/index.php/orders/123");
request.Headers.Add("X-Client-ID", "client123");
request.Headers.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af");
var json = "{\"status\":\"shipped\"}";
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
<?php
$ch = curl_init("http://localhost/api_router/index.php/orders/123");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["status" => "shipped"]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Client-ID: client123",
"Authorization: Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
DELETE
/orders/123
Delete an order from the system.
JavaScript
Python
Go
Rust
C#
PHP
const url = 'http://localhost/api_router/index.php/orders/123';
fetch(url, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'X-Client-ID': 'client123',
'Authorization': 'Bearer f17f7e2d1bc9e94e701f10b8d56f06af'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
url = "http://localhost/api_router/index.php/orders/123"
headers = {
"Content-Type": "application/json",
"X-Client-ID": "client123",
"Authorization": "Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
}
response = requests.delete(url, headers=headers)
print(response.json())
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://localhost/api_router/index.php/orders/123"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Client-ID", "client123")
req.Header.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
use reqwest::header;
#[tokio::main]
async fn main() -> Result<(), Box> {
let mut headers = header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("X-Client-ID", "client123".parse()?);
headers.insert("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af".parse()?);
let client = reqwest::Client::builder().build()?;
let res = client.delete("http://localhost/api_router/index.php/orders/123")
.headers(headers)
.send()
.await?;
println!("{}", res.text().await?);
Ok(())
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Delete, "http://localhost/api_router/index.php/orders/123");
request.Headers.Add("X-Client-ID", "client123");
request.Headers.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af");
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
<?php
$ch = curl_init("http://localhost/api_router/index.php/orders/123");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Client-ID: client123",
"Authorization: Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
GET
/metrics
Retrieve operational metrics for the API gateway.
JavaScript
Python
Go
Rust
C#
PHP
const url = 'http://localhost/api_router/index.php/metrics';
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Client-ID': 'client123',
'Authorization': 'Bearer f17f7e2d1bc9e94e701f10b8d56f06af'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
url = "http://localhost/api_router/index.php/metrics"
headers = {
"Content-Type": "application/json",
"X-Client-ID": "client123",
"Authorization": "Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
}
response = requests.get(url, headers=headers)
print(response.json())
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://localhost/api_router/index.php/metrics"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Client-ID", "client123")
req.Header.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
use reqwest::header;
#[tokio::main]
async fn main() -> Result<(), Box> {
let mut headers = header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("X-Client-ID", "client123".parse()?);
headers.insert("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af".parse()?);
let client = reqwest::Client::builder().build()?;
let res = client.get("http://localhost/api_router/index.php/metrics")
.headers(headers)
.send()
.await?;
println!("{}", res.text().await?);
Ok(())
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api_router/index.php/metrics");
request.Headers.Add("X-Client-ID", "client123");
request.Headers.Add("Authorization", "Bearer f17f7e2d1bc9e94e701f10b8d56f06af");
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
<?php
$ch = curl_init("http://localhost/api_router/index.php/metrics");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Client-ID: client123",
"Authorization: Bearer f17f7e2d1bc9e94e701f10b8d56f06af"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>