# Plan Context

Pass plan progression context so the SDK associates a directly-launched workout with the correct plan. After the workout finishes, the SDK posts `plan_progression_saved` (or `plan_progression_failed` on error). See [Plans & Programs events](/docs/data-points/plans-programs).

| Parameter | Type | Description |
|-----------|------|-------------|
| planId | string | The ID of the plan the workout belongs to |
| planType | string | Type of plan (e.g., goal-based plan type, or "personalized") |
| progressWorkoutId | string | The plan-day workout ID used to record progression |

**When to use:** Only when you launch a workout **directly** via the SDK (not through the in-app plan UI) and want it to count toward plan progression. The in-app plan flow handles this automatically — you don't need to pass these fields if the user navigates from the plan dashboard.

**Note:** If you launch a workout without these fields, it is treated as a standalone session and won't update plan progression.

**Plan Context Configuration**

_Swift (iOS)_
```swift
// Pass plan context when launching a workout directly
kinestex.createWorkoutView(
    workout: "Day 3 Workout",
    customParams: [
        "planId": "plan_abc123",
        "planType": "personalized",
        "progressWorkoutId": "plan_day_3"
    ]
)
```

_Kotlin (Android)_
```kotlin
// Pass plan context when launching a workout directly
KinesteXSDK.createWorkoutView(
    workout = "Day 3 Workout",
    customParams = mapOf(
        "planId" to "plan_abc123",
        "planType" to "personalized",
        "progressWorkoutId" to "plan_day_3"
    )
)
```

_React Native_
```jsx
// Pass plan context via customParameters
const postData: IPostData = {
  key: 'YOUR_API_KEY',
  userId: 'user-123',
  company: 'YOUR_COMPANY',
  customParameters: {
    planId: 'plan_abc123',
    planType: 'personalized',
    progressWorkoutId: 'plan_day_3',
  },
};
```

_Flutter_
```dart
// Pass plan context via customParams
KinesteXAIFramework.createWorkoutView(
  workoutName: "Day 3 Workout",
  customParams: {
    "planId": "plan_abc123",
    "planType": "personalized",
    "progressWorkoutId": "plan_day_3",
  },
);
```

_HTML / JavaScript_
```html
// Direct in postData object
const postData = {
  userId: "user-123",
  company: "YOUR_COMPANY",
  key: "YOUR_API_KEY",
  planId: "plan_abc123",
  planType: "personalized",
  progressWorkoutId: "plan_day_3",
};
```

_React (TypeScript)_
```tsx
// Pass plan context via customParameters
const postData: IPostData = {
  key: 'YOUR_API_KEY',
  userId: 'user-123',
  company: 'YOUR_COMPANY',
  customParameters: {
    planId: 'plan_abc123',
    planType: 'personalized',
    progressWorkoutId: 'plan_day_3',
  },
};
```

---
Source: https://kinestex.com/docs/customization-parameters/plan-context · Index: https://kinestex.com/llms.txt
