# “2031 - Zoom Phone has not been enabled for this account” - API Error

**URL:** <https://devforum.zoom.us/t/2031-zoom-phone-has-not-been-enabled-for-this-account-api-error/130666>\
**Category:** API and Webhooks\
**Tags:** phone\
**Created:** [March 28, 2025, 1:54pm UTC](https://devforum.zoom.us/t/2031-zoom-phone-has-not-been-enabled-for-this-account-api-error/130666 "2025-03-28T13:54:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitor1](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vitor1/32/68255_2.png) [@Vitor1](https://devforum.zoom.us/u/Vitor1)\
**Post date:** [March 28, 2025, 1:54pm UTC](https://devforum.zoom.us/t/2031-zoom-phone-has-not-been-enabled-for-this-account-api-error/130666/1 "2025-03-28T13:54:29Z")

</div>

Hi everyone,

I’m trying to get the call log from my organization’s account. I do have the necessary permissions.

But I keep getting this error:  
{“code”:2031,“message”:“Zoom Phone has not been enabled for this account.”}

On the thread 117278 (it didnt give me permission to include the link), an user gave me an alternative code that would work pretty well for me:

```auto
import requests
import sqlite3
import base64
import time

# OAuth token URL and the new API endpoint for call history
ZOOM_OAUTH_TOKEN_URL = "https://zoom.us/oauth/token"
ZOOM_PHONE_CALL_HISTORY_URL = "https://api.zoom.us/v2/phone/call_history"

# Replace with your Zoom OAuth Client ID and Secret for Server-to-Server OAuth
CLIENT_ID = 'ID'
CLIENT_SECRET = 'SECRET'

# SQLite database setup
DB_FILE = 'zoom_phone_call_logs.db'

def get_zoom_oauth_token():
    """
    Get OAuth token from Zoom API using client credentials for Server-to-Server OAuth.
    """
    auth_header = base64.b64encode(f"{CLIENT_ID}:{CLIENT_SECRET}".encode('utf-8')).decode('utf-8')
    headers = {
        'Authorization': f'Basic {auth_header}',
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    data = {
        'grant_type': 'client_credentials'
    }

    response = requests.post(ZOOM_OAUTH_TOKEN_URL, headers=headers, data=data)

    if response.status_code == 200:
        token_data = response.json()
        return token_data['access_token'], token_data['expires_in']
    else:
        print("Failed to get token:", response.status_code, response.text)
        return None, None

def get_call_history(access_token, from_date, to_date, page_size=100):
    """
    Get account's call history from Zoom Phone API.
    """
    headers = {
        'Authorization': f'Bearer {access_token}'
    }

    params = {
        'from': from_date,
        'to': to_date,
        'page_size': page_size
    }

    all_call_logs = []
    next_page_token = None

    while True:
        if next_page_token:
            params['next_page_token'] = next_page_token

        response = requests.get(ZOOM_PHONE_CALL_HISTORY_URL, headers=headers, params=params)

        if response.status_code == 200:
            data = response.json()
            call_logs = data.get('call_logs', [])
            all_call_logs.extend(call_logs)
            next_page_token = data.get('next_page_token', None)

            if not next_page_token:
                break
        else:
            print("Failed to get call logs:", response.status_code, response.text)
            break

        time.sleep(1) # To avoid hitting API rate limits

    return all_call_logs

def store_call_logs_in_db(call_logs):
    """
    Store call logs into SQLite database.
    """
    conn = sqlite3.connect(DB_FILE)
    cursor = conn.cursor()

    # Create table if it doesn't exist
    cursor.execute('''
        CREATE TABLE IF NOT EXISTS call_logs (
            call_id TEXT PRIMARY KEY,
            call_type TEXT,
            callee_country_code TEXT,
            callee_country_iso_code TEXT,
            callee_did_number TEXT,
            callee_name TEXT,
            call_start_time TEXT,
            call_end_time TEXT,
            duration INTEGER
        )
    ''')

    # Insert or update call logs
    for log in call_logs:
        cursor.execute('''
            INSERT OR REPLACE INTO call_logs (call_id, call_type, callee_country_code, callee_country_iso_code, callee_did_number, callee_name, call_start_time, call_end_time, duration)
            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
        ''', (
            log['call_id'],
            log.get('call_type', ''),
            log.get('callee_country_code', ''),
            log.get('callee_country_iso_code', ''),
            log.get('callee_did_number', ''),
            log.get('callee_name', ''),
            log.get('call_start_time', ''),
            log.get('call_end_time', ''),
            log.get('duration', 0)
        ))

    conn.commit()
    conn.close()

def main():
    access_token, expires_in = get_zoom_oauth_token()

    if not access_token:
        print("Unable to obtain access token. Exiting.")
        return

    print(f"Access token acquired. Expires in {expires_in} seconds.")

    call_logs = get_call_history(access_token, '2023-09-01', '2023-09-30')
    
    if call_logs:
        print(f"Fetched {len(call_logs)} call logs.")
        store_call_logs_in_db(call_logs)
        print("Call logs stored in database.")
    else:
        print("No call logs found.")

if __name__ == ' __main__':
    main()

```

The original user mentioned that to fix it, he had to set grant\_type set to ‘client\_credentials’ rather than ‘account\_credentials’ and specify ‘account\_id

However, I’m having some trouble making those edits.

Could someone please advise me?

Thank you so much!

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [March 31, 2025, 4:32pm UTC](https://devforum.zoom.us/t/2031-zoom-phone-has-not-been-enabled-for-this-account-api-error/130666/2 "2025-03-31T16:32:34Z")

</div>

Hey @Vitor1  
Thanks for reaching out to us  
You should not be using “client\_credentials” as a grant type, if you are working with S2S oauth app, the grant\_type is “account\_credentials”

Could you please change the grant type and try again?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [April 4, 2025, 1:51pm UTC](https://devforum.zoom.us/t/2031-zoom-phone-has-not-been-enabled-for-this-account-api-error/130666/3 "2025-04-04T13:51:15Z")

</div>

Closed on April 4, 2025, 1:51pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
