Skip to navigation

Dimensions

Creating a Dimension

This shows how to create a new dimension (e.g., a department).

# main.py
dimension_name = f"SDK Department {time_now}"
dimension_unique_key = f"dept-sdk-{time_now}"
new_dimension = client.dimensions.post_dimensions_root(
ottimate_company_id=ottimate_company_id,
type="DEPARTMENT",
code="MKT",
dimension_type_code="DEPARTMENT",
name=dimension_name,
unique_key=dimension_unique_key,
)
ottimate_dimension_id = new_dimension.dimension.get("id")

Fetching Dimensions

You can fetch all dimensions for a company, or filter by type.

Fetching all dimensions:

# Fetch all the dimensions
dimensions = client.dimensions.get_dimensions_root(ottimate_company_id=ottimate_company_id)
print(f"✅ Fetched {len(dimensions.dimensions)} dimensions for the company.")
for dimension in dimensions.dimensions:
print(f" - Dimension: {dimension.name} | Ottimate Dimension ID : {dimension.id} | Type: {dimension.dimension_type} | ERP ID: {dimension.erp_dimension_id}")

Fetching dimensions of a specific type:

# Fetch dimensions of type DEPARTMENT
dimensions = client.dimensions.get_dimensions_root(ottimate_company_id=ottimate_company_id, type="DEPARTMENT")
for dimension in dimensions.dimensions:
print(f" - Dimension: {dimension.name} | Ottimate Dimension ID : {dimension.id} | Type: {dimension.type} | ERP ID: {dimension.erp_dimension_id}")

Fetching a single dimension by ID:

# Fetch a single dimension by ID
dimension = client.dimensions.get_dimensions_id(id="<ottimate_dimension_id>").dimension
print(f" - Dimension: {dimension.name} | Ottimate Dimension ID : {dimension.id}| Type: {dimension.type} | ERP ID: {dimension.erp_dimension_id}")