RAIA™ Specification

3.0a Organisation Data Intelligence

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

← Back to Developer Hub TEXTBOOK SPECIFICATION

Companies House · Logo Backfill · Professional Qualifications · UK Jurisdiction

Automated pipeline to enrich tbl_organisations with logos, registered office addresses, company status, SIC codes, and professional qualification signals — sourced from Clearbit, Google Favicons, and the Companies House public API.

◉ AITL — Fully Automated ▲ HITL Gate — API Key Required ✓ Dry-Run by Default

SYNOPSIS At a Glance

8,248
Active organisations in portal
7%
Have a logo URL today
93%
Missing logo — show initials circle
600
Companies House API req/day (free tier)
🏢

Goal of this pipeline: Replace every grey initials-circle in the portal sidebar and organisation modals with a real logo. Simultaneously harvest Companies House data (registered address, SIC codes, company status) and infer professional qualification requirements from trade codes.

CH. 1 The Problem

Organisations appear throughout the RAIA (Real estate Artificial Intelligence Agent) portal in three sidebar sections — Suppliers, Building contacts, and Tenancy partners. Without a logo, each org renders as a grey circle containing its initials (e.g. AI for Attic Inventory). This degrades visual scanning and brand recognition, particularly when an agent manages 50+ supplier relationships.

Octopus Energy
Octopus Energy
Clearbit ✓
Thames Water
Thames Water
Google fav ✓
MyDeposits
MyDeposits
Google fav ✓
Alan Boswell
Alan Boswell
Google fav ✓
AI
Attic Inventory
No logo ✗

What we need per organisation

  1. Logo — for visual identity in the portal sidebar and org modal (44×44 px circle)
  2. Registered office address — from Companies House (authoritative UK source, not self-reported)
  3. Professional qualifications — e.g. Gas Safe (plumbers), NICEIC/NAPIT (electricians), ARLA/NAEA (letting agents), RICS (surveyors), CHAS/SafeContractor (general contractors)
  4. Company type and status — active, dissolved, dormant — so the portal can surface warnings on dissolved suppliers

Data sources — priority order

#
Source
Details
Cost
1
Clearbit Logo API
https://logo.clearbit.com/{domain} — free, excellent coverage for commercial orgs. Returns PNG at 128×128. No auth required.
Free
2
Google Favicon API
https://www.google.com/s2/favicons?sz=128&domain={domain} — fallback, always returns something. Verify image size > 32×32 before accepting (see P-02).
Free
3
Companies House API
https://api.company-information.service.gov.uk — free, requires API key, 600 req/day on free tier. Lookup by company_reg_num (stored for ~60% of active orgs). Returns: registered_office_address, company_status, company_type, date_of_creation, sic_codes.
Free Key req.
4
SIC → Qualification Map
UK SIC codes from Companies House map to trade types (e.g. 43220 = Plumbing, 43210 = Electrical, 68100 = Letting Agent) and hence to mandatory certification requirements.
Internal
5
Website scraping
Last resort: fetch the company's homepage and extract og:image meta tag or <link rel="icon">. Used when Clearbit and Google both fail.
Slow

CH. 2 Data Model

Three tables are involved. Two are existing; one migration adds two new columns.

tbl_organisations — core record

🗂 tbl_organisations (relevant columns)
organisation_iduuidPrimary key
nametextDisplay name — used for fallback initial generation
org_typetexte.g. supplier, utility, letting_agent, council
company_reg_numtextCompanies House number — present for ~60% of active orgs. Must be zero-padded to 8 digits.
logo_urltextPublic URL for the org logo — written by the pipeline
incorporation_datedateFrom Companies House date_of_creation
incorporation_countrytextDefaults to "GB" for Companies House entries
company_registry_urltextCH public URL — also used to extract the company domain
vat_numbertextHMRC VAT number if known
abouttextFree-text description
statustextactive, deleted — soft-delete flag
head_office_address_iduuid FK→ tbl_organisations_addresses.address_id
website ⚡ NEWtextCompany website URL — added by migration below
sic_codes ⚡ NEWtext[]Array of UK SIC codes from Companies House — added by migration below

tbl_organisations_attributes — EAV qualifications store

