# Claim lifecycle

A claim is one account's attempt to prove one domain. It has seven statuses, a fixed set of moves between them, and a schedule that decides when we look next.

## Status and phase

A claim tells you where it stands twice, on purpose.

- Status is what's stored. There are seven, and a claim only moves between them through the events below. It answers “who owns this domain?”
- Phase is worked out on every read from the status, the current code and the last check. It's never stored, so it can't disagree with the status. It answers “what should the person see right now?”

Build screens from `view.phase`. Use `view.status` when the question is about ownership.

## The lifecycle

- `pending` (Pending): A code has been issued and we're looking for the record. Every new claim starts here.
- `verified` (Verified): Ownership is proven. The record has to stay in place, and we keep checking it's there.
- `at_risk` (At risk): Still the owner, but a check found the record missing. Ownership holds for 7 days while there's time to put it back.
- `lapsed` (Lapsed): The record stayed missing for the whole grace period, so ownership ended. A new code starts it over.
- `expired` (Expired): The code ran out before the record was found. A new code carries on from here.
- `transferred` (Transferred, final): Another account proved this domain more recently, so it's theirs now. This claim is finished.
- `abandoned` (Abandoned, final): The owner stopped the claim. It's finished, and the name is free for a new attempt.

## Every legal move

These 15 are all of them. Any other pair of status and event is refused: the claim doesn't move, and the refusal is recorded in its history as `ILLEGAL_TRANSITION`. Through the API that's a `409` with `illegal_transition`.

| From | Event | To | What causes it |
| --- | --- | --- | --- |
| `pending` | `CHECK_PASSED` | `verified` | A check found the record, with the right value, on every server we asked. |
| `pending` | `CHECK_FAILED` | `pending` | A check ran and the record wasn't there, wasn't right, or DNS couldn't be reached. |
| `pending` | `CHALLENGE_EXPIRED` | `expired` | 7 days passed since the code was issued, and the record was never found. |
| `pending` | `TOKEN_ROTATED` | `pending` | The owner asked for a new code. The old one stops counting at once. |
| `pending` | `ABANDONED` | `abandoned` | The owner stopped the claim. |
| `verified` | `CHECK_PASSED` | `verified` | A check found the record, with the right value, on every server we asked. |
| `verified` | `RECORD_MISSING` | `at_risk` | A re-check found the record gone or changed. DNS being unreachable doesn't count. |
| `verified` | `SUPERSEDED_BY_OTHER_ACCOUNT` | `transferred` | Another account's check passed for the same domain. The newest proof wins. |
| `at_risk` | `CHECK_PASSED` | `verified` | A check found the record, with the right value, on every server we asked. |
| `at_risk` | `GRACE_ELAPSED` | `lapsed` | 7 days went by at risk without the record coming back. |
| `at_risk` | `SUPERSEDED_BY_OTHER_ACCOUNT` | `transferred` | Another account's check passed for the same domain. The newest proof wins. |
| `lapsed` | `TOKEN_ROTATED` | `pending` | The owner asked for a new code. The old one stops counting at once. |
| `lapsed` | `ABANDONED` | `abandoned` | The owner stopped the claim. |
| `expired` | `TOKEN_ROTATED` | `pending` | The owner asked for a new code. The old one stops counting at once. |
| `expired` | `ABANDONED` | `abandoned` | The owner stopped the claim. |

The event names are what you'll see in a claim's `events`, alongside a few that record a fact without changing the status, like `CLAIM_CREATED` and `SHARE_OPENED`.

## What a check does

A check ends in one of 5 outcomes. What that means for the claim depends on its status, and the rule is deliberately lopsided: it's easy to become verified, and hard to stop being verified by accident.

| Status | verified | propagating | mismatch | not_found | lookup_error |
| --- | --- | --- | --- | --- | --- |
| `pending` | `CHECK_PASSED` to verified | `CHECK_FAILED` to pending | `CHECK_FAILED` to pending | `CHECK_FAILED` to pending | `CHECK_FAILED` to pending |
| `verified` | `CHECK_PASSED` to verified | No change | `RECORD_MISSING` to at_risk | `RECORD_MISSING` to at_risk | No change |
| `at_risk` | `CHECK_PASSED` to verified | No change | No change | No change | No change |

> **A DNS outage never costs anyone their domain**
>
> When a verified claim's check can't reach DNS, or finds the record still spreading, nothing changes. Only a check that got a clear answer, and the answer was “it's gone”, starts the grace period. An at-risk claim that keeps failing just waits it out.

## When we check

You never have to ask. Every claim that can still change has a next look scheduled, and `nextCheckAt` says when.

| Status | Next look |
| --- | --- |
| `pending` | After a check that doesn't pass: 30 seconds, 1 minute, 2 minutes, 5 minutes, 15 minutes, then every 30 minutes. Never past the code's expiry. |
| `verified` | Every 1 day. |
| `at_risk` | Every 6 hours, and exactly when the grace period ends. |
| `lapsed` | Never. Nothing is scheduled. |
| `expired` | Never. Nothing is scheduled. |
| `transferred` | Never. Nothing is scheduled. |
| `abandoned` | Never. Nothing is scheduled. |

A pending claim backs off through 6 steps so a record that's seconds away is found quickly and one that never comes doesn't cost a lookup every half minute for a week. When a claim comes due, time wins over another lookup: a code past its 7 days expires, and a grace period past its 7 days ends, without asking DNS first.

[Run a check](https://www.prufy.dev/docs/api-reference/run-check.md) looks at once, outside the schedule, at most every 10 seconds per claim.

## Phases

`view` has a different shape for each phase, so switching on `view.phase` tells you which fields are there. The five pending phases all carry the record, the provider instructions and the timing.

| Phase | When |
| --- | --- |
| `add_record` | Pending, and no check of the current code has run yet. |
| `checking` | Pending, with a check running right now. |
| `waiting_for_dns` | Pending. The record is right and DNS is still catching up. |
| `fix_needed` | Pending. The last check found something to change, and `outcome` says what. |
| `try_again_later` | Pending. DNS couldn't be reached, so we'll try again. |
| `verified` | Ownership is proven. The record has to stay, and we re-check it daily. |
| `at_risk` | Verified, but the record has gone missing. Put it back before `lapsesAt`. |
| `lapsed` | The record stayed missing past the grace period. Get a new code to start over. |
| `expired` | The code ran out before the record was found. Get a new code to carry on. |
| `transferred` | Another account proved this domain more recently. Final. |
| `abandoned` | Stopped by its owner. Final. |

Getting a new code puts a claim back to `add_record`: a check of the old code says nothing about the new one.

## One owner at a time

A domain has at most one owner: the account whose claim is `verified` or `at_risk`. Any number of accounts can have a pending claim on the same name.

- The newest proof wins. When a second account's check passes, the domain is theirs and the first claim becomes `transferred`. Whoever controls the DNS controls the domain, and the record is the evidence.
- It's never silent. Both claims record it, and the account that lost the domain gets an alert. It isn't told who the new owner is.
- You're warned first. [Create a claim](https://www.prufy.dev/docs/api-reference/create-claim.md) answers `warning: "verified_by_another_account"` when the name already has an owner.

---

Every page of these docs, as a list: https://www.prufy.dev/llms.txt
