Welcome to Kazoo’s documentation!

This is a wrapper around the Kazoo API.

class kazoo.Client(api_key=None, password=None, account_name=None, username=None)

The interface to the Kazoo API

This class should be initialized either with a username, password and account name combination, or with an API key. Once you have initialized the client you will need to call authenticate() before you can begin making API calls.

>>>import kazoo
>>>client = kazoo.Client(api_key="sdfasdfas")
>>>client.authenticate()

You can also initialize with a username and password combination:

>>>client = kazoo.Client(username="myusername", password="mypassword", account_name="my_account_name")
>>>client.authenticate()

API calls which require data take it in the form of a required argument called ‘data’ which is the last argument to the method. For example

>>>client.update_account(acct_id, {"name": "somename", "realm":"superfunrealm"})

Dictionaries and lists will automatically be converted to their appropriate representation so you can do things like:

>>>client.update_callflow(acct_id, callflow_id, {"flow":{"module":"somemodule"}})

Invalid data will result in an exception explaining the problem.

The server response is returned from each method as a python dictionary of the returned JSON object, for example:

>>>client.get_account(acct_id)
{u'auth_token': u'abc437d000007d0454cc984f6f09daf3',
 u'data': {u'billing_mode': u'normal',
  u'caller_id': {},
  u'caller_id_options': {},
  u'id': u'c4f64412ad0057222c0009a3e7da011',
  u'media': {u'bypass_media': u'auto'},
  u'music_on_hold': {},
  u'name': u'test3',
  u'notifications': {},
  u'realm': u'4c8050.sip.2600hz.com',
  u'superduper_admin': False,
  u'timezone': u'America/Los_Angeles',
  u'wnm_allow_additions': False},
 u'request_id': u'ea6441422fb85000ad21db4f1e2326c1',
 u'revision': u'3-c16dd0a629fe1da0000e1e7b3e5fb35a',
 u'status': u'success'}

For each resource exposed by the kazoo api there are corresponding methods on the client. For example, for the ‘callflows’ resource the correspondence is as follows.

GET /accounts/{account_id}/callflows -> client.get_callflows(acct_id)
GET /accounts/{account_id}/callflows/{callflow_id} -> client.get_callflow(acct_id, callflow_id)
PUT /accounts/{account_id}/callflows/ -> client.create_callflow(acct_id, data)
POST /account/{account_id}/callflows/{callflow_id} -> client.update_callflow(acct_id, data)
DELETE /account/{account_id}/callflows/{callflow_id} -> client.delete_callflow(acct_id, callflow_id)

Some resources do not have all methods available, in which case they are not present on the client.

There are also some resources which don’t quite fit this paradigm, they are:

GET /accounts/{account_id}/media -> client.get_all_media(acct_id)
GET /accounts/{account_id}/children -> client.get_account_children(acct_id)
GET /accounts/{account_id}/descendants -> client.get_account_descendants(acct_id)
GET /accounts/{account_id}/devices/status -> client.get_all_devices_status(acct_id)
GET /accounts/{account_id}/servers/{server_id}/deployment -> client.get_deployment(acct_id, server_id)
GET /accounts/{account_id}/users/hotdesk -> client.get_hotdesk(acct_id)
activate_phone_number(account_id, phone_number, data)
add_port_in_number(account_id, phone_number, data)
authenticate()

Call this before making other api calls to fetch an auth token which will be automatically used for all further requests

create_callflow(account_id, data)
create_conference(account_id, data)
create_deployment(account_id, server_id, data)
create_device(account_id, data)
create_directory(account_id, data)
create_global_resource(account_id, data)
create_local_resource(account_id, data)
create_media(account_id, data)
create_menu(account_id, data)
create_phone_number(acct_id, phone_number)
create_queue(account_id, data)
create_temporal_rule(account_id, data)
create_user(account_id, data)
create_voicemail_box(account_id, data)
delete_callflow(account_id, callflow_id)
delete_conference(account_id, conference_id)
delete_device(account_id, device_id)
delete_directory(account_id, directory_id)
delete_global_resource(account_id, resource_id)
delete_local_resource(account_id, resource_id)
delete_media(account_id, media_id)
delete_menu(account_id, menu_id)
delete_phone_number(account_id, phone_number)
delete_phone_number_doc(account_id, phone_number, filename)
delete_queue(account_id, queue_id)
delete_temporal_rule(account_id, rule_id)
delete_user(account_id, user_id)
delete_voicemail_box(account_id, vmbox_id)
get_account(account_id)
get_account_children(account_id)
get_account_descendants(account_id)
get_all_devices_status(account_id)
get_all_media(account_id)
get_callflow(account_id, callflow_id)
get_callflows(account_id)
get_conference(account_id, conference_id)
get_conferences(account_id)
get_deployment(account_id, server_id)
get_device(account_id, device_id)
get_devices(account_id)
get_directories(account_id)
get_directory(account_id, directory_id)
get_global_resource(account_id, resource_id)
get_global_resources(account_id)
get_hotdesk(account_id)
get_limits(account_id)
get_local_resource(account_id, resource_id)
get_local_resources(account_id)
get_media(account_id, media_id)
get_menu(account_id, menu_id)
get_menus(account_id)
get_phone_numbers(account_id)
get_queue(account_id, queue_id)
get_queues(account_id)
get_server_log(account_id)
get_servers(account_id)
get_temporal_rule(account_id, rule_id)
get_temporal_rules(account_id)
get_user(account_id, user_id)
get_users(account_id)
get_voicemail_box(account_id, vmbox_id)
get_voicemail_boxes(account_id)
reserve_phone_number(account_id, phone_number, data)
search_phone_numbers(prefix, quantity=10)
update_account(account_id, data)
update_callflow(account_id, callflow_id, data)
update_conference(account_id, conference_id, data)
update_device(account_id, device_id, data)
update_directory(account_id, directory_id, data)
update_global_resource(account_id, resource_id, data)
update_local_resource(account_id, resource_id, data)
update_media(account_id, media_id, data)
update_menu(account_id, menu_id, data)
update_phone_number(account_id, phone_number, data)
update_queue(account_id, queue_id, data)
update_temporal_rule(account_id, rule_id, data)
update_user(account_id, user_id, data)
update_voicemail_box(account_id, vmbox_id, data)
upload_phone_number_file(acct_id, phone_number, filename, file_obj)

Uploads a file like object as part of a phone numbers documents

This Page