# User plan lifecycle

The states a user plan passes through from creation to a live line, and how a port-in changes the path.

> Enterprise API · https://developer.telgea.com/docs/enterprise/concepts/user-plan-lifecycle

A user plan is one user's line: its number and its eSIM. Its `status` is on every [`GET /v1/user-plans/{userId}`](https://developer.telgea.com/docs/enterprise/api/user-plans#get-user-plan-details) response. The status is worked out from the plan's numbers, which is why stopping or ending a line shows up here too.

## States [#states]

## What to build [#what-to-build]

* **Create, then wait for ACTIVE.** [`POST /v1/user-plans`](https://developer.telgea.com/docs/enterprise/api/user-plans#create-a-new-user-plan) returns `PROVISIONING`; a port-in, submitted separately, moves the plan to `PORTING`. Poll `GET /v1/user-plans/{userId}` until it is `ACTIVE`.
* **Read the activation code once ACTIVE.** It is the LPA string on the number; render your own QR. See the [eSIM install flow](https://developer.telgea.com/docs/enterprise/concepts/number-lifecycle#esim-install-flow).
* **Read TERMINATING with `terminationScheduledAt`.** When it is set, the plan is ending on that date. When it is `null`, the number is being ported out to another carrier. Suspending a number doesn't end its plan, so a plan whose number is suspended reads `ACTIVE` until its end is booked.
* **End a plan with the API.** See [End a plan](https://developer.telgea.com/docs/enterprise/guides/end-a-plan).

The UserPlanCreated and UserPlanActive webhooks carry the status too, so you can be notified of a plan going `ACTIVE` instead of polling.

## Related [#related]

* [Provision a line](https://developer.telgea.com/docs/enterprise/guides/number-provisioning)
* [Number and eSIM lifecycle](https://developer.telgea.com/docs/enterprise/concepts/number-lifecycle)
