> ## Documentation Index
> Fetch the complete documentation index at: https://flare-iman-v2-v3-spec-ordering.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate a Threat Flow Report

export const name_0 = "Flare CTI"

<Info>
  Access to {name_0} is required for this feature.
  Please contact your Customer Success Manager for more details.
</Info>

<Steps>
  <Step title="Create an intel request">
    Use the
    [threat\_flow/intel/requests <Icon icon="code" size={16} />](/api-reference/v4/endpoints/create-intel-request)
    endpoint to queue the generation of a report for a given question.

    This endpoint returns a `request_id` that can be used to poll the request until it is completed.
  </Step>

  <Step title="Poll the intel request">
    Use the
    [threat\_flow/intel/requests/\{id} <Icon icon="code" size={16} />](/api-reference/v4/endpoints/get-intel-request)
    endpoint to poll the request's status.

    Generation typically takes 10 to 15 minutes. While the request is in progress, `status` will be
    `pending` or `processing`. Once it is done, `status` will be `completed` and `result.report_id`
    will contain the id of the generated report, or `status` will be `error` if generation failed.

    Once completed, the report identified by `result.report_id` can be retrieved for up to 30 days.
  </Step>
</Steps>

## End-to-End API Example

This is an end-to-end example in Python.

<AccordionGroup>
  <Accordion title="Python SDK Example">
    ```python theme={null}
    import time

    from flareio import FlareApiClient


    api_client = FlareApiClient.from_env()

    # Create an intel request
    intel_request_resp = api_client.post(
        "/firework/v4/threat_flow/intel/requests",
        json={
            "question": "xss vulnerability in banks",
            "tone": "analytical",
        },
    )
    intel_request_resp.raise_for_status()
    request_id: str = intel_request_resp.json()["request_id"]
    print(f"Created intel request: {request_id=}")

    # Poll the intel request until it's completed
    report_id: int | None = None
    timeout = time.monotonic() + 60 * 15
    while time.monotonic() < timeout:
        intel_resp = api_client.get(
            f"/firework/v4/threat_flow/intel/requests/{request_id}",
        )
        intel_resp.raise_for_status()
        intel_data = intel_resp.json()
        status = intel_data["status"]

        if status == "completed":
            report_id = intel_data["result"]["report_id"]
            break
        elif status == "error":
            raise Exception(f"Intel request failed: {intel_data=}")

        print(f"Waiting for intel request to complete ({status=})...")
        time.sleep(5)
    else:
        raise Exception("Failed to complete intel request within 15 minutes")

    print(f"Report generated: {report_id=}")
    print("This report can be retrieved for up to 30 days.")
    ```
  </Accordion>
</AccordionGroup>
