Skip to main content
Splunk® Phantom (Legacy)

Python Playbook API Reference for Splunk Phantom

Splunk® Phantom (Legacy)
4.9

Session automation API

The Splunk Phantom Automation API allows security operations teams to develop detailed and precise automation strategies. Playbooks can serve many purposes, ranging from automating minimal investigative tasks that can speed up analysis to large-scale responses to a security breach. The following APIs are supported to leverage the capabilities of session automation using playbooks.

build_phantom_rest_url

Use the build_phantom_rest_url API to combine the Splunk Phantom base URL and the specific resource path, such as /rest/artifact.

The build_phantom_rest_url API is supported from within a custom function.

phantom.build_phantom_rest_url()
Expand

This sample uses the phantom.build_phantom_rest_url API.

get_base_url

Use the get_base_url API to retrieve the URL that points to your Splunk Phantom instance.

The get_base_url API is supported from within a custom function.

phantom.get_base_url()
Expand

This sample uses the phantom.get_base_url() API.

get_phantom_home

Use the get_phantom_home API to return the path to the Splunk Phantom home directory.

The get_phantom_home is supported from within a custom function.

phantom.get_phantom_home()

The following examples show the return values for the get_phantom_home API on different types of installs.

On a release OVA or privileged install:

Thu Jan 03 2019 16:37:23 GMT-0800 (Pacific Standard Time): /opt/phantom

On an unprivileged install:

Thu Jan 03 2019 16:36:31 GMT-0800 (Pacific Standard Time): /home/username/directory_name

get_rest_base_url

Use the get_rest_base_url API to return the base URL to the REST API of your Splunk Phantom instance. This API works on all Splunk Phantom instances, regardless of installation type, or the base URL found in the in Company Settings.

The get_rest_base_url is supported from within a custom function.

phantom.get_rest_base_url()

The following examples show the return values for the get_rest_base_url API on different types of installs.

On a release OVA or privileged install:

Thu Jan 03 2019 16:37:23 GMT-0800 (Pacific Standard Time): https://127.0.0.1/rest/

On an unprivileged install, showing the custom HTTPS port:

Thu Jan 03 2019 16:36:31 GMT-0800 (Pacific Standard Time): https://127.0.0.1:9999/rest/

requests

Use the requests API to interact with the Splunk Phantom platform through the REST API. By using phantom.requests instead of directly importing requests from site packages, you avoid the need to set the Splunk Phantom request headers by hand, meaning that you don't need to authenticate with the platform. For more information on how to use the requests package, see https://pypi.org/project/requests.

The requests API is supported from within a custom function.

phantom.requests
Expand

This sample uses the phantom.requests() API.

set_action_limit

Use set_action_limit in your playbook's on_start() block to set the maximum number of action calls that can be executed. The default is 50 action calls per container per Playbook. Each phantom.act() call can still result in multiple actions performed, resulting in more actions than this setting.

set_action_limit is not supported from within a custom function.

phantom.set_action_limit(limit)
Last modified on 03 May, 2022
Data access automation API   Vault automation API

This documentation applies to the following versions of Splunk® Phantom (Legacy): 4.9, 4.10, 4.10.1, 4.10.2, 4.10.3, 4.10.4, 4.10.6, 4.10.7


Please expect delayed responses to documentation feedback while the team migrates content to a new system. We value your input and thank you for your patience as we work to provide you with an improved content experience!

Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters