Core Command

Core Command API client and functional wrappers for pykada.

The CoreCommandClient provides access to organization-wide audit logs and user management (create, read, update, delete) through Verkada’s Core Command API.

Client

class pykada.core_command.CoreCommandClient(api_key=None, token_manager=None)[source]

Bases: BaseClient

Client for interacting with Verkada’s Core Command API. This client provides methods to retrieve audit logs and manage users.

Initialize the client with either an API key or a token manager. If not key is provided, a default token manager will be used based on the environment configuration (VERKADA_API_KEY in a .env file).

Parameters:
get_all_audit_logs(start_time=None, end_time=None)[source]

Returns all audit log events for the organization, walking all pages automatically.

Parameters:
  • start_time (Optional[int]) – Start of the time window (Unix timestamp, seconds).

  • end_time (Optional[int]) – End of the time window (Unix timestamp, seconds).

Returns:

A generator that yields individual audit log event dictionaries.

Return type:

Generator

get_audit_logs(start_time=None, end_time=None, page_token=None, page_size=100)[source]

Retrieve audit log events based on various filters.

Parameters:
  • start_time (Optional[int]) – The start of the time range for requested events, as a Unix timestamp in seconds. Defaults to one hour ago from the current time if not provided.

  • end_time (Optional[int]) – The end of the time range for requested events, as a Unix timestamp in seconds. Defaults to the current time if not provided.

  • page_token (Optional[str]) – The pagination token used to fetch the next page of results.

  • page_size (Optional[int]) – The number of items returned in a single response (0 to 200). Defaults to 100.

Return type:

Dict[str, Any]

Returns:

JSON response containing audit log events matching the provided filters.

Raises:

ValueError – If page_size is not between 0 and 200.

get_user(user_id=None, external_id=None)[source]

Retrieve a user for an organization based on either the provided user ID or external ID. Exactly one of user_id or external_id must be provided.

Parameters:
  • user_id (Optional[str]) – The internal user identifier.

  • external_id (Optional[str]) – The external user identifier.

Return type:

Dict[str, Any]

Returns:

JSON response containing user details.

Raises:

ValueError – If not exactly one of user_id or external_id is provided.

create_user(external_id=None, company_name=None, department=None, department_id=None, email=None, employee_id=None, employee_title=None, employee_type=None, first_name=None, last_name=None, middle_name=None, phone=None)[source]

Create a new user in an organization.

Creates a user using the Core API endpoint. An external_id is required; if not provided, the newly created user will contain a generated user ID for identification.

Body Parameters:
  • company_name (string): The name of the company the user is part of.

  • department (string): The name of the department the user is part of.

  • department_id (string): The department ID of the department the user is in.

  • email (string): The email address of the user.

  • employee_id (string): The user’s employee ID (does not have to be unique).

  • employee_title (string): The title of the employee.

  • employee_type (string): The type of employee.

  • external_id (string, required): A unique identifier managed externally provided by the consumer.

  • first_name (string): The first name of the user.

  • last_name (string): The last name of the user.

  • middle_name (string): The middle name of the user.

  • phone (string): The main phone number of the user (E.164 format preferred).

Parameters:
  • external_id (Optional[str]) – External unique identifier (required).

  • company_name (Optional[str]) – Optional company name.

  • department (Optional[str]) – Optional department name.

  • department_id (Optional[str]) – Optional department ID.

  • email (Optional[str]) – Optional email address.

  • employee_id (Optional[str]) – Optional employee ID.

  • employee_title (Optional[str]) – Optional employee title.

  • employee_type (Optional[str]) – Optional employee type.

  • first_name (Optional[str]) – Optional first name.

  • last_name (Optional[str]) – Optional last name.

  • middle_name (Optional[str]) – Optional middle name.

  • phone (Optional[str]) – Optional phone number.

Return type:

Dict[str, Any]

Returns:

JSON response containing the created user information.

Raises:

ValueError – If external_id is an empty string.

update_user(external_id=None, user_id=None, company_name=None, department=None, department_id=None, email=None, employee_id=None, employee_title=None, employee_type=None, first_name=None, last_name=None, middle_name=None, phone=None)[source]

Update an existing user in an organization.

Updates a user using the Core API endpoint. Exactly one of user_id or external_id must be provided. The fields provided in the payload will be updated for the user.

Parameters:
Return type:

Dict[str, Any]

Returns:

JSON response containing the updated user information.

Raises:

ValueError – If not exactly one of user_id or external_id is provided.

delete_user(user_id=None, external_id=None)[source]

Delete a user from an organization based on either provided user ID or external ID. Exactly one of user_id or external_id must be provided.

Parameters:
  • user_id (Optional[str]) – The internal user identifier.

  • external_id (Optional[str]) – The external user identifier.

Return type:

Dict[str, Any]

Returns:

JSON response confirming deletion.

Raises:

ValueError – If not exactly one of user_id or external_id is provided.

property request_manager: VerkadaRequestManager

Returns the request manager used by this client.

Functional wrappers

Core Command API client and functional wrappers for pykada.

The CoreCommandClient provides access to organization-wide audit logs and user management (create, read, update, delete) through Verkada’s Core Command API.

pykada.core_command.create_user(external_id=None, company_name=None, department=None, department_id=None, email=None, employee_id=None, employee_title=None, employee_type=None, first_name=None, last_name=None, middle_name=None, phone=None)[source]

