Use the Python Management SDK to create, update, delete, or manage stack resources with the Content Management API (CMA).
Note: If you only need to fetch published content, use the Contentstack Python Delivery SDK.
In this guide, you:
Before you begin, make sure you have the following:
Once you have these prerequisites, install the package in your Python environment.
Run the following command:
With the package installed, choose the authentication method that matches your workflow.
The SDK supports four authentication methods. Use the one that matches your access pattern and account setup.
Use an Authtoken when you want a user-specific, read-write token for CMA requests.
Use login credentials when you want to authenticate with your Contentstack email address and password.
Use a management token when you want stack-level access without a user-specific token.
Use OAuth when you need an app-driven authorization flow.
After you authenticate, create a stack object so you can run CMA requests against a specific stack.
Initialize the client with the authentication method you selected, and then create a stack-scoped object with your API key.
The following example uses an Authtoken. If you used login credentials, a management token, or OAuth, reuse that authenticated client object and create the same stack object.
With the stack object ready, you can run basic CMA operations.
The following examples show common operations you can use to confirm your setup and start working with stack data.
Fetch stack details to confirm that your client is authenticated and your API key is correct.
Create an entry by passing an entry payload to a content type in your stack.
Upload an asset by passing the local file path to the asset upload method.
After these requests succeed, move to the full reference and repository examples for broader SDK coverage.