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

# Overview

> Architecture for the Get Entities endpoint

## Purpose

Returns all businesses and products that have deployed AI sites. Used by cron jobs to iterate through entities for batch processing.

## Architecture

```mermaid theme={null}
flowchart TD
    Request["GET /api/cron/entities"]
    
    subgraph db [Database Query]
        Query["SELECT * FROM entities JOIN ai_sites"]
    end
    
    Request --> Query
    Query --> Response["Return entities list"]
```

## Query Parameters

| Parameter     | Type     | Description                       |
| ------------- | -------- | --------------------------------- |
| `business_id` | `string` | Filter by specific business       |
| `type`        | `string` | Filter by "business" or "product" |

## Response Format

```json theme={null}
{
  "entities": [
    {
      "entity_id": "uuid-...",
      "business_id": "org-slug-123",
      "product_id": null,
      "product_name": null,
      "type": "business",
      "name": "Acme Corp",
      "source_url": "https://acme.com",
      "deployment_url": "https://acme-corp.searchcompany.dev"
    },
    {
      "entity_id": "uuid-...",
      "business_id": "org-slug-123",
      "product_id": "product-a",
      "product_name": "Product A",
      "type": "product",
      "name": "Product A",
      "source_url": "https://acme.com/product-a",
      "deployment_url": "https://acme-corp.searchcompany.dev"
    }
  ]
}
```

## Code Location

```
src/app/apis/cron/get_entities/routes.py
```

## Used By

* Daily cron job to iterate through all entities
* Batch visibility analysis
* Batch AI article creation
