---
title: "Python SDK - Workflows"
description: "Manage workflows and item status transitions with the Python SDK"
keywords: [python, sdk, workflows, status, transitions]
---

# Python SDK - Workflows

Manage item status workflows and transitions using the Python SDK.

## Transition Item Status

```python
from tracertm import TraceRTM

client = TraceRTM(api_key="rtm_live_abc123...")

# Transition item status
result = client.transition_item_status(
    item_id="item_abc123",
    to_status="active",
    comment="Ready for review"
)

print(f"Transitioned from {result['previous_status']} to {result['new_status']}")
```

## Get Workflow

```python
# Get workflow for project
workflow = client.get_workflow(project_id="proj_123")

print(f"Workflow: {workflow['name']}")
print(f"States: {workflow['states']}")
```

## Check Allowed Transitions

```python
# Get current item
item = client.get_item("item_abc123")
current_status = item['status']

# Get workflow
workflow = client.get_workflow(project_id="proj_123")

# Check allowed transitions
allowed = workflow.get_allowed_transitions(current_status)
print(f"Can transition to: {allowed}")
```

## Examples

### Transition with Validation

```python
def safe_transition(client, item_id, to_status):
    item = client.get_item(item_id)
    workflow = client.get_workflow(project_id=item['project_id'])
    
    allowed = workflow.get_allowed_transitions(item['status'])
    
    if to_status in allowed:
        return client.transition_item_status(
            item_id=item_id,
            to_status=to_status,
            comment="Status transition"
        )
    else:
        raise ValueError(f"Cannot transition from {item['status']} to {to_status}")

# Use it
result = safe_transition(client, "item_abc123", "active")
```

## Related Documentation

- [Artifacts](./04-artifacts) - Working with items
- [Examples](./06-examples) - More examples
