cs-icon.svg

Python Management SDK API Reference

Contentstack is a headless CMS that prioritizes an API-first approach. It empowers developers to create robust cross-platform applications in their preferred programming languages. Simply build your application frontend, and Contentstack handles the rest. This SDK utilizes the Content Management API (CMA), which is designed for managing the content within your Contentstack account. It enables tasks such as creating, updating, deleting, and retrieving account content. To utilize the CMA, user authentication is necessary, achieved through a Management Token or an AuthToken.

Additional Resource: To know more about the Python Management SDK, refer to the About Python Management SDK and Get Started with Python Management SDK documentation.

Contentstack

The Content Management API (CMA) is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account.

Contentstack

The Content Management API (CMA) is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account.

Returns:
Type
contentstack_management.Client
NameTypeDescription

host (required)

string

API host

Default: api.contentstack.io

headers

Dict

Additional headers

early_access

List

Array of header strings for early access features.

authtoken

string

Authtoken is a user-specific read-write token used to make authorized CMA requests.

management_token

string

Authorization token is a read-write token used to make authorized CMA requests, but it is a user-specific token.

timeout

number

Number of milliseconds before the request times out.

Default: 30000ms

region (required)

string

DB region of the stack. You can choose from five regions: NA, EU, Azure NA, Azure EU, and GCP NA

Client Initialization

import contentstack_management
client = contentstack_management.Client()


Set the `host` to 'api.contentstack.io'

import contentstack_management
client = contentstack_management.Client(host: 'api.contentstack.io' )


Set the `headers` to { 'headerkey': 'value'}

import contentstack_management
client = contentstack_management.Client( headers: { 'headerkey': 'value'} )


Set the Early Access Headers

import contentstack_management
client = contentstack_management.Client(early_access: ['early_access_1', 'early_access_2'])
)


Set the `authtoken`

import contentstack_management
client = contentstack_management.Client( authtoken: 'value' )


Set the `authorization`

import contentstack_management
client = contentstack_management.Client( management_token: Management  token' )


Set the `timeout` to 50000ms

import contentstack_management
client = contentstack_management.Client( timeout: 50000 )

ContentstackClient

The Client serves as the central element of the SDK, providing users with an interface to access and engage with external services. It encapsulates functionality and configuration within a user-friendly API, abstracting away intricate technical aspects. This streamlines the procedure of sending requests and managing responses.


Returns:
Type
Client
NameTypeDescription

host

str

Hostname for API endpoint

authtoken

str

A user-specific read-write token for authorization of API requests

headers

str

Headers to be included in the API requests

authorization

str

A user-specific read-write token for authorization of API requests

region

Region

DB region for Stack. You can choose from four regions namely, NA, EU, Azure NA, and Azure EU. The default region is set to NA.

import contentstack_management
client = contentstack_management.Client()

Region

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

Returns:
Type
Client
NameTypeDescription

region

Region

DB region for Stack. You can choose from four regions namely, NA, EU, Azure NA, and Azure EU. The default region is set to NA.

import contentstack_management
client = contentstack_management.Client(region="eu")

User Session

User session consists of calls that will help you to sign in and sign out of your Contentstack account.

User

All accounts registered with Contentstack are known as Users. A Stack can have many users with varying permissions and roles.

Example:

import contentstack_management
client = contentstack_management.Client(authtoken="auth_token")
user = client.user()

activate

The activate method enables the activation of a user account using the activation token.

Returns:
Type
JSON
NameTypeDescription

activation_token

str

The token received at the time of signup or when a user requests an account activation.

body={
   "user": {
      "first_name": "first_name",
      "last_name": "last_name",
      "password": "password",
      "password_confirmation": "confirm_password"
     }
  }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = self.client.user().activate('user_activation_token', body)

fetch

The fetch method retrieves the information of an existing user account.

Returns:
Type
User information
client = contentstack_management.Client(authtoken='auth_token')

response = client.user().fetch()

forgot_password

The forgot_password method sends a request for a temporary password to log in to an account in case a user has forgotten the login password.

Returns:
Type
JSON
NameTypeDescription

body

Dict

The necessary user information for the request, usually comprising the user's email or username.

body={
     "user": {
        "email": "john.doe@contentstack.com"
     }
  }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.user().request_password(body).json()

reset_password

The reset_password method sends a request for resetting the password of your Contentstack account.

Returns:
Type
JSON
NameTypeDescription

body

Dict

The necessary user information for the request, usually comprising the user's email or username.

body = {
    "user": {
    "reset_password_token": "*******",
    "password": "******",
    "password_confirmation": "*****"
   }
 }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.user().reset_password(body)

update

The update method updates the details of an existing user account.

Returns:
Type
JSON
NameTypeDescription

body

Dict

The data that you want to update.

body ={
   "user": {
      "company": "company name inc.",
      "first_name": "Your name"
     }
  }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
user = client.user()
response = user.update(body)

Organization

Organization is the top-level entity in the hierarchy of Contentstack, consisting of stacks and stack resources, and users. Organization allows easy management of projects as well as users within the Organization.

add_users

The add_users method adds users to the organization.

Returns:
Type
JSON
NameTypeDescription

user_data (required)

str

The email address of the user whom you intend to add in the organization.

data = {
           "share": {
               "users": {
                   "abc@sample.com": ["{****}"],
                   "xyz@sample.com": ["{****}"]
               },
               "stacks": {
                   "abc@sample.com": {
                       "{{apiKey}}": ["{****}"]
                   },
                   "xyz@sample.com": {
                   }
               },
               "message": "Invitation message"
           }
       }

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.organizations('organization_uid').organization_add_users(data).json()

fetch

The fetch method retrieves the organization entries.

Returns:
Type
JSON
NameTypeDescription

organization_uid (required)

str

UID of the organization

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.organizations('organization_uid').fetch().json()

find

The find method searches the organization entries.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.organizations().find()

logs

The log method retrieves the organization log entries.

Returns:
Type
JSON
NameTypeDescription

organization_uid (required)

str

UID of the organization

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.organizations('organization_uid').organization_logs().json()

roles

The roles method retrieves the organization roles entries.

Returns:
Type
JSON
NameTypeDescription

organization_uid (required)

str

UID of the organization

import contentstack_management 
client = contentstack_management.Client(authtoken='auth_token')

response = client.organizations('organization_uid').get_organization_roles().json()

stacks

The stacks method retrieves the organization stacks.

Returns:
Type
JSON
NameTypeDescription

organization_uid (required)

str

UID of the organization

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.organizations('organization_uid').organization_stacks()

transfer_ownership

The transfer_ownership method transfers the ownership of the organization to another user.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The email address of the user to whom you intend to transfer ownership.

organization_uid (required)

str

UID of the organization

data = {
     "transfer_to": "abc@sample.com"
  }

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.organizations('organization_uid').transfer_organizations_ownership(data)

Stack

A stack is a repository or a container that holds all the content/assets of your site. It allows multiple users to create, edit, approve, and publish their content within a single space.

The stack function initializes an instance of the “Stack”.

accept_ownership

The accept_ownership method allows the user to take control of the stack.

Returns:
Type
JSON
NameTypeDescription

user_uid (required)

str

UID of the user

ownership_token

str

The ownership token received via email by another user.

import contentstack_management
client = contentstack.ContentstackClient(authtoken='the_authtoken')
response = client.stack('api_key').accept_ownership('user_id', 'ownership_token')

assets

Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use. The assets method retrieves a specific asset in the stack

Returns:
Type
JSON
NameTypeDescription

asset_uid

str

UID of the asset

branch

str

Branch where the asset is added

import contentstack_management
client = contentstack_management.Client(authtoken="auth_token")
assets = client.stack(api_key).assets()

auditlog

A auditLog displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content.

Returns:
Type
JSON
NameTypeDescription

log_item_uid

str

UID of the item

import contentstack_management
client = contentstack_management.Client(authtoken="auth_token")
response = client.stack(api_key).auditlog()

branch

Branch corresponds to Stack branch.

Returns:
Type
JSON
NameTypeDescription

branch_uid

str

UID of the branch

import contentstack_management
client = contentstack_management.Client(authtoken="auth_token")
response = client.stack(api_key).branch()

branch_alias

Branch alias corresponds to the alias of that branch.

Returns:
Type
JSON
NameTypeDescription

alias_uid

str

UID of the alias

import contentstack_management
client = contentstack_management.Client(authtoken="auth_token")
response = client.stack(api_key).branch_alias()

content_types

Content type defines the structure or schema of a page or a section of your web or mobile property.

Returns:
Type
JSON
NameTypeDescription

content_type_uid

str

UID of the content type

import contentstack_management
client = contentstack_management.Client(authtoken="auth_token")
response = client.stack(api_key).content_types()

create

The create method creates a new stack.

Returns:
Type
JSON
NameTypeDescription

organization_uid (required)

str

UID of the organization

data (required)

Dict

The request body.

data = {
   "stack": {
        "name": "My New Stack",
        "description": "My new test stack",
        "master_locale": "en-us"
        }
     }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack().create('organization_uid', data).json()


create_settings

The create_settings method creates stack settings

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body.

data = {
           "stack_settings": {
               "stack_variables": {
                   "enforce_unique_urls": 'true',
                   "sys_rte_allowed_tags": "style,figure,script",
                   "sys_rte_skip_format_on_paste": "GD:font-size"
              },
               "rte": {
                   "cs_only_breakline": 'true'
               }
           }
       }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack('api_key').create_stack_settings(data).json()

delete

The delete method deletes the stack from the organization.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').delete()

environment

The environment method retrieves the details of the environment added in the stack.

Returns:
Type
JSON
NameTypeDescription

environment_name

str

Name of the environment

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').environment()

fetch

The fetch method retrieves the entries from the stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack('api_key').fetch()

global_fields

Global field defines the structure or schema of a page or a section of your web or mobile property.

Returns:
Type
JSON
NameTypeDescription

global_field_uid

str

UID of the global field

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack().global_field()

metadata

Metadata is a piece of information that lets you describe or classify an asset/entry. You can manage your digital entities effectively and facilitate enhanced accessibility with additional metadata.

Returns:
Type
JSON
NameTypeDescription

metadata_uid

str

UID of the metadata

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack().metadata()

reset_settings

The reset_settings method resets the stack settings.

Returns:
Type
JSON
NameTypeDescription

data

Dict

The request body.

data = {
      "stack_settings":{}
   }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack('api_key').reset_stack_settings(data)


roles

The roles method retrieves the details of the user roles in the stack.

Returns:
Type
JSON
NameTypeDescription

roles_uid (required)

str

UID of the user role

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack().roles()

settings

The settings method retrieves the settings of the stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack('api_key').settings()

share

The share method shares the stack with the users.

Returns:
Type
JSON
NameTypeDescription

data

Dict

The request body

data = {
           "emails": [
               "*****"
           ],
           "roles": {
               "manager@example.com": [
                   "*******"
               ]
           }
       }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack('api_key').share_stack(data).json()

transfer_ownership

The transfer_ownership method transfers the ownership of the stack to another user.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
            "transfer_to": "manager@example.com"
        }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').transfer_ownership(data)

