Start a new topic

PHP | Scheduling API: how to get a list of all email templates for all companies of an account

You can extract a list of locations, and fetch the list of email templates for each one:


<?php 
$token = "";
$apikey = "";

// Fetching list of companies/locations for the account
$data = file_get_contents("https://api.agendize.com/api/2.1/scheduling/companies?apiKey=$apikey&token=$token");
$results = json_decode($data);

// Table header for output
echo "Company name\tCompany ID\tEmail template name\tEmail template ID\n";

foreach ($results->items as $result) {
    // Fetching list of email templates for the current company/location
    $data2 = file_get_contents("https://api.agendize.com/api/2.1/scheduling/companies/$result->id/settings/messages/emails?apiKey=$apikey&token=$token");

    $ct = json_decode($data2);
    foreach ($ct->items as $key => $value) {
        // Table row for output
        echo $result->name . "\t" . $result->id . "\t" . $value->name . "\t" . $value->id . "\n";
    }
}
?>


Login or Signup to post a comment