Create a new user in an organization.

Creates a user using the Core API endpoint. An external_id is required; if not provided, the newly created user will contain a generated user ID for identification.

Body Parameters:
  • company_name (string): The name of the company the user is part of.

  • department (string): The name of the department the user is part of.

  • department_id (string): The department ID of the department the user is in.

  • email (string): The email address of the user.

  • employee_id (string): The user’s employee ID (does not have to be unique).

  • employee_title (string): The title of the employee.

  • employee_type (string): The type of employee.

  • external_id (string, required): A unique identifier managed externally provided by the consumer.

  • first_name (string): The first name of the user.

  • last_name (string): The last name of the user.

  • middle_name (string): The middle name of the user.

  • phone (string): The main phone number of the user (E.164 format preferred).

Parameters:
  • external_id (Optional[str]) – External unique identifier (required).

  • company_name (Optional[str]) – Optional company name.

  • department (Optional[str]) – Optional department name.

  • department_id (Optional[str]) – Optional department ID.

  • email (Optional[str]) – Optional email address.

  • employee_id (Optional[str]) – Optional employee ID.

  • employee_title (Optional[str]) – Optional employee title.

  • employee_type (Optional[str]) – Optional employee type.

  • first_name (Optional[str]) – Optional first name.

  • last_name (Optional[str]) – Optional last name.

  • middle_name (Optional[str]) – Optional middle name.

  • phone (Optional[str]) – Optional phone number.

Returns:

JSON response containing the created user information.

Raises:

ValueError – If external_id is an empty string.

Note: This is a functional wrapper for its equivalent method in the CoreCommandClient. It creates a new client instance on every call, making it best for single, convenient operations. For making multiple API calls, instantiate and use an CoreCommandClient object directly for better performance.

pykada.core_command.delete_user(user_id=None, external_id=None)[source]

Delete a user from an organization based on either provided user ID or external ID. Exactly one of user_id or external_id must be provided.

Parameters:
  • user_id (Optional[str]) – The internal user identifier.

  • external_id (Optional[str]) – The external user identifier.

Returns:

JSON response confirming deletion.

Raises:

ValueError – If not exactly one of user_id or external_id is provided.

Note: This is a functional wrapper for its equivalent method in the CoreCommandClient. It creates a new client instance on every call, making it best for single, convenient operations. For making multiple API calls, instantiate and use an CoreCommandClient object directly for better performance.

pykada.core_command.get_all_audit_logs(start_time=None, end_time=None)[source]

Returns all audit log events for the organization, walking all pages automatically.

Parameters:
  • start_time (Optional[int]) – Start of the time window (Unix timestamp, seconds).

  • end_time (Optional[int]) – End of the time window (Unix timestamp, seconds).

Returns:

A generator that yields individual audit log event dictionaries.

Return type:

Generator

Note: This is a functional wrapper for its equivalent method in the CoreCommandClient. It creates a new client instance on every call, making it best for single, convenient operations. For making multiple API calls, instantiate and use a CoreCommandClient object directly for better performance.

pykada.core_command.get_audit_logs(start_time=None, end_time=None, page_token=None, page_size=100)[source]

Retrieve audit log events based on various filters.

Parameters:
  • start_time (Optional[int]) – The start of the time range for requested events, as a Unix timestamp in seconds. Defaults to one hour ago from the current time if not provided.

  • end_time (Optional[int]) – The end of the time range for requested events, as a Unix timestamp in seconds. Defaults to the current time if not provided.

  • page_token (Optional[str]) – The pagination token used to fetch the next page of results.

  • page_size (Optional[int]) – The number of items returned in a single response (0 to 200). Defaults to 100.

Returns:

JSON response containing audit log events matching the provided filters.

Raises:

ValueError – If page_size is not between 0 and 200.

Note: This is a functional wrapper for its equivalent method in the CoreCommandClient. It creates a new client instance on every call, making it best for single, convenient operations. For making multiple API calls, instantiate and use an CoreCommandClient object directly for better performance.

pykada.core_command.get_user(user_id=None, external_id=None)[source]

Retrieve a user for an organization based on either the provided user ID or external ID. Exactly one of user_id or external_id must be provided.

Parameters:
  • user_id (Optional[str]) – The internal user identifier.

  • external_id (Optional[str]) – The external user identifier.

Returns:

JSON response containing user details.

Raises:

ValueError – If not exactly one of user_id or external_id is provided.

Note: This is a functional wrapper for its equivalent method in the CoreCommandClient. It creates a new client instance on every call, making it best for single, convenient operations. For making multiple API calls, instantiate and use an CoreCommandClient object directly for better performance.

pykada.core_command.update_user(external_id=None, user_id=None, company_name=None, department=None, department_id=None, email=None, employee_id=None, employee_title=None, employee_type=None, first_name=None, last_name=None, middle_name=None, phone=None)[source]

Update an existing user in an organization.

Updates a user using the Core API endpoint. Exactly one of user_id or external_id must be provided. The fields provided in the payload will be updated for the user.

Parameters:
Returns:

JSON response containing the updated user information.

Raises:

ValueError – If not exactly one of user_id or external_id is provided.

Note: This is a functional wrapper for its equivalent method in the CoreCommandClient. It creates a new client instance on every call, making it best for single, convenient operations. For making multiple API calls, instantiate and use an CoreCommandClient object directly for better performance.