unshare

The unshare method removes access to a stack from users who have specific user roles.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
    "email": "manager@example.com"
  }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack('api_key').unshare(data)

update

The update method updates the stack entries.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
"stack": {
    "name": "My New Stack",
    "description": "My new test stack",
    "master_locale": "en-us"
    }
}
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').update(data).json()

update_user_roles

The update_user_roles method updates all the user roles of the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
    "users": {
        "user_uid": ["role_uid1", "role_uid2"]
      }
  }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').update_user_role(data)

users

The users method retrieves the details of all the users of a stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack().users()

webhooks

A Webhook is a mechanism that sends real-time information to any third-party app or service to keep your application in sync with your Contentstack account.

Returns:
Type
JSON
NameTypeDescription

webhook_uid

str

UID of the webhook

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack().webhooks()

workflows

A Workflow is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly.

Returns:
Type
JSON
NameTypeDescription

workflow_uid

str

UID of the workflow

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')

response = client.stack().workflows()

Content Types

Content Type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type.

create

The create method creates a new content type in a particular stack.

Returns:
Type
Content Type
NameTypeDescription

data (required)

Dict

The request body

import contentstack_management
data = {
            "content_type": {
                    "title": "test content type",
                    "uid": "content_type_uid",
                    "schema": [{
                                    "display_name": "Title",
                                    "uid": "title",
                                    "data_type": "text",
                                    "field_metadata": {
                                            "_default": True
                                    },
                                    "unique": False,
                                    "mandatory": True,
                                    "multiple": False
                            },
                            {
                            "display_name": "URL",
                            "uid": "url",
                            "data_type": "text",
                            "field_metadata": {
                                    "_default": True
                            },
                            "unique": False,
                            "multiple": False
                        }
                        ],
                        "options": {
                            "title": "title",
                            "publishable": True,
                            "is_page": True,
                            "singleton": False,
                            "sub_title": [
                                    "url"
                                    ],
                                "url_pattern": "/:title",
                                "url_prefix": "/"
                            }
                    }
            }
content_type = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').content_type()
response = content_type.create(data)

delete

The delete method deletes an existing content type in a particular stack

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.delete()

entry

The entry method retrieves the details of a particular entry in the content type.

Returns:
Type
JSON
NameTypeDescription

entry_uid (required)

str

UID of the entry

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.entry()

export

The export method exports a specific content type and its schema.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

import contentstack
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.export()

fetch

The fetch method retrieves the details of a specific content type.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.fetch()

find

The find method retrieves the details of all content types.

Returns:
Type
JSON
import contentstack
import contentstack_management
content_type = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').content_type()
response = content_type.find()

imports

The imports method imports the content type into the stack by uploading a JSON file.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

file_path (required)

str

File path of the content type to be uploaded

import contentstack
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.imports(file_path)

references

The references method retrieves the details of the content types in which a specific content type is referred.

Returns:
Type
JSON
import contentstack
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.references()

set_field_visibility_rules

The set_field_visibility_rules method lets you add the field visibility rules to an existing content type.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

Data (required)

Dict

The Request body

import contentstack
import contentstack_management
data = {
                "content_type": {
                "title": "updatedContentType",
                "uid": "content_type_uid",
                "schema": [{
                            "display_name": "Title",
                                "uid": "title",
                                "data_type": "text",
                                "field_metadata": {
                                    "_default": True
                                },
                                "unique": False,
                                "mandatory": True,
                                "multiple": False
                        },
                            {
                                    "display_name": "URL",
                                    "uid": "url",
                                    "data_type": "text",
                                "field_metadata": {
                                        "_default": True
                                },
                                "unique": False,
                                "multiple": False
                            },
                            {
                                    "display_name": "Single Line Textbox",
                                    "uid": "single_line_textbox",
                                "data_type": "text",
                                "field_metadata": {
                                    "_default": True
                                },
                                "unique": False,
                                "multiple": False
                            },
                            {
                                    "display_name": "Multi Line Textbox",
                                    "uid": "multi_line_textbox",
                                    "data_type": "text",
                                    "field_metadata": {
                                            "_default": True
                                    },
                                    "unique": False,
                                    "multiple": False
                            }
                    ],
                    "field_rules": [{
                            "conditions": [{
                                    "operand_field": "single_line_textbox",
                                    "operator": "equals",
                                    "value": "abc"
                            }],
                            "match_type": "all",
                            "actions": [{
                            "action": "show",
                                    "target_field": "multi_line_textbox"
                            }]
                    }],
                    "options": {
                            "title": "title",
                            "publishable": True,
                            "is_page": True,
                            "singleton": False,
                            "sub_title": ["url"],
                            "url_pattern": "/:title",
                            "url_prefix": "/"
                        }
                }
        }
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type('content_type_uid')
response = content_type.set_field_visibility_rules(data)

update

The update method updates the schema of an existing content type

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

Data (required)

Dict

The Request body

import contentstack
import contentstack_management
data = {
        >>>        "content_type": {
        >>>         "title": "updated content type",
        >>>         "uid": "content_type_uid",
        >>>         "schema": [
        >>>             {}
            >>>            ],
            >>>            "options": {
            >>>             "title": "title",
            >>>             "sub_title": [
            >>>                     "url"
            >>>             ],
            >>>             "url_pattern": "/:title",
            >>>             "url_prefix": "/"
            >>>             }
            >>>           }
        >>>        }
client = contentstack_management.Client(authtoken='auth_token')
content_type = client.stack(api_key='api_key').content_type("content_type_uid")
response = content_type.update(data)

Global Fields

Global Field defines the structure or schema of a page or a section of your web or mobile property. To create Global Fields for your application, you are required to first create a Global Field.

create

The create method creates a new global field in a particular stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
           "global_field": {
               "title": "Servlet",
               "uid": "servlet",
           "schema": [{
                   "display_name": "Name",
                   "uid": "name",
                   "data_type": "text"
               }
       }
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').global_fields().create(data)

delete

The delete method deletes an existing global field from a particular stack.

Returns:
Type
JSON
NameTypeDescription

global_field_uid (required)

str

UID of the global field

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
response = client.stack('api_key').global_fields('global_field_uid').delete()

export

The export method exports the existing global fields from a particular stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').global_fields().export().json()

fetch

The fetch method retrieves the details of a specific global field from a particular stack.

Returns:
Type
JSON
NameTypeDescription

global_field_uid (required)

str

UID of the global field

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').global_fields('global_field_uid').fetch().json()

find

The find method retrieves the details of all global fields from a particular stack.

Returns:
Type
Content Type
import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack("api_key").global_fields('global_field_uid').find().json()

imports

The imports method imports the global field into a particular stack.

Returns:
Type
JSON
NameTypeDescription

global_field_uid (required)

str

UID of the global field

file_path (required)

str

File path of the global field to be imported

import contentstack_management
client = contentstack_management.Client(authtoken='auth_token')
response = client.stack('api_key').global_fields('global_field_uid').imports().json()

update

The update method updates the details of an existing global field.

Returns:
Type
JSON
NameTypeDescription

global_field_uid (required)

str

UID of the global field

data (required)

Dict

The Request body

data = {
           "global_field": {
               "title": "Servlet",
               "uid": "servlet",
               "schema": [{
                   "display_name": "Name",
                   "uid": "name",
                   "data_type": "text"
               }
       }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
response = client.stack('api_key').global_fields('global_field_uid').update(data)

Entry

An entry is the actual piece of content created using one of the defined content types. Read more about Entries.

create

The create method creates a new entry for the selected content type in a particular stack.

Returns:
Type
Entry
NameTypeDescription

data (required)

Dict

The content of the new entry that you want to create.

data = {
           "global_field": {
               "title": "Servlet",
               "uid": "servlet",
           "schema": [{
                   "display_ndata = {
         "entry": {
                    "title": "example",
                    "url": "/example"
                 }
        }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types().entry().create(data).json()

delete

The delete method deletes an existing entry for the selected content type in a particular stack.

Returns:
Type
Entry
NameTypeDescription

entry_uid (required)

str

UID of the entry

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').delete().json()

export

The export method exports an existing entry in a JSON format.

Returns:
Type
Entry
NameTypeDescription

entry_uid (required)

str

UID of the entry

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types(''content_type_uid'').entry('entry_uid').export().json()

fetch

The fetch method retrieves the details of an existing entry.

Returns:
Type
Entry
NameTypeDescription

entry_uid (required)

str

UID of the entry

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').fetch().json()

find

The find method retrieves the details of all existing entries.

Returns:
Type
Entry
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack("api_key").content_types('content_type_uid').entry().find().json()

addParam

The addParam method adds a parameter to the request.

Returns:
Type
JSON
NameTypeDescription

key (required)

str

Query parameter key for the request

value (required)

str/int

Query parameter value for the request

Example 1:

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
query = client.stack('api_key').content_types('content_type_uid').entry()
query.add_param("limit", 2)
result = query.find()

Example 2:

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
query = client.stack('api_key').content_types('content_type_uid').entry()
query.add_param("skip", 2)
result = query.find()

addParam with Dictionary

The addParam with Dictionary method adds multiple parameters to the request.

Returns:
Type
JSON
NameTypeDescription

testdict (required)

dict

Query parameter dictionary for the request

Example:

import contentstack_management
testdict =	{
  "limit": 2,
  "skip": 2,
  "include_branch": True
}

client = contentstack_management.Client(authtoken='your_authtoken')
query = client.stack('api_key').content_types('content_type_uid').entry()
query.add_param_dict(testdict)
result = query.find()

addHeader

The addHeader method adds a header to the request.

Returns:
Type
JSON
NameTypeDescription

key (required)

str

Header key for the request

value (required)

obj

Header value for the request

Example:

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
query = client.stack('api_key').content_types('content_type_uid').entry()
query.add_header("branch", "branch_uid")
result = query.find()

addHeader with Dictionary

The addHeader with Dictionary method adds multiple headers to the request.

Returns:
Type
JSON
NameTypeDescription

testdict (required)

dict

Query parameter dictionary for the request

Example:

import contentstack_management
testdict =	{
  "branch": "branch_uid"
}
client = contentstack_management.Client(authtoken='your_authtoken')
query = client.stack('api_key').content_types('content_type_uid').entry()
query.add_header_dict(testdict)
result = query.find()

import

The import method imports the entries in the JSON.

Returns:
Type
Entry
NameTypeDescription

entry_uid (required)

str

UID of the entry

file_path (required)

str

The file path of the file you want to import

locale

str

The language for the entry. Set to en-us by default

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

file_path = "tests/resources/mock_content_types/import_content_types.json"
response = client.stack('api_key').content_types().entry('entry_uid').imports(file_path).json()

language

The languages method retrieves the details of all the languages that an entry exists in.

Returns:
Type
Entry
NameTypeDescription

entry_uid (required)

str

UID of the entry

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').languages().json()

publish

The publish method allows you to publish an entry for a specified environment either immediately or schedule it for a later date/time.

Returns:
Type
Entry
NameTypeDescription

data (required)

Dict

The data you want to publish

data = {
               "entry": {
                   "environments": ["development"],
                   "locales": ["en-us"]
               },
               "locale": "en-us",
               "version": 1,
               "scheduled_at": "2019-02-14T18:30:00.000Z"
           }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types().entry('entry_uid').publish(data).json()

localize

The localize method will allow you to localize an entry, i.e., the entry will cease to retrieve the data from the fallback language and possess an independent content specific to the selected locale.

Returns:
Type
Entry
NameTypeDescription

data (required)

Dict

Fields and values that you want to add or update for the specified locale

locale (required)

str

The language for the entry. Set to en-us by default

data ={
              "entry": {
                  "title": "Home",
                   "url": "/home-french",
                   "tags": [],
                   "locale": "en-us",
                   "uid": "entry_uid",
                   "created_by": "user_uid",
                   "updated_by": "user_uid",
                   "created_at": "2017-06-13T12:34:52.083Z",
                   "updated_at": "2018-12-28T06:33:06.752Z",
                   "ACL": {},
                   "_version": 2
                   }
           }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').localize(data).json()

references

The references method retrieves the details of all the entries referenced by a particular entry.

Returns:
Type
Entry
NameTypeDescription

entry_uid (required)

str

UID of the entry

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').references().json()

unlocalize

The unlocalize method will allow you to unlocalize an existing entry, i.e., the entry will retrieve the data from the fallback language.

Returns:
Type
Entry
NameTypeDescription

locale (required)

str

The language for the entry. Set to en-us by default.

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').unlocalize().json()

unpublish

The unpublish method allows you to unpublish an entry for a specified environment either immediately or schedule it for a later date/time.

Returns:
Type
Entry
NameTypeDescription

data (required)

Dict

The content type UID and any additional data required for the unpublishing process

data = {
               "entry": {
                   "environments": ["development"],
                   "locales": ["en-us"]
               },
               "locale": "en-us",
               "version": 1,
               "scheduled_at": "2019-02-14T18:30:00.000Z"
           }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types().entry('entry_uid').unpublish().json()

update

The update method allows you to make changes in the contents of an existing entry.

Returns:
Type
Entry
NameTypeDescription

data (required)

Dict

The content type UID and any additional data required for the unpublishing process

locale (required)

str

The language for the entry. Set to en-us by default.

data = {
          "entry": {
                   "title": "example",
                   "url": "/example"
           }
        }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').update(data).json()

version_naming

The version_naming method allows you to assign a name to a specific version of an entry.

Returns:
Type
Entry
NameTypeDescription

data (required)

Dict

The information you want to send to the server

version_number (required)

str

The identifier to a specific version of an entry.

data ={
               "entry": {
                   "_version_name": "Test version",
                   "locale": "en-us",
                   "force": true
               }
           }
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

response = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').version_naming(data).json()

Asset

Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use. These files can be attached and used in multiple entries.

create_folder

The create_folder method creates a new asset folder and/or adds a parent folder to it in a particular stack.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The data you want to send to the server when creating a folder.

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

data = {
    >>>     "asset": {
        >>>         "name": "Demo"
    >>>     }
}
asset = client().stack(api_key='api_key').assets()
response = asset.create_folder(data)

delete_folder

The delete_folder method removes an existing asset folder along with all the assets within that folder.

Returns:
Type
Asset
NameTypeDescription

folder_uid (required)

str

The UID of the folder you want to delete

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.delete(folder_uid='folder_uid')

delete

The delete method removes an existing asset from the stack.

Returns:
Type
Asset
NameTypeDescription

asset_uid (required)

str

UID of the asset

client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.delete("asset_uid")

download

The download method lets you save the specific asset in your local storage.

Returns:
Type
Asset
NameTypeDescription

asset_uid (required)

str

UID of the asset

client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.download()

fetch

The fetch method retrieves the details of a specific version of a particular asset

Returns:
Type
Asset
NameTypeDescription

asset_uid (required)

str

UID of the asset

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.fetch("asset_uid")

find

The find method retrieves the details of all assets in a stack.

Returns:
Type
Asset
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.find()

folder

The folder method retrieves the details of a specific asset folder in the stack using the folder UID.

Returns:
Type
Asset
NameTypeDescription

folder_uid (required)

str

UID of the folder

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.folder_collection(folder_uid='folder_uid')

folder_by_name

The folder_by_name method retrieves the details of a specific asset folder in the stack using the folder name.

Returns:
Type
Asset
NameTypeDescription

query (required)

str

The search query for the folder

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

query = {"is_dir": True, "name": "folder_name"}
asset = client().stack(api_key='api_key').assets()
response = asset.folder_collection(query)

generate

The generate method allows you to generate a permanent asset URL for the specific asset.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The data to be sent in the request body

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

data = {
   "asset": {
       "permanent_url": "https://images.contentstack.io/v3/assets/stack_api_key/asset_UID/sample-slug.jpeg"
       }
   } 
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.generate(data)

get_subfolders

The get_subfolders method retrieves the details of only the subfolder within a specific asset folder in the stack.

Returns:
Type
Asset
NameTypeDescription

folder_uid (required)

str

The UID of the folder

query (required)

str

The search query for the folder

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

query = {"is_dir": True}
asset = client().stack(api_key='api_key').assets()
response = asset.folder_collection(folder_uid='folder_uid', query)

publish

The publish method allows you to publish a specific version of the asset on the required environment either immediately or at a later time/date.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The data that you want to publish.

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
data = {
         "asset": {
                 "locales": [
                         "en-us"
                 ],
                 "environments": [
                         "development"
                 ]
         },
         "version": 1,
         "scheduled_at": "2019-02-08T18:30:00.000Z"
}
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.publish(data)

references

The references method retrieves the details of the entries and content types in which a specific asset is referenced.

Returns:
Type
Asset
NameTypeDescription

asset_uid (required)

str

UID of the asset

client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.references()

replace

The replace method allows you to replace an existing asset with another file in the stack.

Returns:
Type
Asset
NameTypeDescription

file_path (required)

str

The path to the file that you want to replace the existing asset with.

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

file_path = ""
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.replace(file_path)

rte

The rte method retrieves the details of all the assets uploaded through the Rich Text Editor field.

Returns:
Type
Asset
import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.rte()

specific_asset_type

The specific_asset_type method retrieves the assets based on the query request.

Returns:
Type
Asset
NameTypeDescription

asset_type

str

The type of asset you want to retrieve

client = contentstack_management.Client(authtoken="authtoken")

asset_type = "images"
asset = client().stack(api_key='api_key').assets()
response = asset.specific_asset_type(asset_type)

specific_folder

The specific_folder method retrieves the details of assets of a specific asset folder without the subfolders in the requested parent folder.

Returns:
Type
Asset
NameTypeDescription

folder_uid (required)

str

UID of the folder

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.specific_folder("folder_uid")

subfolder

The subfolder method retrieves the details of assets and subfolders of a specific parent folder.

Returns:
Type
Asset
NameTypeDescription

folder_uid (required)

str

UID of the folder

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets()
response = asset.subfolders("folder_uid")

unpublish

The unpublish method allows you to unpublish a specific version of an asset from a desired environment.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The data you want to send to server for the unpublish operation

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
data = {
         "asset": {
                 "locales": [
                         "en-us"
                 ],
                 "environments": [
                         "development"
                ]
         },
         "version": 1,
         "scheduled_at": "2019-02-08T18:30:00.000Z"
}
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.unpublish(data)

update

The update method allows you to make changes in the title and description of an existing asset in the stack.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The updated information for the asset

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
data = {
         "asset": {
                 "title": "Title"
         }
}
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.update(data)

update_asset_revision

The update_asset_revision method upgrades the specified version of the asset to the latest version.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The updated information for the asset

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
data = {
         "asset": {
                 "title": "Title",
                 "description": "Description"
         },
         "version": 2
}
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.update_asset_revision(data)

update_or_move

The update_or_move method allows you to either update the details of a folder or set the folder as a parent folder if you want to move a folder under another folder.

Returns:
Type
Asset
NameTypeDescription

folder_uid (required)

str

UID of the folder

data (required)

Dict

The request body

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
data = {
         "asset": {
                 "name": "Demo"
         }
}
asset = client().stack(api_key='api_key').assets()
response = asset.update_or_move(folder_uid='folder_uid', data)

upload

The upload method allows you to upload an asset file in the stack.

Returns:
Type
Asset
NameTypeDescription

file_path (required)

str

The path to the file you want to upload

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")

file_path = ""
asset = client().stack(api_key='api_key').assets()
response = asset.upload(file_path)

version

The version method retrieves the details of all versions of an asset.

Returns:
Type
Asset
NameTypeDescription

asset_uid (required)

str

UID of the asset

client = contentstack_management.Client(authtoken="authtoken")

asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.version()

version_delete

The version_delete method allows you to remove the name of a specific version of an asset and resets it to the version number.

Returns:
Type
Asset
NameTypeDescription

version_number (required)

str

The version of the asset you want to delete

client = contentstack_management.Client(authtoken="authtoken")

version_number = 1
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.version_delete(version_number)

version_naming

The version_naming method allows you to assign a name to a specific version of an asset.

Returns:
Type
Asset
NameTypeDescription

data (required)

Dict

The information you want to update for the specified version

version_number (required)

str

The version of the asset you want to delete

import contentstack_management
client = contentstack_management.Client(authtoken="authtoken")
version_number = 1
data = {
         "upload": {
             "_version_name": "Version name"
         }
}
asset = client().stack(api_key='api_key').assets(asset_uid='asset_uid')
response = asset.version_naming(version_number, data)

Alias

An alias acts as a pointer to a particular branch. You can specify the alias ID in your frontend code to pull content from the target branch associated with an alias.

assign

The assign method creates a new alias in a particular stack of the organization.

Returns:
Type
Alias
NameTypeDescription

data (required)

Dict

The data you want to send to the server when creating a folder.

import contentstack_management
body = {
       "branch_alias": {
           "target_branch": "test"
           }
       }
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').alias("alias_uid")
response = branch.assign(data)

delete

The delete method removes an alias permanently from the stack

Returns:
Type
Alias
NameTypeDescription

branch_uid (required)

str

UID of the branch

import contentstack_management
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch(branch_uid="branch_uid")
response = branch.delete()

fetch

The fetch method retrieves the details of a particular alias.

Returns:
Type
Alias
NameTypeDescription

branch_alias_uid (required)

str

UID of the alias

import contentstack_management
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch_alias('branch_alias_uid')
response = branch.fetch()

find

The find method retrieves the details of all aliases available in the particular stack.

Returns:
Type
Alias
NameTypeDescription

limit (required)

Number

A limit on the number of objects to return

skip (required)

Number

The number of objects to skip before return

include_count (required)

Boolean

To retrieve the count of results in response

import contentstack_management
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch_alias()
response = branch.find()

Audit log

Audit log displays a record of all the activities performed in a stack and helps you keep a track of all published items, updates, deletes, and current status of the existing content.

fetch

The fetch method retrieves a specific item from the audit log of the stack

Returns:
Type
JSON
NameTypeDescription

log_item_uid (required)

str

UID of the item to be retrieved

import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').auditlog('log_item_uid').fetch().json()

find

The find method retrieves the complete audit log of the stack

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").auditlog().find().json()

Branches

Branches efficiently present independent workspaces where developers and content managers can work parallelly on content models and content. It helps sync the development activities of websites.

create

The create method creates a new branch in a particular stack of your organization.

Returns:
Type
Branch
NameTypeDescription

data (required)

Dict

Data required to create a new branch

import contentstack
import contentstack_management
data = {
        "branch": {
        "uid": "release",
        "source": "main"
        }
    }
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch()
response = branch.create(data)

delete

The delete method removes an existing branch from a particular stack of your organization.

Returns:
Type
Branch
NameTypeDescription

branch_uid (required)

str

UID of the branch

import contentstack
import contentstack_management
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch(branch_uid="branch_uid")
response = branch.delete(data)

fetch

The fetch method retrieves the details of a specific branch.

Returns:
Type
Branch
NameTypeDescription

branch_uid (required)

str

UID of the branch

import contentstack
import contentstack_management
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch(branch_uid="branch_uid")
response = branch.fetch()

find

The find method retrieves the details of all the branches in a particular branch.

Returns:
Type
Branch
NameTypeDescription

limit (required)

Number

A limit on the number of objects to return

skip (required)

Number

The number of objects to skip before return

include_count (required)

Boolean

To retrieve the count of results in response

import contentstack
import contentstack_management
branch = contentstack_management.Client(authtoken='auth_token').stack(api_key='api_key').branch()
response = branch.find()

Bulk Operations

Perform bulk operations, such as publish, unpublish, delete, or move, on entries and assets in a single action.

delete

The Delete entries and assets in bulk request allows you to delete multiple entries and assets at the same time.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

   data = {
       "entries":[{
           "content_type":"content_type_uid",
           "uid":"entry_uid",
           "locale":"locale"
       },{
           "content_type":"content_type_uid",
           "uid":"entry_uid",
           "locale":"entry_locale"
       }
       ],
       "assets": [{
           "uid": "uid"
       }]
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').bulk_operation().delete(data).json()

publish

The Publish entries and assets in bulk method allows you to publish multiple entries and assets at the same time.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
           "entries":[
               {
                   "uid":"entry_uid",
                   "content_type":"ct0",
                   "version":"5",
                   "locale":"en-us"
               },
               {
                   "uid":"entry_uid",
                   "content_type":"ct0",
                   "version":"1",
                   "locale":"en-us"
               },
               {
                   "uid":"entry_uid",
                   "content_type":"ct5",
                   "version":"2",
                   "locale":"en-us"
               }
           ],
           "locales":[
               "en-us"
           ],
           "environments":[
               "env1"
           ],
           "rules":{
               "approvals":"true/false"
           },
           "scheduled_at":"scheduled_time",
           "publish_with_reference":true
           }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').bulk_operation().publish(data).json()

unpublish

The Unpublish entries and assets in bulk method allows you to unpublish multiple entries and assets at the same time.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
       "entries": [
           {
           "content_type": "news",
           "uid": "entry_uid",
           "locale": "en-us"
           },
           {
           "content_type": "article",
           "uid": "entry_uid",
           "locale": "en-us"
           }
       ],
       "workflow": {
           "workflow_stage": {
           "comment": "String Comment",
           "due_date": "Thu Dec 01 2018",
           "notify": false,
           "uid": "workflow_uid",
           "assigned_to": [
               {
               "uid": "user_uid",
               "name": "user_name",
               "email": "user_email_ID"
               }
           ],
           "assigned_by_roles": [
               {
               "uid": "role_uid",
               "name": "Content Manager"
               }
           ]
           }
       },
       "locales": [
           "en-us"
       ],
       "environments": [
           "env_uid"
       ]
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').bulk_operation().unpublish(data).json()

update

The update method allows you to make changes in the existing entries/assets in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
       "entries": [{
           "content_type": "content_type_uid1",
           "uid": "entry_uid",
           "locale": "en-us"
       }, {
           "content_type": "content_type_uid2",
           "uid": "entry_uid",
           "locale": "en-us"
       }],
       "workflow": {
           "workflow_stage": {
               "comment": "Workflow-related Comments",
               "due_date": "Thu Dec 01 2018",
               "notify": false,
               "uid": "workflow_stage_uid",
               "assigned_to": [{
                   "uid": "user_uid",
                   "name": "user_name",
                   "email": "user_email_id"
               }],
               "assigned_by_roles": [{
                   "uid": "role_uid",
                   "name": "role_name"
               }]
           }
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').bulk_operation().update(data).json()

Delivery Token

Delivery Tokens are tokens that provide you with read-only access to the associated environments. It is a credential used along with the stack API key to make authorized Content Delivery API requests for retrieving the published content of an environment.

create

The create method allows you to create a new delivery token in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

  "token":{
           "name":"Test",
           "description":"This is a demo token.",
           "scope":[
               {
                   "module":"environment",
                   "environments":[
                       "production"
                   ],
                   "acl":{
                       "read":true
                   }
               },
               {
                   "module":"branch",
                   "branches":[
                       "main",
                       "development"
                   ],
                   "acl":{
                       "read":true
                   }
               },
               {
                   "module":"branch_alias",
                   "branch_aliases":[
                       "deploy",
                       "release"
                   ],
                   "acl":{
                       "read":true
                   }
               }
           ]
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').delivery_token().create(data).json()

delete

The delete method removes the existing delivery token from the stack.

Returns:
Type
Delivery Token
NameTypeDescription

delivery_token_uid (required)

str

UID of the delivery token

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').delivery_token('delivery_token_uid').delete().json()

fetch

The fetch method retrieves the details of a specific delivery token from the stack.

Returns:
Type
Delivery Token
NameTypeDescription

delivery_token_uid (required)

str

UID of the delivery token

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').delivery_token('delivery_token_uid').fetch().json()

find

The find method retrieves the details of all the delivery tokens created in the stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").delivery_token().find().json()

update

The update method allows you to make changes in the existing delivery token in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the delivery token

data = {
       "token":{
           "name":"Test",
           "description":"This is a updated token.",
           "scope":[
               {
                   "module":"environment",
                   "environments":[
                       "production"
                   ],
                   "acl":{
                       "read":true
                   }
               },
               {
                   "module":"branch",
                   "branches":[
                       "main",
                       "development"
                   ],
                   "acl":{
                       "read":true
                   }
               },
               {
                   "module":"branch_alias",
                   "branch_aliases":[
                       "deploy"
                   ],
                   "acl":{
                       "read":true
                   }
               }
           ]
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').delivery_token("delivery_token_uid").update(data).json()

Environment

An environment allows users to publish their content on the destination URL. After you create an entry, you will publish it in an environment. After publishing, you will see the content on your website’s URL (specified in the environment). Being not limited to a single environment, you can publish content on multiple environments too.

create

The create method adds a new publishing environment in your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new environment

       "environment": {
           "name": "development",
           "urls": [{
               "locale": "en-us",
               "url": "http://example.com/"
           }]
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').environments().create(data).json()

delete

The delete method removes an existing environment from a particular stack of your organization.

Returns:
Type
Environment
NameTypeDescription

environment_name (required)

str

Name of the environment you want to delete

import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').environments('environment_name').delete().json()

fetch

The fetch method retrieves the details of a specific environment from the stack.

Returns:
Type
Environment
NameTypeDescription

environment_name (required)

str

Name of the environment you want to fetch

import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').environments('environment_name').fetch().json()

find

The find method retrieves the details of all the environments in a particular stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").environments().find().json()

update

The update method allows you to make changes in the existing environment for a stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the environment

data = {
       "environment": {
           "name": "development",
           "urls": [{
               "locale": "en-us",
               "url": "http://example.com/"
           }]
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').environments("environment_name").update(data).json()

Extensions

Extensions typically refer to additional functionalities, customizations, or integrations that developers can add to a content management system. Contentstack provides a variety of extensions to enhance your functionality such as Dashboard Extensions, Asset Sidebar Extensions, Sidebar Extensions, Experience Extensions.

create

The create method adds a new extension in a particular stack of your Contentstack account.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new extension

    extension = {
           tags: [
           'tag1',
           'tag2'
           ],
           data_type: 'text',
           title: 'Old Extension',
           src: "Enter either the source code (use 'srcdoc') or the external hosting link of the extension depending on the hosting method you selected.",
           multiple: false,
           config: {},
           type: 'field'
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').extension("extension_uid").update(extension).json()

delete

The Delete method removes an extension permanently from your stack.

Returns:
Type
JSON
NameTypeDescription

extension_uid (required)

str

UID of the extension

 client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').extension('extension_uid').delete().json()

fetch

The fetch method retrieves information about the specified extension.

Returns:
Type
JSON
NameTypeDescription

extension_uid (required)

str

UID of the extension

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').extension('extension_uid').fetch().json()

find

The find method retrieves the data about all extensions in the stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").extension().find().json()

update

The update method allows you to make changes in the existing extensions in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

data = {
       "extension": {
           "tags": [
               "tag1",
               "tag2"
           ],
           "data_type": "text",
           "title": "Old Extension",
           "src": "Enter either the source code (use 'srcdoc') or the external hosting link of the extension depending on the hosting method you selected.",
           "multiple": false,
           "config": "{}",
           "type": "field"
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').extension("extension_uid").update(data).json()

upload

The upload method is used to upload a new extension to your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The request body

extension = {
       "file_name": "demo.html",
       "file_path": "/Users/sunil.lakshman/Downloads/demo.html",
       "data_type": 'text',
       "title": 'Old Extension',
       "multiple": False,
       "tags": {},
       "type": 'dashboard'
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').extension().upload(extension).json()

Management Token

Management Tokens are tokens that provide you with read-write access to the content of your stack. It is a credential used along with the stack API key to make authorized Content Management API (CMA) requests for managing content of your stack.

create

The create method allows you to create a new management token in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

"token":{
           "name":"Test Token",
           "description":"This is a sample management token.",
           "scope":[
               {
                   "module":"content_type",
                   "acl":{
                       "read":true,
                       "write":true
                   }
               },
               {
                   "module":"branch",
                   "branches":[
                       "main",
                       "development"
                   ],
                   "acl":{
                       "read":true
                   }
               },
               {
                   "module":"branch_alias",
                   "branch_aliases":[
                       "deploy",
                       "release"
                   ],
                   "acl":{
                       "read":true
                   }
               }
           ],
           "expires_on":"2020-12-10",
           "is_email_notification_enabled":true
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').management_token().create(data).json()

delete

The delete method removes the existing management token from the stack.

Returns:
Type
JSON
NameTypeDescription

management_token_uid (required)

str

UID of the management token

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').management_token('management_token_uid').delete().json()

fetch

The fetch method retrieves the details of a specific management token from the stack.

Returns:
Type
JSON
NameTypeDescription

management_token_uid (required)

str

UID of the management token

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').management_token('management_token_uid').fetch().json()

find

The find method retrieves the details of all the management tokens created in the stack.

Returns:
Type
JSON
NameTypeDescription

management_token_uid (required)

str

UID of the management token

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").management_token().find().json()

update

The update method allows you to make changes in the existing management token in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the management token

data = {
       "token":{
           "name":"Updated Test Token",
           "description":"This is an updated management token.",
           "scope":[
               {
                   "module":"content_type",
                   "acl":{
                       "read":true,
                       "write":true
                   }
               },
               {
                   "module":"entry",
                   "acl":{
                       "read":true,
                       "write":true
                   }
               },
               {
                   "module":"branch",
                   "branches":[
                       "main",
                       "development"
                   ],
                   "acl":{
                       "read":true
                   }
               },
               {
                   "module":"branch_alias",
                   "branch_aliases":[
                       "deploy"
                   ],
                   "acl":{
                       "read":true
                   }
               }
           ],
           "expires_on":"2020-12-31",
           "is_email_notification_enabled":true
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').management_token("management_token_uid").update(data).json()

Metadata

Metadata is a piece of information that lets you describe or classify an asset/entry.

create

The create method allows you to create a new metadata for a specific entry or asset.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

    "metadata": {
           "entity_uid": "entity_uid",
           "type": "entry",
           "_content_type_uid": "sample_content",
           "extension_uid": "extension_uid",
           "presets": [{
               "uid": "presents_uid",
               "name": "Test1",
               "options": {
               }
           }]
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').metadata().create(data).json()

delete

The delete method removes the metadata associated with a specific entry or asset.

Returns:
Type
JSON
NameTypeDescription

metadata_uid (required)

str

UID of the metadata

import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').metadata('metadata_uid').delete().json()

fetch

The fetch method retrieves the details of the metadata attached to a specific asset or entry of a stack.

Returns:
Type
JSON
NameTypeDescription

metadata_uid (required)

str

UID of the metadata

import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').metadata('metadata_uid').fetch().json()

find

The find method retrieves the details of all the metadata attached to all the entries and assets in your stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").metadata().find().json()

publish

The publish method allows you to publish the metadata associated with a specific entry or asset.

Returns:
Type
JSON
NameTypeDescription

metadata_uid (required)

str

UID of the metadata

       "metadata": {
           "environments": [
           "test"
           ],
           "locales": [
           "en-us"
           ]
       }
       }
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').metadata('metadata_uid').publish(data).json()

unpublish

The unpublish method allows you to unpublish the metadata associated with a specific entry or asset.

Returns:
Type
JSON
NameTypeDescription

metadata_uid (required)

str

UID of the metadata

data = {
       "metadata": {
           "environments": [
           "test"
           ],
           "locales": [
           "en-us"
           ]
       }
       }
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').metadata('metadata_uid').unpublish(data).json()

update

The update method allows you to make changes in the metadata for a specific entry or asset.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the metadata

data = {
       "metadata": {
           "entity_uid": "entity_uid",
           "type": "entry",
           "extension_uid": "extension_uid",
           "locale": "en_us",
           "_content_type_uid": "_content_type_uid",
           "presets": [{
                   "uid": "presets_uid",
                   "name": "test1",
                   "options": {}
               },
               {
                   "name": "Test3",
                   "uid": "presets_uid",
                   "options": {
                       "quality": "100",
                       "transform": {
                           "height": 500,
                           "width": 500
                       },
                       "image-type": "jpeg",
                       "focal-point": {
                           "x": 0,
                           "y": 0
                       }
                   }
               }
           ]
       }
   }
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').metadata("metadata_uid").update(data).json()

Publish Queue

When the Content Manager publishes an entry and/or asset, the system puts the action into a publish queue. Publish/unpublish activities in this queue are performed one at a time, almost at a high speed. This eliminates the need to wait for an entry to be published before moving on to the next item. You can keep publishing items and let the system manage the queue.

cancel

The “Cancel Scheduled Action” method allows you to cancel any scheduled publishing or unpublishing activity of entries and/or assets and cancel the deployment of releases.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

  client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').publish_queue().create(data).json()

fetch

The fetch method retrieves comprehensive information on a specific publish, unpublish, or delete action performed on an entry and/or asset. You can also retrieve details of a specific release deployment.

Returns:
Type
JSON
NameTypeDescription

publish_queue_uid (required)

str

UID of the publish queue

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').publish_queue('publish_queue_uid').fetch().json()

find

The find method retrieves comprehensive information on activities such as publish, unpublish, and delete performed on entries and/or assets. This request also includes the details of the release deployments in the response body.

Returns:
Type
JSON
NameTypeDescription

publish_queue_uid (required)

str

UID of the publish queue

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").publish_queue().find().json()

Release Items

Release items are the entries or assets that you intend to publish on your website and have included in a scheduled release.

create

The create method allows you to add a new item in the scheduled release.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

  "item": {
           "version": 1,
           "uid": "entry_or_asset_uid",
           "content_type_uid": "your_content_type_uid",
           "action": "publish",
           "locale": "en-us"
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases('release_uid').item().create(data)


create_multiple

The create method allows you to add multiple new items in the scheduled release.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

 "items": [{
           "uid": "entry_or_asset_uid1",
           "version": 1,
           "locale": "en-us",
           "content_type_uid": "demo1",
           "action": "publish"
       }, {
           "uid": "entry_or_asset_uid2",
           "version": 4,
           "locale": "fr-fr",
           "content_type_uid": "demo2",
           "action": "publish"
       }]
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases('release_uid').item().create_multiple(data)

delete

The delete method removes an item from the specific release.

Returns:
Type
Release Item
NameTypeDescription

data (required)

Dict

The request body

release_uid (required)

str

UID of the release

data = {
       "items": [{
           "uid": "items_uid",
           "version": 1,
           "locale": "ja-jp",
           "content_type_uid": "category",
           "action": "publish"
       }]
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = result = client.stack('api_key').releases('release_uid').item().delete(data)

delete_multiple

The delete_multiple method removes one or more items from the specific release.

Returns:
Type
Release Item
NameTypeDescription

data (required)

Dict

The request body

release_uid (required)

str

UID of the release

data = {
       "items": [{
           "uid": "item_uid",
           "locale": "en-us",
           "version": 1,
           "content_type_uid": "your_content_type_uid",
           "action": "publish_or_unpublish"
       }]
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = result = client.stack('api_key').releases('release_uid').item().delete_multiple(data)

find

The find method retrieves the details of all the items that are a part of the specific release.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").releases("release_uid").item().find()

update

The update method allows you to update the items in the specific release to their latest version before deployment.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the Release Item

item_uid (required)

str

UID of the item

data = {
   "items":[
       "$all"
   ]
 }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases("release_uid").item().update(data)

Release

You can define a “Release” as a set of entries and assets that needs to be deployed (published or unpublished) all at once to a particular environment.

clone

The clone method allows you to make a copy of a specific release in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

data = {

Data you want to send in the request body

data = {
       "release": {
           "name": "New Release Name",
           "description": "2018-12-12"
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases('release_uid').clone(data).json()

create

The create method allows you to create a new release in your stack. To add entries/assets to a release, you need to provide the UIDs of the entries/assets in items in the request body.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

data = {
       "release": {
           "name": "Release Name",
           "description": "2018-12-12",
           "locked": false,
           "archived": false
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases().create(data).json()

delete

The delete method removes a specific release from your stack.

Returns:
Type
Release
NameTypeDescription

release_uid (required)

str

UID of the release

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases('release_uid').delete().json()

deploy

The deploy method will publish/unpublish all the items of the release to the specified environment.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data you want to send in the request body

data = {
          "release": {
           "environments": [
               "development"
           ]
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases('release_uid').deploy(data).json()

fetch

The fetch method retrieves the details of a specific release from the stack.

Returns:
Type
JSON
NameTypeDescription

release_uid (required)

str

UID of the release

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases('release_uid').fetch().json()

find

The find method retrieves the details of all the releases in the stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").releases().find().json()

update

The update method allows you to update the details of a Release.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the Release

release_uid (required)

str

UID of the release

data = {
       "release": {
           "name": "Release Name",
           "description": "2018-12-22"
       }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').releases("release_uid").update(data).json()

Roles

A role is a collection of permissions that will be applicable to all the users who are assigned this role.

create

The create method adds a new role in your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new role

data = {
	"role": {
		"name": "testRole",
		"description": "This is a test role.",
		"rules": [
			{
				"module": "branch_alias",
				"branch_aliases": [
					"deploy"
				],
				"acl": {
					"read": true
				}
			},
			{
				"module": "content_type",
				"content_types": [
					"$all"
				],
				"acl": {
					"read": true,
					"sub_acl": {
						"read": true
					}
				}
			},
			{
				"module": "asset",
				"assets": [
					"$all"
				],
				"acl": {
					"read": true,
					"update": true,
					"publish": true,
					"delete": true
				}
			},
			{
				"module": "environment",
				"environments": [
					"$all"
				],
				"acl": {
					"read": true
				}
			},
			{
				"module": "taxonomy",
				"taxonomies": [
					"taxonomy_UID"
				],
				"terms": [
					"taxonomy_UID.term_UID"
				],
				"content_types": [
					{
						"uid": "$all",
						"acl": {}
					}
				]
			}
		]
	}
}
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').roles().create(data).json()

delete

The delete method removes an existing role from a particular stack of your organization.

Returns:
Type
Role
NameTypeDescription

role_uid (required)

str

UID of the role

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = response = client.stack('api_key').roles('role_uid').delete().json()

fetch

The fetch method retrieves the details of a specific role from the stack.

Returns:
Type
JSON
NameTypeDescription

role_uid (required)

str

UID of the role

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').roles('role_uid').fetch().json()

find

The find method retrieves the details of all the environments in a particular stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").roles().find().json()

update

The update method allows you to make changes in the existing role of your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated information for the role

data = {
       "role":{
           "name":"sampleRole",
           "description":"This is a test role.",
           "rules":[
           {
               "module":"branch",
               "branches":[
               "main"
               ],
               "acl":{
               "read":true
               }
           },
           {
               "module":"branch_alias",
               "branch_aliases":[
               "deploy"
               ],
               "acl":{
               "read":true
               }
           },
           {
               "module":"content_type",
               "content_types":[
               "$all"
               ],
               "acl":{
               "read":true,
               "sub_acl":{
                   "read":true
               }
               }
           },
           {
               "module":"asset",
               "assets":[
               "$all"
               ],
               "acl":{
               "read":true,
               "update":true,
               "publish":true,
               "delete":true
               }
           },
           {
               "module":"folder",
               "folders":[
               "$all"
               ],
               "acl":{
               "read":true,
               "update":true,
               "publish":true,
               "delete":true,
               "sub_acl":{
                   "read":true,
                   "update":true,
                   "publish":true,
                   "delete":true
               }
               }
           },
           {
               "module":"environment",
               "environments":[
               "$all"
               ],
               "acl":{
               "read":true
               }
           },
           {
               "module":"locale",
               "locales":[
               "$all"
               ],
               "acl":{
               "read":true
               }
           }
           ],
           "uid":"blt5a570885da41c710"
       }
       }
import contentstack_management 
client = contentstack_management.client(authtoken='your_authtoken')
response = client.stack('api_key').roles("role_uid").update(data).json()

Webhooks

A webhook is a mechanism that sends real-time information to any third-party app or service to keep your application in sync with your Contentstack account. Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens.

create

The create method creates a new webhook in a specific stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new webhook

data = {
"webhook":{
               "name":"Test",
               "destinations":[
               {
                   "target_url":"http://example.com",
                   "http_basic_auth":"basic",
                   "http_basic_password":"test",
                   "custom_header":[
                   {
                       "header_name":"Custom",
                       "value":"testing"
                   }
                   ]
               }
               ],
               "notifiers": "dave.joe@gmail.com",
               "channels":[
               "assets.create"
               ],
               "branches":[
               "main"
               ],
               "retry_policy":"manual",
               "disabled":false,
               "concise_payload":true
           }
           }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks().create(data).json()

delete

The delete method removes an existing webhook from the stack permanently.

Returns:
Type
Webhook
NameTypeDescription

webhook_uid (required)

str

UID of the webhook

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = response = client.stack('api_key').webhooks('webhook_uid').delete().json()

executions

The execution method retrieves the execution details of a specific webhook, which includes the execution UID.

Returns:
Type
Webhook
NameTypeDescription

webhook_execution_uid (required)

str

UID of the webhook execution

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks('webhook_execution_uid').executions().json()

export

The export method exports an existing webhook to a downloadable JSON file.

Returns:
Type
JSON
NameTypeDescription

webhook_uid (required)

str

UID of the webhook

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks('webhook_uid').export().json()

fetch

The fetch method retrieves the details of a specific webhook.

Returns:
Type
Webhook
NameTypeDescription

webhook_uid (required)

str

UID of the webhook

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks('webhook_uid').fetch().json()

find

The find method retrieves the details of all the webhooks available in the stack.

Returns:
Type
Webhook
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack("api_key").webhooks().find().json()

import

The import method imports an existing webhook by uploading a JSON file.

Returns:
Type
Webhook
NameTypeDescription

file_path (required)

str

The path of the file to be uploaded

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
file_path = "tests/resources/mock_content_types/import_content_types.json"
response = client.stack('api_key').webhooks().imports(file_path).json()

logs

The logs method retrieves the latest execution log of the webhooks.

Returns:
Type
JSON
NameTypeDescription

execution_uid (required)

str

UID of the execution

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks().logs('execution_uid').json()

retry

The retry method makes a manual attempt to execute a webhook after the automatic attempts are exhausted.

Returns:
Type
JSON
NameTypeDescription

execution_uid (required)

str

UID of the execution

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks().retry('execution_uid').json()

update

The update method allows you to update the details of an existing webhook in the stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated data of the webhook

data = {
        "webhook":{
            "name":"Updated webhook",
            "destinations":[
            {
                "target_url":"http://example.com",
                "http_basic_auth":"basic",
                "http_basic_password":"test",
                "custom_header":[
                {
                    "header_name":"Custom",
                    "value":"testing"
                }
                ]
            }
            ],
            "channels":[
            "assets.create"
            ],
            "branches":[
            "main"
            ],
            "retry_policy":"manual",
            "disabled":true,
            "concise_payload":true
        }
        }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').webhooks('webhook_uid').update(data).json()

Workflows

Workflow is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly.

create

The create method creates a new workflow in a specific stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new workflow

data = {
"workflow":{
           "workflow_stages":[
               {
                   "color":"#2196f3",
                   "SYS_ACL":{
                       "roles":{
                           "uids":[
                           ]
                       },
                       "users":{
                           "uids":[
                               "$all"
                           ]
                       },
                       "others":{
                       }
                   },
                   "next_available_stages":[
                       "$all"
                   ],
                   "allStages":true,
                   "allUsers":true,
                   "specificStages":false,
                   "specificUsers":false,
                   "entry_lock":"$none",
                   "name":"Review"
               },
               {
                   "color":"#74ba76",
                   "SYS_ACL":{
                       "roles":{
                           "uids":[
                           ]
                       },
                       "users":{
                           "uids":[
                               "$all"
                           ]
                       },
                       "others":{
                       }
                   },
                   "allStages":true,
                   "allUsers":true,
                   "specificStages":false,
                   "specificUsers":false,
                   "next_available_stages":[
                       "$all"
                   ],
                   "entry_lock":"$none",
                   "name":"Complete"
               }
           ],
           "admin_users":{
               "users":[
               ]
           },
           "name":"Workflow",
           "enabled":true,
           "branches":[
               "main",
               "development"
           ],
           "content_types":[
               "$all"
           ]
       }
   }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().create(data).json()

create_publish_rule

The create_publish_rule method creates a new rule for the workflow in a specific stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new publish rule for the workflow

data = {
 "publishing_rule":{
           "workflow":"workflow_uid",
           "actions":[],
           "branches":[
               "main",
               "development"
           ],
           "content_types":[
               "$all"
           ],
           "locales":[
               "en-us"
           ],
           "environment":"environment_uid",
           "approvers":{
               "users":[
                   "user_uids"
               ],
               "roles":[
                   "role_uids"
               ]
           },
           "workflow_stage":"workflow_stage_uid",
           "disable_approver_publishing":false
       }
   }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().create_publish_rule(data).json()

delete

The delete method removes an existing workflow from a specific stack.

Returns:
Type
JSON
NameTypeDescription

workflow_uid (required)

str

UID of the workflow

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = response = client.stack('api_key').workflows('workflow_uid').delete().json()

delete_publish_rule

The delete_publish_rule method removes an existing publish rule for the workflow in a specific stack.

Returns:
Type
JSON
NameTypeDescription

rule_uid (required)

str

UID of the publishing rule

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().delete_publish_rule('rule_uid').json()

disable

The disable method allows you to disable a workflow.

Returns:
Type
JSON
NameTypeDescription

workflow_uid (required)

str

UID of the workflow

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
file_path = "tests/resources/mock_content_types/import_content_types.json"
response = client.stack('api_key').workflows('workflow_uid').disable().json()

enable

The enable method allows you to enable a workflow.

Returns:
Type
JSON
NameTypeDescription

workflow_uid (required)

str

UID of the workflow

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows('workflow_uid').export().json()

fetch

The fetch method retrieves the details of a single workflow from the stack.

Returns:
Type
workflow
NameTypeDescription

workflow_uid (required)

str

UID of the workflow

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows('workflow_uid').fetch().json()

fetch_publish_rule

The fetch_publish_rule method retrieves the details of a specific publish rule from the stack.

Returns:
Type
JSON
NameTypeDescription

rule_uid (required)

str

UID of the publishing rule

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().fetch_publish_rule('rule_uid').json()

fetch_publish_rule_content_type

The fetch_publish_rule_content_type method retrieves the details of publish rules applied to a specific content type.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().fetch_publish_rule_content_type('content_type_uid').json()

fetch_publish_rules

The fetch_publish_rules method retrieves the details of all publish rules from the stack.

Returns:
Type
JSON
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().fetch_publish_rules().json()

fetch_tasks

The fetch_tasks method retrieves the details of all tasks assigned to you.

Returns:
Type
JSON
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().logs().json()

find

The find method retrieves the details of all workflows in the stack.

Returns:
Type
JSON
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack("api_key").workflows().find().json()

publish_request_approval

The publish_request_approval method allows you to either send a publish request or accept/reject a publish request.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

entry_uid (required)

str

UID of the entry

from contentstack_management import contentstack
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
result = client.stack('api_key').workflows().publish_request_approval('content_type_uid', 'entry_uid').json()

set_workflow_stage

The set_workflow_stage method allows you to either set a workflow stage of an entry or update an already existing one.

Returns:
Type
JSON
NameTypeDescription

content_type_uid (required)

str

UID of the content type

entry_uid (required)

str

UID of the entry

data (required)

Dict

The data required to set the workflow stage for a specific entry

data ={
"workflow": {
           "workflow_stage": {
               "comment": "Workflow Comment",
               "due_date": "Thu Dec 01 2018",
               "notify": false,
               "uid": "workflow_stage_uid",
               "assigned_to": [{
                       "uid": "user_uid", 
                       "name": "Username", 
                       "email": "user_email_id"
                       }],
               "assigned_by_roles": [{
                   "uid": "role_uid",
                   "name": "Role name"
               }]               
           }
       }
   }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().set_workflow_stage('content_type_uid', 'entry_uid', data).json()

update

The update method allows you to add a workflow stage or update the details of the existing stages of a workflow.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The data required to update the workflow stage for a specific entry

workflow_uid

str

UID of the workflow

data = {
       "workflow":{
           "workflow_stages":[
               {
                   "color":"#2196f3",
                   "SYS_ACL":{
                       "roles":{
                           "uids":[
                           ]
                       },
                       "users":{
                           "uids":[
                               "$all"
                           ]
                       },
                       "others":{
                       }
                   },
                   "next_available_stages":[
                       "$all"
                   ],
                   "allStages":true,
                   "allUsers":true,
                   "specificStages":false,
                   "specificUsers":false,
                   "entry_lock":"$none",
                   "name":"Review"
               },
               {
                   "color":"#74ba76",
                   "SYS_ACL":{
                       "roles":{
                           "uids":[
                           ]
                       },
                       "users":{
                           "uids":[
                               "$all"
                           ]
                       },
                       "others":{
                       }
                   },
                   "allStages":true,
                   "allUsers":true,
                   "specificStages":false,
                   "specificUsers":false,
                   "next_available_stages":[
                       "$all"
                   ],
                   "entry_lock":"$none",
                   "name":"Complete"
               }
           ],
           "admin_users":{
               "users":[
               ]
           },
           "name":"Workflow",
           "enabled":true,
           "branches":[
               "main",
               "development"
           ],
           "content_types":[
               "$all"
           ]
       }
   }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows("workflow_uid").update(data).json()

update_publish_rule

The update_publish_rule method allows you to add a publish rule or update the details of an existing publish rule of a workflow.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The data required to update the workflow stage for a specific entry

rule_uid

str

UID of the rule

data = {
       "publishing_rule": {
           "workflow": "workflow_uid",
           "actions": [],
           "branches": [
               "main",
               "development"
           ],
           "content_types": ["$all"],
           "locales": ["en-us"],
           "environment": "environment_uid",
           "approvers": {
               "users": ["user_uid"],
               "roles": ["role_uid"]
           },
           "workflow_stage": "workflow_stage_uid",
           "disable_approver_publishing": false
       }
   }
import contentstack_management 
client = contentstack_management.Client(host='host_name')
client.login(email="email_id", password="password")
response = client.stack('api_key').workflows().update_publish_rule('rule_uid', data).json()

Labels

Labels allow you to group a collection of content within a stack. Using labels you can group content types that need to work together. Read more about Labels.

find

The find method retrieves all the existing labels of the stack.


Returns:
Type
JSON
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").label().find().json()

fetch

The fetch method retrieves information about a particular label of a stack.



Returns:
Type
JSON
NameTypeDescription

label_uid (required)

str

UID of the Label

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').label(label_uid).fetch().json()

create

The Create method creates a new label.

Returns:
Type
JSON
NameTypeDescription

data (required)

dict

Data required to create a new label

data = {
"label": {
"name": "Test",
"parent": [
"label_uid"
],
"content_types": [
"content_type_uid"
]
}
}

import contentstack_management 
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').label().create(data).json()

update

The Update method is used to update an existing label.

Returns:
Type
JSON
NameTypeDescription

data (required)

dict

The updated data of the label

label_uid (required)

str

UID of the label

data ={
  "label": {
    "name": "Test",
    "parent": [
      "label_uid"
    ],
    "content_types": [
      "content_type_uid"
    ]
  }
}

import contentstack_management 
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').label("label_uid").update(data).json()

Delete

The Delete method is used to remove a specific label from the stack.

Returns:
Type
JSON
NameTypeDescription

label_uid (required)

str

UID of the label

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').label('label_uid').delete().json()

Locale

Contentstack has a sophisticated, multilingual capability. It allows you to create and publish entries in any language. This feature allows you to set up multilingual websites and cater to a wide variety of audiences by serving content in their local language(s).

find

The find method retrieves the list of all languages (along with the language codes) available for a stack.

Returns:
Type
JSON
import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").locale().find().json()

fetch

The fetch method retrieves information about a specific language available on the stack.

Returns:
Type
JSON
NameTypeDescription

locale_code (required)

str

Code of the specific language

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').locale('locale_code').fetch().json()

create

The create method lets you add a new language to your stack. You can either add a supported language or a custom language of your choice.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to create a new locale

data = {
"locale":{
          "name":"Arabic - Bahrain",
          "code":"ar-bh",
          "fallback_locale":"en-us"
       }
     }
import contentstack_management 
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale().create(data).json()


update

The update method lets you update the details (such as display name) and the fallback language of an existing language of your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

The updated data of the locale

locale_code (required)

str

Code of the specific language

data ={
  "locale":{
    "name":"Updated Locale Name",
    "fallback_locale":"zh-cn"
  }
}


import contentstack_management 
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale("locale_code").update(data).json()

Delete

The delete method removes an existing language from your stack.

Returns:
Type
JSON
NameTypeDescription

locale_code (required)

str

Code of the specific language

import contentstack_management 
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').locale(locale_code).delete().json()

Set_fallback

The Set_fallback method allows you to assign a fallback language for an entry in a particular language.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to assign the fallback language

data = {
"locale":{
          "name":"Arabic - Bahrain",
          "code":"ar-bh",
          "fallback_locale":"en-us"
       }
}
import contentstack_management 
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale().set_fallback(data).json()

Update_fallback

The Update_fallback method allows you to update the fallback language for an existing language of your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

Dict

Data required to assign the fallback language

locale_code (required)

str

Code of the specific language

data = {
  "locale": {
    "name": "German",
    "code": "de",
    "fallback_locale": "en-us"
      }
}
import contentstack_management 
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale("locale_code").update_fallback(data).json()

Taxonomy

Taxonomy helps you categorize pieces of content within your stack to facilitate easy navigation, search, and retrieval of information. You can hierarchically organize your web properties based on your requirements, such as their purpose, target audience, or any other aspects of your business.

Note: The Taxonomy feature is currently released as part of an Early Access program and may not be available to all users. For more information, you can reach out to our support team.

create

The create method lets you add a new taxonomy to your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

dict

The data to be sent in the request body

data ={
       "taxonomy": {
           "uid": "taxonomy12345",
           "name": "Taxonomy 12345",
           "description": "Description for Taxonomy 1"
       }
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy().create(data).json()

delete

The delete method lets you remove an existing taxonomy from your stack.

Returns:
Type
JSON
NameTypeDescription

taxonomy_uid (required)

str

UID of the taxonomy

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = result = client.stack('api_key').taxonomy('taxonomy_uid').delete('taxonomy_uid').json()

fetch

The fetch method lets you retrieve information about a specific taxonomy in your stack.

Returns:
Type
JSON
NameTypeDescription

taxonomy_uid (required)

str

UID of the taxonomy

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy('taxonomy_uid').fetch('taxonomy_uid').json()

find

The find method lets you retrieves the list of all the taxonomies in your stack.

Returns:
Type
JSON
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").taxonomy().find().json()

update

The update method lets you update the details of an existing taxonomy in your stack.

Returns:
Type
JSON
NameTypeDescription

data (required)

dict

The request body to be sent in the call

data ={
   "taxonomy": {
       "name": "Taxonomy 12345",
       "description": "Description updated for Taxonomy 12345"
   }
   }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy("taxonomy_uid").update(data).json()

Terms

Terms serve as the primary classification elements within a taxonomy, allowing you to establish hierarchical structures and incorporate them into entries.

Note: The Terms feature is currently released as part of an Early Access program and may not be available to all users. For more information, you can reach out to our support team.

ancestors

The ancestors method retrieves information about a specific term in the taxonomy.

Returns:
Type
JSON
NameTypeDescription

terms_uid (required)

str

UID of the term

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').ancestors().json()

create

The create method lets you create a new term to your taxonomy.

Returns:
Type
JSON
NameTypeDescription

data (required)

dict

The request body to be sent in the call.

data ={
       "term": {
           "uid": "term_1",
           "name": "Term 1"
       },
       "parent_uid": null
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy('taxonomy_uid').terms().create(data)

delete

The delete method lets you remove an existing term from your taxonomy.

Returns:
Type
JSON
NameTypeDescription

terms_uid (required)

str

UID of the term

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').delete('taxonomy_uid')

descendants

The descendants method retrieves the information about a specific term in your taxonomy.

Returns:
Type
JSON
NameTypeDescription

terms_uid (required)

str

UID of the term

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').descendants().json()

fetch

The fetch method retrieves the information about a specific taxonomy in your stack.

Returns:
Type
JSON
NameTypeDescription

terms_uid

str

UID of the term

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').fetch()

find

The find method retrieves the list of all terms available for a taxonomy.

Returns:
Type
JSON
NameTypeDescription

terms_uid

str

UID of the term

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack("api_key").taxonomy("taxonomy_uid").terms().find()

move

The move method lets you update the details of a specific term in the taxonomy.

Returns:
Type
JSON
NameTypeDescription

terms_uid (required)

str

UID of the term

data (required)

dict

The request body to be sent in the call.

data ={
       "term": {
           "uid": "term_1"
       },
       "parent_uid": null
       }
       Under an existing Term:
       {
       "term": {
           "uid": "term_3"
       },
       "parent_uid": "term_1"
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy("taxonomy_uid").terms('terms_uid').move(data).json()

search

The search method retrieves the information about specified terms in the taxonomy.

Returns:
Type
JSON
NameTypeDescription

terms_string (required)

str

The string of UIDs of the terms you want to search for.

import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').search("terms_string")

update

The update method updates a resource with the given data and terms UID.

Returns:
Type
JSON
NameTypeDescription

terms_uid (required)

str

UID of the term.

data (required)

dict

The data to be sent in the request body

data ={
       "term": {
           "name": "Term 1"
       }
       }
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
result = client.stack('api_key').taxonomy("taxonomy_uid").terms('terms_uid').update(data)