Code Examples

A copy-paste reference for every Simple Telecom API operation in curl, PHP and JavaScript.

Ready to bolt the API into your stack?

Log in to the Console

All examples assume you have a token — see Authentication. Base URL: https://api.simpletelecom.com.au/v1.

Tip: For the concepts behind these snippets, see Your services, Call detail records, Call routing, Manage forwarding and Call recording.


1. List your services

curl

curl -X GET "https://api.simpletelecom.com.au/v1/api/services?page=1&page_size=50&order=asc" \
  -H "Authorization: Bearer st_your_token_here"

PHP

<?php
$ch = curl_init("https://api.simpletelecom.com.au/v1/api/services?page_size=100");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Authorization: Bearer st_your_token_here"],
]);
$response = json_decode(curl_exec($ch), true);
foreach ($response['data'] ?? [] as $s) {
    echo "{$s['service_id']} {$s['service_number']} type={$s['service_type']}\n";
}

JavaScript

const res = await fetch("https://api.simpletelecom.com.au/v1/api/services", {
  headers: { Authorization: "Bearer st_your_token_here" },
});
const { data } = await res.json();
data.forEach(s => console.log(`${s.service_id} ${s.service_number} type=${s.service_type}`));

2. Pull call detail records

curl

curl -X GET "https://api.simpletelecom.com.au/v1/api/cdrs?service_number=1300858751&start_date=2026-07-01&end_date=2026-07-31&page=1&page_size=50&order=desc" \
  -H "Authorization: Bearer st_your_token_here"

PHP

<?php
$params = http_build_query([
    'service_number' => '1300858751',
    'start_date'     => '2026-07-01',
    'end_date'       => '2026-07-31',
    'page_size'      => 100,
]);
$ch = curl_init("https://api.simpletelecom.com.au/v1/api/cdrs?$params");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Authorization: Bearer st_your_token_here"],
]);
$response = json_decode(curl_exec($ch), true);
echo "Total records: {$response['meta']['total_records']}\n";
foreach ($response['data'] ?? [] as $cdr) {
    echo "{$cdr['start_time']} {$cdr['duration_sec']}s \${$cdr['cost']}\n";
}

3. Read call routing

curl

curl -X GET "https://api.simpletelecom.com.au/v1/api/services/123/routing" \
  -H "Authorization: Bearer st_your_token_here"

JavaScript

const { call_recording, forwarding_numbers } = await fetch(
  "https://api.simpletelecom.com.au/v1/api/services/123/routing",
  { headers: { Authorization: "Bearer st_your_token_here" } }
).then(r => r.json());

console.log(`Recording: ${call_recording.enabled ? "ON" : "OFF"}`);
forwarding_numbers.forEach(f =>
  console.log(`#${f.position} ${f.phone_number} (${f.display_name}) ring ${f.duration}s`));

4. Add a forwarding number

curl

curl -X POST "https://api.simpletelecom.com.au/v1/api/services/123/routing/forwarding" \
  -H "Authorization: Bearer st_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{"phone_number":"0412345678","display_name":"Reception","duration":15}'

JavaScript

await fetch("https://api.simpletelecom.com.au/v1/api/services/123/routing/forwarding", {
  method: "POST",
  headers: {
    Authorization: "Bearer st_your_token_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    phone_number: "0412345678",
    display_name: "Reception",
    duration: 15,
  }),
});

5. Update a forwarding number

curl

curl -X PUT "https://api.simpletelecom.com.au/v1/api/services/123/routing/forwarding" \
  -H "Authorization: Bearer st_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{"current_phone_number":"0412345678","display_name":"Head Office","duration":30}'

6. Remove a forwarding number

curl

curl -X DELETE "https://api.simpletelecom.com.au/v1/api/services/123/routing/forwarding" \
  -H "Authorization: Bearer st_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{"phone_number":"0298765432"}'

Remember — you can't remove the last forwarding number on a service.


7. Enable call recording

curl

curl -X PUT "https://api.simpletelecom.com.au/v1/api/services/123/routing/recording" \
  -H "Authorization: Bearer st_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{"enabled":true}'

JavaScript

const res = await fetch("https://api.simpletelecom.com.au/v1/api/services/123/routing/recording", {
  method: "PUT",
  headers: {
    Authorization: "Bearer st_your_token_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ enabled: false }),
});
const { call_recording } = await res.json();
console.log(`Recording now: ${call_recording.enabled ? "ON" : "OFF"}`);

Building your own wrapper

Putting the auth header in one place makes the rest of your code cleaner. A minimal JavaScript wrapper:

const token = "st_your_token_here";
const base  = "https://api.simpletelecom.com.au/v1";

async function api(path, method = "GET", body) {
  const res = await fetch(`${base}${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${token}`,
      ...(body ? { "Content-Type": "application/json" } : {}),
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  if (!res.ok) throw new Error(`${res.status} ${(await res.json()).code}`);
  return res.json();
}

const services = await api("/api/services");
const routing  = await api("/api/services/123/routing");
await api("/api/services/123/routing/recording", "PUT", { enabled: true });