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

# Task Lifecycle

> How an interaction task moves from creation to completion.

Every task moves through a predictable lifecycle — from creation to a retrievable result.

## Task Flow

<Steps>
  <Step title="Task Creation">
    You send a `POST /createTask` request. The server validates your API key, task parameters, proxy format, and checks your balance or package quota. If everything is valid, a task ID (UUID) is returned and the task is queued for processing.
  </Step>

  <Step title="Validation">
    The server performs deep validation:

    * API key and account status
    * Task type must be `FunCaptchaTask`
    * Site key must be a valid UUID
    * Proxy format and port validation
    * Thread limit check
  </Step>

  <Step title="Session Initialization">
    A session is created through your proxy. The system detects the proxy's geolocation to set the correct timezone and language, then generates the initial session token.
  </Step>

  <Step title="Immediate Completion Check">
    If the session token contains `sup=1`, no interactive step is required and the result token is returned immediately. This is the fastest path.
  </Step>

  <Step title="Interactive Processing">
    If an interactive step is required, the system parses the flow type, variant, and number of rounds, then processes each round until completion or timeout.
  </Step>

  <Step title="Result Available">
    Once complete, the result is stored with a 120-second TTL. Poll `GET /getTaskResult/{taskId}` to retrieve it.
  </Step>
</Steps>

## Task Statuses

| Status       | Description                                          |
| ------------ | ---------------------------------------------------- |
| `created`    | Task accepted and queued                             |
| `processing` | Task is running                                      |
| `ready`      | Task completed (check `errorId` for success/failure) |
| `failure`    | Task failed with an error                            |

## Timeouts

| Phase            | Timeout                      |
| ---------------- | ---------------------------- |
| Total task       | 300 seconds                  |
| Processing phase | 120 seconds                  |
| Result TTL       | 120 seconds after completion |

<Warning>
  Results expire 120 seconds after completion. Make sure to poll frequently enough to retrieve your result token before it expires.
</Warning>

## Balance & Refunds

Balance-based (`FUN-`) keys are charged when a task starts processing and **automatically refunded if the task fails**. See [Authentication](/getting-started/authentication) for billing details.

## Polling

<Tip>
  Poll `GET /getTaskResult/{taskId}` every **0.5 seconds**. Results expire 120 seconds after completion — see [Get Task Result](/api-reference/get-task-result) for the full polling reference.
</Tip>
