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

# Jobs Overview

Every agent run creates a **job**. Jobs are asynchronous, you submit parameters, get a job ID back, then poll until results are ready.

## Job Lifecycle

| Status      | Description                           |
| ----------- | ------------------------------------- |
| `queued`    | Job is waiting to be processed        |
| `running`   | Agent is actively collecting data     |
| `completed` | Finished, results are available       |
| `failed`    | Error occurred, check the error field |
| `cancelled` | Cancelled by you, nothing charged     |

<Note>
  Job results expire after **7 days**. Download your data before the `expires_at` timestamp.
</Note>

## Quick Example

<CodeGroup>
  ```bash curl theme={null}
  # Start a job
  curl -X POST https://api.mindcase.co/api/v1/agents/instagram/profiles/run \
    -H "Authorization: Bearer mk_live_abc123def456" \
    -H "Content-Type: application/json" \
    -d '{"params": {"usernames": ["nike"]}}'
  # → {"job_id": "abc123", "status": "queued"}

  # Poll status
  curl https://api.mindcase.co/api/v1/jobs/abc123 \
    -H "Authorization: Bearer mk_live_abc123def456"

  # Get results when completed
  curl https://api.mindcase.co/api/v1/jobs/abc123/results \
    -H "Authorization: Bearer mk_live_abc123def456"

  # Cancel if needed
  curl -X DELETE https://api.mindcase.co/api/v1/jobs/abc123 \
    -H "Authorization: Bearer mk_live_abc123def456"
  ```

  ```python Python theme={null}
  import requests, time

  API_KEY = "mk_live_abc123def456"
  HEADERS = {"Authorization": f"Bearer {API_KEY}"}

  # 1. Start a job
  job = requests.post(
      "https://api.mindcase.co/api/v1/agents/instagram/profiles/run",
      headers=HEADERS,
      json={"params": {"usernames": ["nike"]}},
  ).json()

  # 2. Poll until done
  while True:
      status = requests.get(
          f"https://api.mindcase.co/api/v1/jobs/{job['job_id']}",
          headers=HEADERS,
      ).json()
      if status["status"] in ("completed", "failed", "cancelled"):
          break
      time.sleep(2)

  # 3. Get results
  results = requests.get(
      f"https://api.mindcase.co/api/v1/jobs/{job['job_id']}/results",
      headers=HEADERS,
  ).json()
  ```
</CodeGroup>
