> ## Documentation Index
> Fetch the complete documentation index at: https://docs.legitmark.com/llms.txt
> Use this file to discover all available pages before exploring further.

# States

> Service request states and workflow transitions.

## Overview

Service requests use a two-part state system:

* Primary state: Main stage (DRAFT → QC → UNDERWAY → COMPLETE)
* Supplement state: Additional context (PENDING, APPROVED, REJECTED, etc.)

## State combinations

| Primary State | Supplement State | Description                         | Partner Action           |
| ------------- | ---------------- | ----------------------------------- | ------------------------ |
| `DRAFT`       | -                | Just created, missing requirements  | Complete payment/images  |
| `QC`          | `PENDING`        | Queued for quality control review   | Wait for review          |
| `QC`          | `REJECTED`       | Quality control found issues        | Fix issues and resubmit  |
| `QC`          | `APPROVED`       | Quality control passed              | Wait for authentication  |
| `QC`          | `COMPLETE`       | Fast-track completion during QC     | Check final results      |
| `UNDERWAY`    | `PENDING`        | Ready for authentication assignment | Wait for assignment      |
| `UNDERWAY`    | `ASSIGNED`       | Authenticator assigned and working  | Wait for completion      |
| `UNDERWAY`    | `APPROVED`       | Authentication process completed    | Wait for final results   |
| `COMPLETE`    | `APPROVED`       | Authentic - Item verified genuine   | Authentication passed    |
| `COMPLETE`    | `REJECTED`       | Not authentic - Item is counterfeit | Authentication failed    |
| `COMPLETE`    | `COMPLETE`       | Fully processed with documentation  | Authentication completed |
| `CANCELLED`   | -                | Service request cancelled           | Request cancelled        |

## Workflow

```mermaid theme={null}
graph TD
    A[DRAFT] --> B[QC + PENDING]
    B --> C[QC + REJECTED]
    B --> D[QC + APPROVED]
    C --> B
    D --> E[UNDERWAY + ASSIGNED]
    E --> F[UNDERWAY + APPROVED]
    F --> G[COMPLETE + APPROVED]
    F --> H[COMPLETE + REJECTED]
    A --> I[CANCELLED]
    B --> I
    E --> I
    
    style A fill:#e1f5fe
    style I fill:#ffebee
    style G fill:#e8f5e8
    style H fill:#ffeaa7
```

## Key states to handle

| State                 | Action required                                             |
| --------------------- | ----------------------------------------------------------- |
| `QC + REJECTED`       | Fix issues - Check feedback, add images, or correct details |
| `COMPLETE + APPROVED` | Authentication passed - Item verified as authentic          |
| `COMPLETE + REJECTED` | Authentication failed - Item is not authentic               |
| `CANCELLED`           | Request cancelled - Service request was cancelled           |

## Implementation

```javascript theme={null}
// Essential state handling
function handleServiceRequestUpdate(sr) {
  if (sr.state.primary === 'QC' && sr.state.supplement === 'REJECTED') {
    showAttentionRequired(sr); // Partner action needed
  }
  
  if (sr.state.primary === 'COMPLETE') {
    if (sr.state.supplement === 'APPROVED') {
      handleAuthentic(sr); // Authentication passed
    } else {
      handleNotAuthentic(sr); // Authentication failed
    }
  }
}
```

## Webhooks

Real-time updates are available via webhooks:

* `state_change` - Any state transition
* `media_rejected` - Images need fixes
* `invalidate_sr` - Request cancelled

See [webhook events](/webhook-reference/introduction) for complete details.