🏷 tbl_organisations_attributes
attribute_iduuidPrimary key
organisation_iduuid FK→ tbl_organisations
attribute_keytexte.g. gas_safe_number, niceic_number, arla_membership, rics_number, chas_number
attribute_valuetexte.g. "123456" — the actual registration number or membership ID
is_secretboolfalse for qualification numbers (they're public)
categorytext"qualification" — used to filter attributes tab in OrganisationCardModal

tbl_organisations_addresses — address link

The head office address is stored in a separate addresses table and linked via head_office_address_id FK on tbl_organisations. When Companies House returns a registered_office_address, the pipeline upserts a row in tbl_organisations_addresses and updates the FK.

Migration — add new columns

Run this migration to add the two new columns before executing the pipeline:

-- Migration: add website and sic_codes to tbl_organisations
-- File: supabase/migrations/20260602_add_org_website_sic_codes.sql

ALTER TABLE tbl_organisations
  ADD COLUMN IF NOT EXISTS website   TEXT,
  ADD COLUMN IF NOT EXISTS sic_codes TEXT[];

-- Optional: index sic_codes for reporting queries
CREATE INDEX IF NOT EXISTS idx_org_sic_codes
  ON tbl_organisations USING GIN (sic_codes);
⚠️

Run the migration first. The pipeline will throw if website or sic_codes columns are absent when it tries to write them via the Supabase client.

CH. 3 The Pipeline — backfill-org-data.cjs

📄
03_technology/09_pipelines/programs/backfill-org-data.cjs
CommonJS Node.js script — runs standalone, no build step required. Requires Node 18+.

Pipeline step-by-step

  • 1
    Load target organisations from Supabase

    Query: SELECT * FROM tbl_organisations WHERE logo_url IS NULL AND status != 'deleted'. Respects --limit=N and --org=UUID flags for scoped runs.

  • 2
    Companies House lookup (if company_reg_num present)

    Zero-pad the reg number to 8 digits. Call GET /company/{number} on the CH API. Extracts: registered_office_address, sic_codes, company_status, company_type, date_of_creation. Rate-limited to 1 req/s (see --delay=MS). Responses cached in memory for duplicate reg numbers.

  • 3
    Extract domain

    Tries in order: (a) parse domain from company_registry_url or website column, (b) name-normalise to {slug}.co.uk as a guess, (c) Companies House registered name → domain heuristic. Domain is used for logo lookup in steps 4–5.

  • 4
    Clearbit logo attempt

    HEAD https://logo.clearbit.com/{domain} — if HTTP 200 and Content-Type is image, use this URL as logo_url. Uses User-Agent: Mozilla/5.0 to avoid server-IP blocks (see P-01).

  • 5
    Google Favicon fallback

    https://www.google.com/s2/favicons?sz=128&domain={domain} — always returns an image, but verify the response image dimensions are >32×32 px before accepting (a 16×16 globe means Google doesn't know the domain — see P-02).

  • 6
    Map SIC codes → qualification categories

    Built-in SIC→qualification map (see Ch.5). For each matching SIC code, record the expected qualification category. Does not write actual registration numbers — those must be entered manually by agents.

  • 7
    Write results (--write mode only)

    UPDATE tbl_organisations with logo_url, website, sic_codes, incorporation_date. UPSERT tbl_organisations_attributes for each qualification category with attribute_value = 'REQUIRED' as a placeholder. In dry-run mode, only prints what would be written.

CLI flags

FlagDefaultPurpose
--writeoffExecute writes to Supabase. Without this flag the script is always a dry run.
--dry-rundefaultAlias — explicit dry-run mode (no writes, prints proposed changes).
--limit=NunlimitedProcess at most N organisations. Useful for testing or rate-limited batches.
--org=UUIDallProcess a single organisation by UUID. Useful for manual spot-checks.
--delay=MS1000Milliseconds to wait between Companies House API requests. Set ≥1100 to stay inside 600 req/day safely.
--reportoffWrite a JSON summary to org-backfill-report.json after completion.

Environment variables

Required
  • COMPANIES_HOUSE_API_KEY — Basic-auth username for the Companies House API (password is blank). Obtain from the CH developer hub.
  • SUPABASE_URL — Supabase project URL (already in .env.local)
  • SUPABASE_SERVICE_ROLE_KEY — Service-role key for write access (already in .env.local)

Key code section

// backfill-org-data.cjs — core loop (simplified)
const orgs = await loadTargetOrgs(supabase, { limit, orgId });

for (const org of orgs) {
  const result = { organisation_id: org.organisation_id };

  // 1. Companies House
  if (org.company_reg_num) {
    const regNum = org.company_reg_num.padStart(8, '0');
    const ch    = await fetchCompaniesHouse(regNum, apiKey);
    if (ch) {
      result.sic_codes         = ch.sic_codes;
      result.incorporation_date  = ch.date_of_creation;
      result.ch_status          = ch.company_status;
    }
    await sleep(delay); // rate limit
  }

  // 2. Domain extraction
  const domain = extractDomain(org);

  // 3. Clearbit → 4. Google favicon
  if (domain) {
    result.logo_url = await tryClearbit(domain)
                    ?? await tryGoogleFavicon(domain);
  }

  // 5. SIC → qualifications
  const quals = mapSicToQualifications(result.sic_codes ?? []);

  if (writeMode) {
    await writeOrgData(supabase, result);
    await writeQualifications(supabase, org.organisation_id, quals);
  } else {
    console.log('[DRY-RUN]', org.name, result);
  }
}

CH. 4 Running the Pipeline

  • 1
    Get a Companies House API key

    Register at developer.company-information.service.gov.uk — free, instant approval. Your API key is used as the Basic-auth username; the password is blank.

  • 2
    Add the key to .env.local

    COMPANIES_HOUSE_API_KEY=your_key_here — do not commit this to git. The .env.local file is gitignored by default.

  • 3
    Dry run — see what would change

    node backfill-org-data.cjs --limit=50 — prints a table of proposed logo_url values and SIC codes for the first 50 orgs. No writes. Verify the output looks correct before proceeding.

  • 4
    Live run — write to Supabase

    node backfill-org-data.cjs --write --report — processes all eligible orgs (logo_url IS NULL), writes logos and SIC codes to Supabase, emits org-backfill-report.json. Runs at ~1 org/s due to Companies House rate limiting. For 8,248 orgs ≈ 14 days of CH lookups at 600/day; run logo-only first (faster, no CH calls).

  • 5
    Check the report

    cat org-backfill-report.json — shows counts: processed, logo_found, logo_missing, ch_found, ch_missing, errors. Commit to the repo as an audit trail.

Useful one-liners

# Single org test
node backfill-org-data.cjs --org=550e8400-e29b-41d4-a716-446655440000

# Logo-only pass (no CH API, faster)
node backfill-org-data.cjs --write --delay=0 --limit=500

# Companies House enrichment pass (CH only, slower)
node backfill-org-data.cjs --write --delay=1100 --limit=550

# Full report run
node backfill-org-data.cjs --write --report 2>&1 | tee run.log
⏱️

Time estimate: 8,248 orgs × 1.1s delay = ~2.5 hours per 600-org batch for CH lookups. Logo-only (Clearbit + Google) runs in minutes. Recommended strategy: run logo pass first (no delay needed), then run CH enrichment in nightly batches of 550 orgs.

CH. 5 Qualification Framework

UK SIC codes returned by Companies House map to trade categories which have known mandatory certification requirements. The pipeline uses this table to populate tbl_organisations_attributes with qualification placeholders. Agents then fill in the actual registration numbers.

SIC Code Trade / Sector Mandatory Certification Regulator
43220 Plumbing & Heating Gas Safe Register HSE
43210 Electrical NICEIC or NAPIT OZAS
43310 Plastering n/a —
43320 Joinery / Carpentry n/a —
43341 Painting & Decorating n/a —
43390 Other building finishing n/a —
68100 Letting / Estate Agency ARLA Propertymark RICS
68209 Property Management ARLA or RICS RICS
41100 Property Development n/a —
81100 Building Management / FM CHAS / SafeContractor SSIP
35110 Electricity Supply Ofgem Supplier Licence Ofgem
36000 Water Supply Ofwat Licence Ofwat

Storage in tbl_organisations_attributes

Each qualification is stored as a row with category = 'qualification'. The pipeline writes placeholder rows; agents complete the actual registration numbers in the portal:

attribute_key values
  • gas_safe_number — Gas Safe Register ID
  • niceic_number — NICEIC contractor number
  • napit_number — NAPIT member number
  • arla_membership — ARLA Propertymark ref
  • rics_number — RICS firm number
  • chas_number — CHAS accreditation ref
Example rows
  • attribute_key: gas_safe_number
  • attribute_value: 123456
  • category: qualification
  • is_secret: false
  • Pipeline writes value = "REQUIRED" as placeholder; agents then paste real numbers.
-- Query to see all qualification gaps
SELECT
  o.name,
  a.attribute_key,
  a.attribute_value
FROM   tbl_organisations_attributes a
JOIN   tbl_organisations            o USING (organisation_id)
WHERE  a.category        = 'qualification'
  AND  a.attribute_value = 'REQUIRED'
ORDER BY o.name;

CH. 6 Manual Override in Portal

Agents should not need to run the CLI. All org data is editable directly in the portal via the OrganisationCardModal.

Logo field

OrganisationCardModal has a logo URL input field. Agents can paste any HTTPS image URL. The 44×44 circle preview renders immediately. On save, calls PATCH /api/organisations/{id} with { logo_url }.

Website field

The new website column is exposed in the modal. Agents can paste the org's website URL. This feeds back into the pipeline domain extraction on subsequent runs.

Qualifications tab

A Qualifications tab in OrganisationCardModal queries tbl_organisations_attributes WHERE category = 'qualification'. Displays key/value pairs with edit-in-place. Agents paste real registration numbers to replace pipeline placeholders.

API endpoints

MethodEndpointBodyEffect
PATCH /api/organisations/{id} { logo_url, website } Updates org logo and/or website URL directly in tbl_organisations
GET /api/organisations/{id}/attributes?category=qualification — Returns all qualification attributes for the org
PUT /api/organisations/{id}/attributes/{key} { value } Upserts a single qualification attribute (e.g. sets gas_safe_number)

⚠ Pitfalls

P-01
Clearbit blocks server IPs

Clearbit's logo endpoint detects and blocks requests from cloud/data-centre IP ranges. Always set User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 in the request headers. This mimics a browser and is accepted by Clearbit's CDN.

P-02
Google favicon returns a 16×16 globe for unknown domains

If Google has no favicon data for the domain, it returns a generic 16×16 grey globe icon. Always fetch the image and check width > 32 && height > 32 before storing the URL as a logo. Images smaller than 32×32 should be rejected and treated as "no logo".

P-03
Companies House free tier: 600 req/day hard limit

Exceeding 600 requests/day results in HTTP 429 errors and a potential temporary ban. Set --delay=1100 (1.1 seconds per request) to guarantee you stay within 600/day. Cache Companies House responses in memory to avoid re-fetching duplicate company_reg_num values in the same run.

P-04
company_reg_num may be incorrectly formatted

Companies House expects exactly 8 digits, zero-padded (e.g. 2366661 → 02366661). Some entries in tbl_organisations were imported without zero-padding. Always call .padStart(8, '0') before constructing the CH API URL. Non-numeric characters (letters, spaces, dashes) indicate a foreign or non-standard registration — skip CH lookup for those.

P-05
Many orgs have no reg number — local councils, charities, foreign companies

Local councils (e.g. K&C Council) have no Companies House number. Charities use a Charity Commission number. Foreign-registered companies don't appear in CH at all. For these, skip the CH lookup entirely and proceed with logo-only enrichment. Do not attempt a CH name search as a fallback — the results are too ambiguous.

P-06
SIC codes not always populated by Companies House

Not all UK companies file SIC codes. When sic_codes is absent or empty in the CH response, fall back to the org's org_type field (e.g. org_type = 'utility') or apply name-based classification (e.g. name contains "Gas" → flag for gas_safe check). Document all fallback classifications in the report so agents can review.

P-07
External logo URLs expire when domains change

Logo URLs sourced from Google Favicons (google.com/s2/favicons?domain=…) are ephemeral — if the company's domain changes or lapses, the URL returns a blank. Best practice: after validating a logo URL, fetch the image and store it to GCS (using the same avatar upload pipeline as tbl_persons.avatar_url), then write the permanent GCS URL to tbl_organisations.logo_url. Clearbit CDN URLs are more stable but still not permanent.


🏢

Once complete, this pipeline transforms the portal sidebar from a wall of grey initials-circles into a visually scannable directory of branded organisations — improving agent efficiency and reducing mis-selection errors when assigning suppliers to jobs or tenancy contacts to properties.

Related pages: § 3.2b RentProfile R2R Scraper · § 3.2a Referencing Report Avatar Backfill · RAIA (Real estate Artificial Intelligence Agent) Documentation Index

Author: RAIA (Real estate Artificial Intelligence Agent) OS — EstateAigents.com · Version: 1.0 · Last updated: June 2026

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder:

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder: