400 Bad Request in "code":200,"message":"Account does not enabled REST API."

I am using Server-To-Server OAuth App

Trying to schedule the zoom meeting URL but getting following error. I have added necessary Scopes as well.

Here is the code which i follow and using composer require guzzlehttp/guzzle for this :

<?php
require 'vendor/autoload.php'; // Include the Guzzle library

// Zoom API credentials
$clientId = 'YOUR_CLIENT_ID';
$clientSecret = 'YOUR_CLIENT_SECRET';

// Define the API endpoint to create a meeting
$apiEndpoint = 'https://api.zoom.us/v2/users/YOUR_USER_ID/meetings';

// Define the meeting data
$meetingData = [
    'topic' => 'Sample Meeting',
    'type' => 2, // 2 for a scheduled meeting
    'start_time' => '2023-09-15T14:00:00Z', // Set your desired start time in UTC
    'duration' => 60, // Meeting duration in minutes
    'timezone' => 'UTC',
];

// Generate a JWT token for Server-to-Server OAuth
$tokenUrl = 'https://zoom.us/oauth/token';
$tokenPayload = [
    'grant_type' => 'client_credentials',
    'client_id' => $clientId,
    'client_secret' => $clientSecret,
];
$tokenHeaders = [
    'Content-Type' => 'application/x-www-form-urlencoded',
];

$tokenClient = new \GuzzleHttp\Client();
$response = $tokenClient->post($tokenUrl, [
    'form_params' => $tokenPayload,
    'headers' => $tokenHeaders,
]);

$tokenData = json_decode($response->getBody(), true);

if (isset($tokenData['access_token'])) {
    // Use the access token to create a meeting
    $meetingHeaders = [
        'Authorization' => 'Bearer ' . $tokenData['access_token'],
        'Content-Type' => 'application/json',
    ];

    $meetingClient = new \GuzzleHttp\Client();
    $meetingResponse = $meetingClient->post($apiEndpoint, [
        'headers' => $meetingHeaders,
        'json' => $meetingData,
    ]);

    $meetingResult = json_decode($meetingResponse->getBody(), true);

    if (isset($meetingResult['id'])) {
        echo 'Meeting created successfully. Meeting ID: ' . $meetingResult['id'];
    } else {
        echo 'Error creating meeting: ' . json_encode($meetingResult);
    }
} else {
    echo 'Error obtaining access token: ' . json_encode($tokenData);
}

Or can any one give simple solution to create meeting using PHP? Any reference would be great.

@numeroplaced ,

Here’s a code sample to get the access token.
Once you get the access token, you can use to call your REST API

<?php

$config = include 'config.php';


// Access the environment variables
$clientId  = $config['client_id'];
$clientSecret  = $config['client_secret'];
$accountId= $config['account_id'];
$oauthUrl = 'https://zoom.us/oauth/token?grant_type=account_credentials&account_id=' . $accountId;  // Replace with your OAuth endpoint URL

function getAccessToken() {
    global $clientSecret, $clientId, $oauthUrl;


    try {
        // Create the Basic Authentication header
        $authHeader = 'Basic ' . base64_encode($clientId . ':' . $clientSecret);
        echo "authHeader: " . $authHeader .  PHP_EOL;
        // Initialize cURL session
        $ch = curl_init($oauthUrl);

        // Set cURL options
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $authHeader));

        // Execute cURL session and get the response
        $response = curl_exec($ch);

        // Check if the request was successful (status code 200)
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpCode == 200) {
            // Parse the JSON response to get the access token
            $oauthResponse = json_decode($response, true);
            $accessToken = $oauthResponse['access_token'];
            return $accessToken;
        } else {
            echo 'OAuth Request Failed with Status Code: ' . $httpCode . PHP_EOL;
            echo $response . PHP_EOL;
            return null;
        }

        // Close cURL session
        curl_close($ch);
    } catch (Exception $e) {
        echo 'An error occurred: ' . $e->getMessage() . PHP_EOL;
        return null;
    }
}

?>```

JWT Apps have been deprecated as of Sept 8, 2023. Check your app status here, App Marketplace