Demisto SDK
raw JSON → 1.38.24 verified Mon Apr 27 auth: no python
A Python library for developing, testing, and managing Cortex XSOAR content. Version 1.38.24 supports Python 3.9-3.12. Released approximately monthly.
pip install demisto-sdk Common errors
error ModuleNotFoundError: No module named 'demisto_sdk' ↓
cause The package is installed but the import path is misspelled (underscore vs hyphen).
fix
Install with
pip install demisto-sdk but import with import demisto_sdk (underscore). error AttributeError: module 'demisto_sdk' has no attribute 'run_command' ↓
cause Trying to import run_command from the top-level module instead of the correct submodule.
fix
Use
from demisto_sdk.commands.common.tools import run_command. error ValueError: Invalid API key ↓
cause API key is missing or incorrect.
fix
Ensure DEMISTO_API_KEY environment variable is set or pass the correct key to DemistoSDK.
Warnings
breaking In v1.16.0, the DemistoSDK class moved from `demisto_sdk` to `demisto_sdk.__main__`. Import from `demisto_sdk` directly going forward. ↓
fix Use `from demisto_sdk import DemistoSDK`
deprecated The `validate` command's `--prev-ver` flag is deprecated in favor of `--previous-version`. ↓
fix Use `--previous-version` instead
gotcha API keys should be stored securely. The SDK does not encrypt keys; avoid hardcoding. ↓
fix Use environment variables or a secrets manager.
Imports
- DemistoSDK wrong
from demisto_sdk import SDKcorrectfrom demisto_sdk import DemistoSDK - run_command wrong
from demisto_sdk import run_commandcorrectfrom demisto_sdk.commands.common.tools import run_command
Quickstart
from demisto_sdk import DemistoSDK
import os
api_key = os.environ.get('DEMISTO_API_KEY', '')
base_url = os.environ.get('DEMISTO_BASE_URL', 'https://api.demisto.com')
sdk = DemistoSDK(api_key=api_key, base_url=base_url)
# Example: validate content
sdk.content_validate()