# domainIDGraph

Query the per-domain user database (ID Graph) using SQL. The ID Graph stores user information collected from your websites or shops, including PII, cookies, custom data, and channel-specific data.

### Parameters

| Parameter  | Type          | Required | Description                                                                                  |
| ---------- | ------------- | -------- | -------------------------------------------------------------------------------------------- |
| `domainId` | string (UUID) | Yes      | The domain ID (tagId). Get this from the `domains` tool.                                     |
| `teamId`   | string (UUID) | Yes      | The team ID the domain belongs to.                                                           |
| `query`    | string        | Yes      | SQL SELECT query. Must include a timestamp range filter. Limit of 500 rows without GROUP BY. |

### Database schema

The ID Graph has 4 tables:

#### main

Primary user table with PII and consent data.

| Column              | Description                          |
| ------------------- | ------------------------------------ |
| `user_id`           | Primary key - unique user identifier |
| `email`             | User email address                   |
| `phone`             | User phone number                    |
| `firstName`         | First name                           |
| `lastName`          | Last name                            |
| `gender`            | Gender                               |
| `dateOfBirth`       | Date of birth                        |
| `city`              | City                                 |
| `state`             | State/region                         |
| `zip`               | Postal code                          |
| `country`           | Country                              |
| `consent`           | JSON object with consent data        |
| `consentCategories` | JSON object with consent categories  |
| `created_at`        | Record creation timestamp            |
| `updated_at`        | Last update timestamp                |

#### cookie

Browser cookie data linked to users.

| Column         | Description               |
| -------------- | ------------------------- |
| `user_id`      | Foreign key to main table |
| `cookie_key`   | Cookie name               |
| `cookie_value` | Cookie value              |
| `created_at`   | Record creation timestamp |

#### custom

Developer-set custom data.

| Column        | Description               |
| ------------- | ------------------------- |
| `user_id`     | Foreign key to main table |
| `store_key`   | Custom data key           |
| `store_value` | Custom data value         |
| `created_at`  | Record creation timestamp |
| `updated_at`  | Last update timestamp     |

#### provider

Channel-specific data such as UTM parameters.

| Column        | Description                 |
| ------------- | --------------------------- |
| `user_id`     | Foreign key to main table   |
| `provider_id` | Channel/provider identifier |
| `store_key`   | Data key                    |
| `store_value` | Data value                  |
| `created_at`  | Record creation timestamp   |
| `updated_at`  | Last update timestamp       |

### Examples

> "Look up the user with email <john@example.com>"

```sql
SELECT * FROM main WHERE email = 'john@example.com' LIMIT 1
```

> "How many users were created today?"

```sql
SELECT COUNT(*) FROM main WHERE created_at >= strftime('%s', '2026-01-01T00:00:00Z')
```

> "Show me all cookies for a specific user"

```sql
SELECT * FROM cookie WHERE user_id = 'user-id-here'
```

{% hint style="info" %}
ID Graph Querying must be enabled for your domain. Contact <support@blotout.io> if you get an "Action not permitted!" error.
{% endhint %}
