mainwp-fathom category. All use the mainwp/ namespace on your MainWP Dashboard.
What You’ll Learn
- Which Fathom abilities are available and who can use them
- Connect a Fathom account and refresh its site catalog
- Read and replace a site’s Fathom mapping
- Read live reports, refresh cached analytics, and get current visitors
- Read and replace global settings
- Preview and delete a local Fathom account connection
Prerequisites
- WordPress 6.9 or later on the MainWP Dashboard site
- MainWP Dashboard 6 or later with Abilities API support; use version 6.2 or later for the
input_jsonand DELETE request examples below - The Fathom Integration with Abilities support, active in MainWP Dashboard
- An authenticated user with access to the Fathom Add-on
manage_optionsfor account, settings, and deletion abilities
On a MainWP Dashboard without the Abilities foundation, the Fathom abilities are not registered. The Fathom mapping, stats, and overview screens also deny access on those Dashboard versions. Update MainWP Dashboard before you update the Fathom Integration.
Permissions
All abilities require access to the Fathom Add-on. Team Control restrictions apply.mainwp/list-fathom-sites-v1 returns only the mapped sites the current user can access. A site-scoped call for a site outside the user’s access returns mainwp_fathom_access_denied before MainWP reads cached data or contacts Fathom.
Available Abilities
Discover the full input and output schemas:
Request Rules
All inputs reject extra properties. Site inputs usesite_id_or_domain, such as 1, "1", or "example.com". Use a positive MainWP site ID or an exact domain or URL. Prefer site IDs when a domain could match more than one site.
account_id is the local MainWP ID of a connected Fathom account, returned by List Accounts. It is not the Fathom account ID. provider_site_id is the Fathom site ID shown in the account’s discovered sites.
Mapping and settings revisions are 64-character lowercase hexadecimal values. Read the current revision and send it as if_match when you replace data. A stale revision returns mainwp_fathom_conflict.
List Mapped Sites
Ability:mainwp/list-fathom-sites-v1Method: GET
Input: None
sites, total, and truncated. Each site has id, name, and url. The list returns at most 1,000 sites, ordered by site ID. truncated is true when more authorized mapped sites exist.
Get a Report
Ability:mainwp/get-fathom-report-v1Method: GET
The range can be up to 366 days. The start date can’t be later than the end date.
site, start_date, end_date, metric, aggregates, and series. aggregates contains visits, uniques, pageviews, average_engagement_time, and bounce_rate. Each series item has a date and a value. series is empty when metric is none.
This ability requests data from Fathom on every call. It doesn’t read or update the cached widget data.
Refresh Cached Analytics
Ability:mainwp/refresh-fathom-analytics-v1Method: POST Required input is
site_id_or_domain. MainWP fetches fresh data from Fathom for the configured display interval. It replaces the site’s cached widget data only after it receives a complete response.
mainwp_fathom_refresh_failed with previous_cache_preserved: true.
The response contains site, refreshed, cached_at, interval (week or month), and section_counts. section_counts reports the number of cached pages, countries, devices, browsers, referrers, and graph_points.
Get Current Visitors
Ability:mainwp/get-fathom-current-visitors-v1Method: GET Required input is
site_id_or_domain.
site, visitors (an integer), source, and cached_until. MainWP caches the count for one minute. source is provider when MainWP fetched the count from Fathom, and cache when it reused the cached count.
Manage Accounts
List Accounts
Ability:mainwp/list-fathom-accounts-v1Method: GET Optional inputs are
limit (1-100, default 50) and after_ref (the next_after_id value from the previous page).
accounts, next_after_id, and truncated. Each account has id, name, connected, and up to 1,000 discovered sites, each with an id and name. When truncated is true, request the next page with after_ref set to next_after_id. A page can contain fewer accounts than limit.
Responses never include API tokens.
Connect an Account
Ability:mainwp/connect-fathom-account-v1Method: POST
Create the token in Fathom as described in Establishing a connection with a Fathom Account.
account (id, name, connected), available_site_count, and credential_stored. The token is never returned.
Refresh an Account’s Site Catalog
Ability:mainwp/refresh-fathom-account-catalog-v1Method: POST Required input is
account_id. Use this after you add or remove sites in Fathom.
account_id, connected, site_count, catalog_replaced, and refreshed_at.
Read and Replace a Site Mapping
Read the Mapping
Ability:mainwp/get-fathom-site-mapping-v1Method: GET
site, mapping, and revision. mapping is null when the site has no mapping. Otherwise it contains account_id, provider_site_id, and provider_site_name.
Replace or Clear the Mapping
Ability:mainwp/replace-fathom-site-mapping-v1Method: DELETE
provider_site_id must be in that account’s discovered sites. Otherwise the request returns mainwp_fathom_conflict. Refresh the account catalog if a new Fathom site is missing.
The response contains site_id, mapping, the new revision, and cache_invalidated. When the mapping changes, MainWP invalidates the site’s cached analytics. Run Refresh Cached Analytics to load data for the new Fathom site.
Read and Replace Settings
Read Settings
Ability:mainwp/get-fathom-settings-v1Method: GET
Input: None
interval (week or month), refresh_hours, and revision. These match the Display interval and Data refresh frequency options on the Fathom Settings tab.
Replace Settings
Ability:mainwp/replace-fathom-settings-v1Method: DELETE Required inputs are
interval (week or month), refresh_hours (integer from 1 to 168), and if_match (the current settings revision).
interval, refresh_hours, the new revision, and caches_invalidated. Changing the settings invalidates cached analytics once so widgets load data for the new settings. Repeating a request with values that are already saved returns the current settings without another change.
Remove a Local Account Connection
Removing an account deletes its local connection from MainWP. It doesn’t delete anything in Fathom, and it doesn’t remove any MainWP Child site.Preview the Removal
Ability:mainwp/preview-delete-fathom-account-v1Method: GET
Delete the Account
Ability:mainwp/delete-fathom-account-v1Method: DELETE Required inputs are
account_id and preview_token from the current preview.
mainwp_fathom_conflict. Request a new preview and review it again.
A successful response contains account_id, status (deleted), deleted_mappings, deleted_cache_rows, deleted_catalog_sites, credential_record_deleted, key_file_deleted, and completed_at. Repeating the same request within 24 hours returns the same result.
If MainWP removes the account but can’t delete the key file, the call returns mainwp_fathom_delete_partial with retryable: true. Repeat the same request to finish the key cleanup.
Handle Errors
A failed Fathom request doesn’t replace the existing account, discovered sites, or cached analytics.
Related Resources
- Fathom Integration - Setup, site mapping, settings, and Team Control access
- Abilities API Overview - Authentication and request formats
- Team Control - Staff roles and site access
