openapi: 3.1.0
info:
  title: Grid My Business API
  version: 1.0.0
  description: |
    ## Introduction

    Read your Grid My Business workspace data, and publish to Google Business Profile, from your own code.

    - **Read access and write access are separate.** Read access covers every `GET` route. Write access covers publishing and scheduling photos, videos and posts, and review replies. A workspace can have one or both.
    - **One workspace per key.** A key reads every business profile in its workspace.
    - **Base URL:** `https://api.gridmybusiness.com/v1`. HTTPS only: a call to `http://` gets `400 INVALID_INPUT`.

    ## Quickstart

    1. Your workspace needs API read access, API write access, or both. To turn one on, contact us.
    2. In the app, open **Workspace Tools**, choose **API**, then **Create API key**. Only the workspace owner or an admin can do this. Copy the key now: it is shown once.
    3. Call `/workspace` to check the key (a `GET`, so it needs read access):

    ```bash
    curl https://api.gridmybusiness.com/v1/workspace \
      -H "Authorization: Bearer $GMB_API_KEY"
    ```

    ```json
    { "success": true, "data": { "id": "65a1f3c2e4b0a1d2c3e4f501", "name": "Sunrise Bakery Group", "totalProfiles": 3 } }
    ```

    4. List your profiles with `GET /profiles`, then use a profile `id` in the other routes.

    ## Authentication

    Send the key in the `Authorization` header:

    ```http
    Authorization: Bearer gmb_live_...
    ```

    - Keep the key on your server. The API does not allow browser calls.
    - Never put the key in the URL. It is refused with a `400`.
    - `GET` routes need API read access in the workspace. Without it, a `GET` gets `403 API_PLAN_INSUFFICIENT`.
    - Write routes need API write access in the workspace. Without it, a write gets `403 API_PLAN_INSUFFICIENT`.
    - A key has no access setting of its own: every key in the workspace can do what the workspace's API access allows.
    - A workspace can have up to 5 active keys. To replace a key, create the new one first, then delete the old one. A deleted key stops working at once.
    - The **Request log** on the **API** page lists every call made with your keys in the last 90 days.

    ## Responses

    Our responses use one envelope (a few network errors do not; see Errors):

    ```json
    { "success": true, "data": {} }
    { "success": false, "error": { "code": "API_RESOURCE_NOT_FOUND", "message": "Resource not found." } }
    ```

    - **Dates** are UTC. Send `YYYY-MM-DD`; ranges are inclusive and at most 365 days.
    - **Ranks:** 1 is best. `null` means outside the top 20; averages count it as 21.
    - **AI results** (review analysis, AI scan analysis, AI Audit) are `null` until created in the app.

    **Paging**

    - Most lists: `page` (from 1) and `pageSize` (up to 100). The response has `items`, `page`, `pageSize` and `total`.
    - Google lists (reviews, posts, media): send `nextPageToken` back as `pageToken`. `null` means the last page.

    ## Errors

    | Status | Code | Meaning |
    | --- | --- | --- |
    | 400 | `INVALID_INPUT` | A value is not valid. The message names it. |
    | 400 | `API_KEY_IN_QUERY` | The key was in the URL. Use the header. |
    | 401 | `API_KEY_INVALID` | Missing, wrong or revoked key. |
    | 400 | `API_MEDIA_FILE_INVALID` | No file, or not a JPEG or PNG up to 5 MB or an MP4 up to 20 MB. |
    | 403 | `API_PLAN_INSUFFICIENT` | The workspace has no API read access (for a `GET`) or no API write access (for a write). |
    | 400 | `API_GOOGLE_REJECTED` | Google refused the request, for example a post Google does not accept. |
    | 404 | `API_RESOURCE_NOT_FOUND` | Not found, or not in your workspace. |
    | 409 | `API_GOOGLE_NOT_CONNECTED` | The profile has no working Google connection. |
    | 429 | `API_RATE_LIMITED` | Too many requests. Wait `Retry-After` seconds. |
    | 500 | `INTERNAL_ERROR` | Our error. Retry later. |
    | 503 | `API_UPSTREAM_UNAVAILABLE` | Google or another data source did not answer. Retry later. |

    Retry only 429, 500, 502, 503 and 504.

    Some errors come from the network in front of the API, without this envelope: a plain `400` for a key in the URL, `404` or `405` for a wrong path or method, and `502` or `504` when the API cannot be reached in time. Treat them like the codes above: fix the request, or retry later.

    ## Writing to Google Business Profile

    Needs API write access. Every write acts on one profile, and nothing uses credits. Write access alone does not cover `GET` routes, such as the lists of profiles and scheduled items; those need API read access.

    | What | Now on Google | Scheduled in Grid My Business |
    | --- | --- | --- |
    | Photos and videos | `POST /profiles/{profileId}/media`, `DELETE …/media/{mediaId}` | `…/media/scheduled` (see below) |
    | Posts | `POST /profiles/{profileId}/posts`, `PATCH` and `DELETE …/posts/{postId}` | `…/posts/scheduled` |
    | Review replies | `PUT` and `DELETE /profiles/{profileId}/reviews/{reviewId}/reply` | not schedulable |

    - Changes "now on Google" go live at once and are public. Google may still review a post or photo before it shows.
    - **Posts** are JSON. To add a photo, send `multipart/form-data` with the post as JSON in a `post` field and the photo in a `file` field (JPEG or PNG up to 5 MB). `EVENT` and `OFFER` posts need `event` (title and dates); `offer` is only for `OFFER`. `callToAction.url` is needed for every action except `CALL`.
    - **Scheduled posts** take the same fields plus `publishAt` and an optional `timezone`. Sending the same text for the same `publishAt` again returns the post already made.
    - `PATCH` changes only the fields you send. A nested field such as `event` is replaced as a whole.

    ## Scheduling photos and videos

    Needs API write access. Send the file and its details in one `multipart/form-data` request:

    ```bash
    curl -X POST https://api.gridmybusiness.com/v1/profiles/$PROFILE_ID/media/scheduled \
      -H "Authorization: Bearer $GMB_API_KEY" \
      -F "file=@photo.jpg" \
      -F "publishAt=2026-12-01T09:00:00+08:00" \
      -F "timezone=Asia/Kuala_Lumpur" \
      -F "category=EXTERIOR"
    ```

    - **Files:** one per request. Photos JPEG or PNG up to 5 MB; videos MP4 up to 20 MB. We check the file itself, not its name. Google can still refuse a file, for example a video longer than 30 seconds. The item then gets `status: failed` and an `errorCode`.
    - **publishAt** is a date and time with an offset. We publish within 5 minutes after it; a time in the past publishes on the next run. `timezone` (an IANA name such as `Asia/Kuala_Lumpur`) is optional and only changes how the app shows the time.
    - **Retries are safe:** the same file for the same profile and `publishAt` returns the item already made, while it is still scheduled.
    - **Change** an item with `PATCH`: send JSON with a new `publishAt`, `timezone` or `category`, or `multipart/form-data` with a new `file` to replace it. A failed item goes back to `scheduled`.
    - **Delete** an item with `DELETE`; its file is deleted too.
    - When an item is published it leaves the scheduled list and shows in `GET /profiles/{profileId}/media`.
    - Scheduling uses no credits. If the workspace has no active plan, items wait until it has one.

    ## Rate limits

    Limits are per workspace: all of its keys share them.

    | Bucket | Per minute | Per day | Used by |
    | --- | --- | --- | --- |
    | Standard | 60 | 10,000 | Most routes |
    | Google | 30 | 3,000 | Routes marked "Rate bucket: Google" |

    A call to `GET /performance` for many profiles uses one Google request per profile. Limits reset each minute and at 00:00 UTC. Each response has `RateLimit` headers with the requests left (`r`) and seconds to reset (`t`).
servers:
  - url: https://api.gridmybusiness.com/v1
security:
  - apiKey: []
tags:
  - name: Workspace and profiles
    description: >-
      Start here. `GET /profiles` gives the profile `id` that most other routes need. Google routes need a profile with `source: google`.
  - name: Many profiles
    description: >-
      Read up to 25 profiles in one call: `profileIds=id1,id2`. If one id is not in your workspace, the call returns 404. If one profile fails, its item has an `error` and the others still have `data`.
  - name: Keywords and rankings
    description: >-
      Get `keywordId` values from `/keywords`, then read one keyword or `/rankings` for history. Rank 1 is best; outside the top 20 counts as 21.
  - name: Maps scans
    description: >-
      A scan ranks the business at each pin of a grid (`gridSize` 3 = 9 pins). `rank` is `null` outside the top 20. Monitors repeat a scan on a schedule.
  - name: Competitors
    description: >-
      Rivals tracked against a profile. Pass scan ids from `/scans` to `/competitors/performance` to compare on those scans.
  - name: AI Search
    description: >-
      Which businesses AI engines (`chatgpt`, `gemini`, `ai-mode`, `ai-overviews`) name at each pin. For a zone's answer text, use its `slots[0]`.
  - name: Citations
    description: >-
      Directory listings of the business, with a `status` and a name, address and phone check (`nap`).
  - name: NAP distribution
    description: >-
      Press releases that spread the business name, address and phone, and where they were picked up.
  - name: Reviews
    description: >-
      Google reviews (live, paged with `pageToken`), monthly growth, and the stored AI analysis (`null` if none). `/review-stream` lists new reviews across the workspace. With API write access, reply to a review or delete the reply.
  - name: AI Audit
    description: >-
      The latest stored AI Audit of a profile, or `null` if none exists yet.
  - name: Posts
    description: >-
      Live Google posts, plus scheduled posts and post automations. With API write access, publish, schedule, change and delete posts; see "Writing to Google Business Profile" above.
  - name: Media
    description: >-
      Live Google photos and videos, plus media scheduled to publish. With API write access, upload, schedule, change and delete scheduled media; see "Scheduling photos and videos" above.
  - name: Business information
    description: >-
      Hours, categories, address, services and attributes, read live from Google.
  - name: Performance
    description: >-
      Calls, clicks, directions and impressions from Google, plus search terms. Google lags a few days, so the newest days can be partial.
  - name: Lead Gen Widget
    description: >-
      Your widgets, the leads they collected and the scans those visitors ran. Use the widget `id`, not its public `embedId`.
paths:
  /workspace:
    get:
      tags: [Workspace and profiles]
      summary: Get the workspace of the key
      description: "Returns the name of the workspace and the counts of its profiles, with the average rating. Use it to check that a key works."
      responses:
        '200':
          description: Workspace summary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles:
    get:
      tags: [Workspace and profiles]
      summary: List business profiles
      description: "Lists the business profiles of the workspace, with rating, review count, GMB Score and the average Maps rank of the last 30 days. Use the id of a row as profileId in other routes. Filter with search and tags."
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PageSize'
        - { name: search, in: query, schema: { type: string, maxLength: 200 }, description: Match on name or address }
        - { name: sort, in: query, schema: { type: string, enum: [lastOpened, rating, alphabetical], default: lastOpened } }
        - { name: direction, in: query, schema: { type: string, enum: [asc, desc], default: desc } }
        - { name: tags, in: query, schema: { type: string }, description: 'Comma-separated tags, e.g. dental,clinic' }
      responses:
        '200':
          description: One page of profiles
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProfilePageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /rankings:
    get:
      tags: [Many profiles]
      summary: "Rank history of many profiles"
      description: "The same data as /profiles/{profileId}/rankings, one item per profile."
      parameters:
        - {"$ref":"#/components/parameters/ProfileIds"}
        - {"$ref":"#/components/parameters/From"}
        - {"$ref":"#/components/parameters/To"}
        - {"name":"interval","in":"query","description":"Size of one history point","schema":{"type":"string","enum":["day","month"],"default":"day"}}
      responses:
        '200':
          description: "Rank history per profile"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RankingsBatchEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /scans:
    get:
      tags: [Many profiles]
      summary: "Maps scans of many profiles, with all pins"
      description: "Full scans, the same as /scans/{scanId}, so you need no call per scan. Use from and to to get only new scans. Scans older than the plan history window are left out. The date range is at most 365 days."
      parameters:
        - {"$ref":"#/components/parameters/ProfileIds"}
        - {"$ref":"#/components/parameters/Page"}
        - {"name":"pageSize","in":"query","description":"Scans per page. The default and the maximum are 25.","schema":{"type":"integer","minimum":1,"maximum":25,"default":25}}
        - {"$ref":"#/components/parameters/From"}
        - {"$ref":"#/components/parameters/To"}
        - {"$ref":"#/components/parameters/Direction"}
      responses:
        '200':
          description: "One page of scans, by date"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScanBatchPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /performance:
    get:
      tags: [Many profiles]
      summary: "Google performance metrics of many profiles"
      description: "The same data as /profiles/{profileId}/performance, one item per profile. A profile without a Google connection gets the API_GOOGLE_NOT_CONNECTED error in its item. Rate bucket: Google, one request per profile."
      parameters:
        - {"$ref":"#/components/parameters/ProfileIds"}
        - {"$ref":"#/components/parameters/FromRequired"}
        - {"$ref":"#/components/parameters/ToRequired"}
      responses:
        '200':
          description: "Performance metrics per profile"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PerformanceBatchEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}:
    get:
      tags: [Workspace and profiles]
      summary: Get a business profile
      description: "The fields of the list row, plus the description, phone, website, location and whether protection is on."
      parameters:
        - $ref: '#/components/parameters/ProfileId'
      responses:
        '200':
          description: Profile
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProfileEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/score:
    get:
      tags: [Workspace and profiles]
      summary: Get the GMB Score of a profile
      description: "Returns the GMB Score from 0 to 100 and the result of every check, as points earned out of points possible. A check that does not apply, or that could not be read, leaves the score calculation. provisional is true when a check could not be read."
      parameters:
        - $ref: '#/components/parameters/ProfileId'
      responses:
        '200':
          description: Score
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProfileScoreEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/keywords:
    get:
      tags: [Keywords and rankings]
      summary: "List keywords of a profile"
      description: "Each row is one keyword with one grid setup, with its average rank from the latest scan."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"$ref":"#/components/parameters/Search"}
        - {"name":"monitoredOnly","in":"query","description":"Only keywords with an active monitor","schema":{"type":"boolean","default":false}}
        - {"name":"sort","in":"query","schema":{"type":"string","enum":["avgPosition","lastScanned","alphabetical"],"default":"lastScanned"}}
        - {"$ref":"#/components/parameters/Direction"}
      responses:
        '200':
          description: "One page of keywords"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeywordPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/keywords/stats:
    get:
      tags: [Keywords and rankings]
      summary: "Keyword totals and average rank"
      description: "Averages count an unranked pin as 21. Local 3-Pack presence is a percent of pins."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Keyword statistics"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeywordStatsEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/keywords/{keywordId}:
    get:
      tags: [Keywords and rankings]
      summary: "Get one keyword with the pins of a scan"
      description: "Returns the pins of the scan on the given day, or of the latest scan. 404 when the keyword has no scan."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/KeywordId"}
        - {"name":"date","in":"query","description":"Day of the scan (UTC). The latest scan when left out.","schema":{"type":"string","format":"date"}}
        - {"name":"limit","in":"query","description":"How many top performers to return","schema":{"type":"integer","minimum":1,"maximum":50,"default":10}}
      responses:
        '200':
          description: "Keyword detail"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeywordDetailEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/rankings:
    get:
      tags: [Keywords and rankings]
      summary: "Rank history of all keywords"
      description: "Average rank and Local 3-Pack share per keyword over time. Averages count an unranked pin as 21. Without from and to, the last 30 days are returned. The range is at most 365 days."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/From"}
        - {"$ref":"#/components/parameters/To"}
        - {"name":"interval","in":"query","description":"Size of one history point","schema":{"type":"string","enum":["day","month"],"default":"day"}}
      responses:
        '200':
          description: "Rank history"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RankingsEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/scans:
    get:
      tags: [Maps scans]
      summary: "List Maps scans of a profile"
      description: "Scans older than the plan history window are left out. The date range is at most 365 days."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"$ref":"#/components/parameters/Search"}
        - {"$ref":"#/components/parameters/From"}
        - {"$ref":"#/components/parameters/To"}
        - {"$ref":"#/components/parameters/Direction"}
      responses:
        '200':
          description: "One page of scans, by date"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScanPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/monitors:
    get:
      tags: [Maps scans]
      summary: "List scan monitors of a profile"
      description: "A monitor repeats a keyword scan on a schedule."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
      responses:
        '200':
          description: "One page of monitors"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MonitorPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /scans/{scanId}:
    get:
      tags: [Maps scans]
      summary: "One Maps scan with all pins"
      description: "Returns 404 for a scan hidden by the plan history window."
      parameters:
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "Scan detail"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScanEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /scans/{scanId}/local-3-pack-history:
    get:
      tags: [Maps scans]
      summary: "Local 3-Pack history of a scan"
      description: "How many pins sat at rank 1, 2 and 3 of the Local 3-Pack on each day."
      parameters:
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "Local 3-Pack history points"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Local3PackHistoryEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/competitors:
    get:
      tags: [Competitors]
      summary: "List tracked competitors"
      description: "Paused competitors are left out unless includePaused is true. History holds the changes of the last 90 days."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"$ref":"#/components/parameters/Search"}
        - {"name":"includePaused","in":"query","schema":{"type":"boolean","default":false}}
        - {"name":"sort","in":"query","schema":{"type":"string","enum":["avgPosition","lastChanged","alphabetical"],"default":"lastChanged"}}
        - {"$ref":"#/components/parameters/Direction"}
      responses:
        '200':
          description: "One page of competitors"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompetitorPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/competitors/performance:
    get:
      tags: [Competitors]
      summary: "Competitor performance on scans"
      description: "Compares the business with its rivals on the pins of the selected scans and on all scans of the plan history window. Averages count an unranked pin as 21."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"name":"scanId","in":"query","style":"form","explode":true,"description":"Scan id to include in the latest section. Repeat it for more, up to 10: ?scanId=a&scanId=b. Never comma-separated.","schema":{"type":"array","maxItems":10,"items":{"type":"string","pattern":"^[a-f0-9]{24}$"}}}
      responses:
        '200':
          description: "Competitor performance"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompetitorPerformanceEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/competitors/{competitorId}/position-history:
    get:
      tags: [Competitors]
      summary: "Average rank history of a competitor"
      description: "One point per interval. Averages count an unranked pin as 21."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/CompetitorId"}
        - {"$ref":"#/components/parameters/IntervalCount"}
        - {"$ref":"#/components/parameters/IntervalUnit"}
      responses:
        '200':
          description: "Average rank points"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompetitorPositionHistoryEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/competitors/{competitorId}/local-3-pack-history:
    get:
      tags: [Competitors]
      summary: "Local 3-Pack history of a competitor"
      description: "One point per interval, as a percent of pins in the Local 3-Pack."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/CompetitorId"}
        - {"$ref":"#/components/parameters/IntervalCount"}
        - {"$ref":"#/components/parameters/IntervalUnit"}
      responses:
        '200':
          description: "Local 3-Pack presence points"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompetitorLocal3PackHistoryEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans:
    get:
      tags: [AI Search]
      summary: "List AI Search scans"
      description: "Each scan asks AI engines one query on a grid of pins."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/AiPageSize"}
      responses:
        '200':
          description: "One page of AI scans, newest first"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/rank-history:
    get:
      tags: [AI Search]
      summary: "AI share of voice by day"
      description: "AI share of voice per query and day on one platform. Without from and to, the last 30 days are returned. The range is at most 365 days."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"name":"platform","in":"query","required":true,"schema":{"$ref":"#/components/schemas/AiPlatform"}}
        - {"$ref":"#/components/parameters/From"}
        - {"$ref":"#/components/parameters/To"}
      responses:
        '200':
          description: "Rank history rows"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanRankHistoryEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/insights/queries:
    get:
      tags: [AI Search]
      summary: "Tracked AI queries with their totals"
      description: "One row per query, with its monitor and its pin counts per platform, and topic totals."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/AiPageSize"}
        - {"$ref":"#/components/parameters/Search"}
        - {"name":"monitoredOnly","in":"query","description":"Only queries with a monitor","schema":{"type":"boolean","default":false}}
        - {"name":"sort","in":"query","schema":{"type":"string","enum":["aiSov","lastScanned","alphabetical"],"default":"aiSov"}}
        - {"name":"direction","in":"query","schema":{"$ref":"#/components/schemas/SortDirection","default":"desc"}}
      responses:
        '200':
          description: "One page of tracked queries"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanQueryInsightsPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/insights/platforms:
    get:
      tags: [AI Search]
      summary: "AI results by platform"
      description: "Rolls up the scans of the window per platform. Percentages are left to the client: use answeredPinCount as the denominator."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/WindowDays"}
      responses:
        '200':
          description: "Platform insights"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanPlatformInsightsEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/insights/competitors:
    get:
      tags: [AI Search]
      summary: "Businesses AI engines name"
      description: "Businesses named in AI answers over the window, with the window before for comparison."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/WindowDays"}
        - {"name":"queryId","in":"query","description":"Only answers to this tracked query","schema":{"type":"string","pattern":"^[a-f0-9]{24}$"}}
      responses:
        '200':
          description: "Competitor insights"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanCompetitorInsightsEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/{scanId}:
    get:
      tags: [AI Search]
      summary: "Get one AI scan"
      description: "The scan with its query, status, grid settings and the status and metrics of each platform. Use the report route for zones and businesses."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "AI scan"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/{scanId}/report:
    get:
      tags: [AI Search]
      summary: "AI scan with all platform details"
      description: "The scan plus the zones, businesses, sources and phrases of every platform in one response."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "AI scan report"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanReportEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/{scanId}/analysis:
    get:
      tags: [AI Search]
      summary: "Stored AI analysis of a scan"
      description: "Cached only: this route never starts an analysis. data is null when nothing is stored yet."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "The stored analysis, or data null"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanAnalysisEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/{scanId}/history:
    get:
      tags: [AI Search]
      summary: "History of the query of a scan"
      description: "Results of the same query over time, on every platform."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "Query history"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanQueryHistoryEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/{scanId}/zones/{platform}:
    get:
      tags: [AI Search]
      summary: "Zones of one platform in an AI scan"
      description: "A zone is a group of nearby pins that share one AI answer."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScanId"}
        - {"$ref":"#/components/parameters/AiPlatformPath"}
      responses:
        '200':
          description: "Zones of the platform"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanZonesEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/ai-scans/{scanId}/zones/{platform}/{slot}/answer:
    get:
      tags: [AI Search]
      summary: "Full AI answer text of a zone"
      description: "The raw answer as markdown, cut at 4,000 characters."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScanId"}
        - {"$ref":"#/components/parameters/AiPlatformPath"}
        - {"name":"slot","in":"path","required":true,"description":"The zone's first slot (slots[0] in the zones response), where its answer is stored. Other slots of the zone return 404.","schema":{"type":"integer","minimum":0,"maximum":224}}
      responses:
        '200':
          description: "Answer text"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiScanZoneAnswerTextEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/citations:
    get:
      tags: [Citations]
      summary: "List citations of a profile"
      description: "A citation is a listing of the business in a directory."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"$ref":"#/components/parameters/Search"}
        - {"name":"status","in":"query","description":"Only citations with these statuses. Comma-separated, e.g. todo,processing. Allowed: todo, processing, active, lost, ignored, not_found.","schema":{"type":"string"}}
        - {"name":"sort","in":"query","schema":{"type":"string","enum":["lastUpdated","alphabetical"],"default":"lastUpdated"}}
        - {"$ref":"#/components/parameters/Direction"}
      responses:
        '200':
          description: "One page of citations"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CitationPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/citations/directories:
    get:
      tags: [Citations]
      summary: "List directories available to a profile"
      description: "Directories where the business can have a citation, with their type and countries."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Directories"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CitationDirectoryListEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/distributions:
    get:
      tags: [NAP distribution]
      summary: "List press distributions"
      description: "Press distributions of the profile. Each row holds the release text, the publish settings and the status."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"$ref":"#/components/parameters/Search"}
        - {"name":"status","in":"query","description":"Only distributions with these statuses. Comma-separated, e.g. draft,processing. Allowed: draft, processing, approved, rejected, archived.","schema":{"type":"string"}}
        - {"name":"sort","in":"query","schema":{"type":"string","enum":["lastUpdated","createdAt"],"default":"lastUpdated"}}
        - {"$ref":"#/components/parameters/Direction"}
      responses:
        '200':
          description: "One page of distributions"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DistributionPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/distributions/{distributionId}:
    get:
      tags: [NAP distribution]
      summary: "Get one press distribution"
      description: "One distribution with the release text, the contact and the publish settings. Use the report route for pickup."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/DistributionId"}
      responses:
        '200':
          description: "Distribution"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DistributionEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/distributions/{distributionId}/report:
    get:
      tags: [NAP distribution]
      summary: "Pickup report of a distribution"
      description: "Read live from the press distribution partner. Uses the Google bucket because it reads from a partner and not from stored data. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/DistributionId"}
      responses:
        '200':
          description: "Distribution report"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DistributionReportEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/reviews:
    get:
      tags: [Reviews]
      summary: "List Google reviews"
      description: "Read live from Google, newest first unless orderBy says otherwise. Needs a Google-connected profile (409 otherwise). Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/GoogleReviewPageSize"}
        - {"$ref":"#/components/parameters/PageToken"}
        - {"name":"orderBy","in":"query","description":"Sort order of Google. Google default when left out.","schema":{"type":"string","enum":["rating","rating desc","updateTime desc"]}}
      responses:
        '200':
          description: "One page of reviews"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReviewListEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/reviews/{reviewId}/reply:
    put:
      tags: [Reviews]
      summary: "Reply to a review"
      description: "Adds or replaces the business reply on Google. Public at once. Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ReviewId"}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReviewReplyRequest'
      responses:
        '200':
          description: "The reply"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReviewReplyEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
    delete:
      tags: [Reviews]
      summary: "Delete a review reply"
      description: "Deletes the business reply on Google. Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ReviewId"}
      responses:
        '200':
          description: "Deleted"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeletedEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/reviews/growth:
    get:
      tags: [Reviews]
      summary: "Get total reviews by month"
      description: "The review total of the profile for each month, from stored data. Use it to chart review growth."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Monthly review totals"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReviewGrowthEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/reviews/analysis:
    get:
      tags: [Reviews]
      summary: "Stored AI analysis of reviews"
      description: "Cached only: this route never starts an analysis. data is null when nothing is stored yet."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "The stored analysis, or data null"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReviewAnalysisEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /review-stream:
    get:
      tags: [Reviews]
      summary: "New review events across the workspace"
      description: "Stored review events of all profiles of the workspace. Without from and to, the last 14 days are returned. The range is under 14 days."
      parameters:
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"name":"from","in":"query","description":"First day, inclusive (UTC)","schema":{"type":"string","format":"date"}}
        - {"name":"to","in":"query","description":"Last day, inclusive (UTC)","schema":{"type":"string","format":"date"}}
      responses:
        '200':
          description: "One page of review stream entries, newest first"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReviewStreamPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/audit:
    get:
      tags: [AI Audit]
      summary: "Stored AI audit of a profile"
      description: "Cached only: this route never starts an audit. data is null when nothing is stored yet."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "The stored audit, or data null"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/posts:
    get:
      tags: [Posts]
      summary: "List live Google posts"
      description: "Read live from Google. Page with pageToken and nextPageToken. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/GooglePageSize"}
        - {"$ref":"#/components/parameters/PageToken"}
      responses:
        '200':
          description: "One page of posts"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
    post:
      tags: [Posts]
      summary: "Publish a post now"
      description: "Creates the post on Google at once. Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/PostMultipartRequest'
      responses:
        '200':
          description: "The post on Google"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/posts/scheduled:
    get:
      tags: [Posts]
      summary: "List scheduled posts"
      description: "Posts saved in Grid My Business, not yet or no longer on Google. Not paged."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Scheduled posts"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledPostListEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
    post:
      tags: [Posts]
      summary: "Schedule a post"
      description: "Saves the post to publish at publishAt; we publish within 5 minutes after it. Needs API write access. The same summary for the same publishAt returns the post already made."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SchedulePostRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SchedulePostMultipartRequest'
      responses:
        '200':
          description: "The scheduled post"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledPostEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/posts/scheduled/{scheduleId}:
    get:
      tags: [Posts]
      summary: "Get one scheduled post"
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScheduleId"}
      responses:
        '200':
          description: "The scheduled post"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledPostEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
    patch:
      tags: [Posts]
      summary: "Change a scheduled post"
      description: "Changes the fields you send, or the photo. Needs API write access. A failed post goes back to scheduled."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScheduleId"}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateScheduledPostRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/UpdateScheduledPostMultipartRequest'
      responses:
        '200':
          description: "The changed scheduled post"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledPostEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
    delete:
      tags: [Posts]
      summary: "Delete a scheduled post"
      description: "Deletes the post and its photo. Needs API write access."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScheduleId"}
      responses:
        '200':
          description: "Deleted"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeletedEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/posts/automations:
    get:
      tags: [Posts]
      summary: "List post automations"
      description: "Automations that write and publish posts on a schedule. Not paged."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Post automations"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostAutomationListEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/posts/{postId}:
    patch:
      tags: [Posts]
      summary: "Change a post on Google"
      description: "Changes the fields you send, or the photo, on the live post. Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/PostId"}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePostRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/UpdatePostMultipartRequest'
      responses:
        '200':
          description: "The post on Google"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
    delete:
      tags: [Posts]
      summary: "Delete a post on Google"
      description: "Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/PostId"}
      responses:
        '200':
          description: "Deleted"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeletedEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/media:
    get:
      tags: [Media]
      summary: "List Google photos and videos"
      description: "Read live from Google. Page with pageToken and nextPageToken. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/GooglePageSize"}
        - {"$ref":"#/components/parameters/PageToken"}
      responses:
        '200':
          description: "One page of media"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
    post:
      tags: [Media]
      summary: "Publish a photo or video now"
      description: "Uploads the file to Google at once, as multipart/form-data. Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/PublishMediaRequest'
      responses:
        '200':
          description: "The media item on Google"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaItemEnvelope'
        '400': { $ref: '#/components/responses/MediaFileInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/media/scheduled:
    get:
      tags: [Media]
      summary: "List scheduled media"
      description: "Media saved in Grid My Business to publish later."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
      responses:
        '200':
          description: "One page of scheduled media"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledMediaPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
    post:
      tags: [Media]
      summary: "Schedule a photo or video"
      description: "Sends the file and its publish details in one request. Needs API write access. The same file for the same profile and publishAt returns the item already made."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ScheduleMediaRequest'
      responses:
        '200':
          description: "The scheduled media"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledMediaEnvelope'
        '400': { $ref: '#/components/responses/MediaFileInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/media/scheduled/{scheduleId}:
    get:
      tags: [Media]
      summary: "Get one scheduled media item"
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScheduleId"}
      responses:
        '200':
          description: "The scheduled media"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledMediaEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
    patch:
      tags: [Media]
      summary: "Change scheduled media"
      description: "Change the publish time, time zone or category with JSON, or send multipart/form-data with a new file to replace it. Needs API write access. A failed item goes back to scheduled."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScheduleId"}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateScheduledMediaRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ReplaceScheduledMediaRequest'
      responses:
        '200':
          description: "The changed scheduled media"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledMediaEnvelope'
        '400': { $ref: '#/components/responses/MediaFileInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
    delete:
      tags: [Media]
      summary: "Delete scheduled media"
      description: "Deletes the item and its file. Needs API write access. Media already on Google is not affected."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/ScheduleId"}
      responses:
        '200':
          description: "Deleted"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeletedEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /profiles/{profileId}/media/{mediaId}:
    delete:
      tags: [Media]
      summary: "Delete a photo or video on Google"
      description: "Use the id from GET /profiles/{profileId}/media. Needs API write access. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/MediaId"}
      responses:
        '200':
          description: "Deleted"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeletedEnvelope'
        '400': { $ref: '#/components/responses/WriteInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/WriteForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/information:
    get:
      tags: [Business information]
      summary: "Business information from Google"
      description: "Read live from Google: hours, categories, address, services and links. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Business information"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BusinessInformationEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/information/attributes:
    get:
      tags: [Business information]
      summary: "Attributes from Google"
      description: "Read live from Google, such as wheelchair access or payment types. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
      responses:
        '200':
          description: "Attributes"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttributeListEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/performance:
    get:
      tags: [Performance]
      summary: "Google performance metrics"
      description: "Calls, clicks, direction requests and impressions from Google, with totals against the range before. Dates are UTC. The range is at most 365 days. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/FromRequired"}
        - {"$ref":"#/components/parameters/ToRequired"}
      responses:
        '200':
          description: "Performance metrics"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PerformanceEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /profiles/{profileId}/performance/search-keywords:
    get:
      tags: [Performance]
      summary: "Search terms that showed the profile"
      description: "Search terms from Google with their impressions, most first. The range is at most 365 days. Rate bucket: Google."
      parameters:
        - {"$ref":"#/components/parameters/ProfileId"}
        - {"$ref":"#/components/parameters/FromRequired"}
        - {"$ref":"#/components/parameters/ToRequired"}
      responses:
        '200':
          description: "Search keywords"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchKeywordsEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/GoogleNotConnected' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }
  /embeds:
    get:
      tags: [Lead Gen Widget]
      summary: "List Lead Gen Widget embeds"
      description: "All embeds of the workspace. Not paged."
      responses:
        '200':
          description: "Embeds"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedListEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /embeds/{embedId}/leads:
    get:
      tags: [Lead Gen Widget]
      summary: "List leads of an embed"
      description: "Visitors who left an email on the widget. Send from and to together, or neither. The range is at most 365 days."
      parameters:
        - {"$ref":"#/components/parameters/EmbedId"}
        - {"$ref":"#/components/parameters/Page"}
        - {"$ref":"#/components/parameters/PageSize"}
        - {"name":"from","in":"query","description":"First day, inclusive (UTC). Needs to.","schema":{"type":"string","format":"date"}}
        - {"name":"to","in":"query","description":"Last day, inclusive (UTC). Needs from.","schema":{"type":"string","format":"date"}}
      responses:
        '200':
          description: "One page of leads, newest first"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedLeadPageEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /embed-scans/{scanId}:
    get:
      tags: [Lead Gen Widget]
      summary: "Get one widget scan"
      description: "The scan a visitor ran on the widget."
      parameters:
        - {"$ref":"#/components/parameters/ScanId"}
      responses:
        '200':
          description: "Widget scan"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedScanEnvelope'
        '400': { $ref: '#/components/responses/InvalidInput' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/PlanInsufficient' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimited' }
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: "Send your API key as `Authorization: Bearer <key>`. Keys start with gmb_live_. Create one in the app under Workspace Tools, then API."
  parameters:
    Page:
      name: page
      in: query
      description: Page number, starting at 1.
      schema: { type: integer, minimum: 1, maximum: 10000, default: 1 }
    PageSize:
      name: pageSize
      in: query
      description: Rows per page. The default is 20 and the maximum is 100.
      schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
    PostId:
      name: postId
      in: path
      required: true
      description: Id of a live Google post. Take it from GET /profiles/{profileId}/posts.
      schema: { type: string, pattern: '^[A-Za-z0-9_-]{1,200}$' }
    ReviewId:
      name: reviewId
      in: path
      required: true
      description: Id of a Google review. Take it from GET /profiles/{profileId}/reviews.
      schema: { type: string, pattern: '^[A-Za-z0-9_-]{1,200}$' }
    MediaId:
      name: mediaId
      in: path
      required: true
      description: Id of a photo or video on Google. Take it from GET /profiles/{profileId}/media.
      schema: { type: string, pattern: '^[A-Za-z0-9_-]{1,200}$' }
    ScheduleId:
      name: scheduleId
      in: path
      required: true
      description: Id of a scheduled media item or scheduled post. Take it from the matching scheduled list.
      schema: { type: string, pattern: '^[a-f0-9]{24}$' }
    ProfileId:
      name: profileId
      in: path
      required: true
      description: Id of a business profile. Take it from GET /profiles.
      schema: { type: string, pattern: '^[a-f0-9]{24}$' }
      example: '65a1f3c2e4b0a1d2c3e4f5a1'
    ProfileIds:
      name: profileIds
      in: query
      required: true
      description: Up to 25 profile ids from GET /profiles, separated by commas.
      schema: { type: string }
      example: '65a1f3c2e4b0a1d2c3e4f5a1,65a1f3c2e4b0a1d2c3e4f5b2'
    From:
      name: from
      in: query
      description: First day, inclusive (UTC). The range is at most 365 days.
      schema: { type: string, format: date }
      example: '2026-10-01'
    To:
      name: to
      in: query
      description: Last day, inclusive (UTC)
      schema: { type: string, format: date }
      example: '2026-10-03'
    Search:
      name: search
      in: query
      description: Text to match. Special characters match literally.
      schema:
        type: string
        maxLength: 200
    Direction:
      name: direction
      in: query
      schema:
        $ref: '#/components/schemas/SortDirection'
        default: desc
    PageToken:
      name: pageToken
      in: query
      description: 'The nextPageToken of the page before. Opaque: send it as received.'
      schema:
        type: string
        minLength: 1
        maxLength: 2000
    GooglePageSize:
      name: pageSize
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
    GoogleReviewPageSize:
      name: pageSize
      in: query
      description: Google allows at most 50 reviews a page.
      schema:
        type: integer
        minimum: 1
        maximum: 50
        default: 20
    AiPageSize:
      name: pageSize
      in: query
      description: Rows hold per-platform metrics, so the page is smaller than on other lists.
      schema:
        type: integer
        minimum: 1
        maximum: 50
        default: 20
    FromRequired:
      name: from
      in: query
      required: true
      description: First day, inclusive (UTC). The range is at most 365 days.
      schema:
        type: string
        format: date
      example: '2026-10-01'
    ToRequired:
      name: to
      in: query
      required: true
      description: Last day, inclusive (UTC)
      schema:
        type: string
        format: date
      example: '2026-10-03'
    ScanId:
      name: scanId
      in: path
      required: true
      description: Id of a scan. Take it from the list route of the same data group.
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
      example: '65b2c4d6e8f0a1b2c3d4e5f6'
    KeywordId:
      name: keywordId
      in: path
      required: true
      description: The keywordId of a keyword row. It is 16 characters and encodes the keyword and its grid setup.
      schema:
        type: string
        pattern: ^[A-Za-z0-9_-]{16}$
      example: Fa6iGZD2Quf_Pne7
    CompetitorId:
      name: competitorId
      in: path
      required: true
      description: Id of a competitor. Take it from GET /profiles/{profileId}/competitors.
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
      example: '65a1f3c2e4b0a1d2c3e4f5c1'
    DistributionId:
      name: distributionId
      in: path
      required: true
      description: Id of a distribution. Take it from GET /profiles/{profileId}/distributions.
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
      example: '65a1f3c2e4b0a1d2c3e4f5d1'
    EmbedId:
      name: embedId
      in: path
      required: true
      description: The id of an embed from GET /embeds, not its public embedId
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
      example: '65a1f3c2e4b0a1d2c3e4f5e1'
    AiPlatformPath:
      name: platform
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/AiPlatform'
    IntervalCount:
      name: interval
      in: query
      description: Length of one point, in intervalUnit. At most 104 weeks or 24 months.
      schema:
        type: integer
        minimum: 1
        default: 1
    IntervalUnit:
      name: intervalUnit
      in: query
      schema:
        type: string
        enum:
          - week
          - month
        default: week
    WindowDays:
      name: days
      in: query
      description: Length of the window in days
      schema:
        type: string
        enum:
          - '7'
          - '30'
          - '90'
          - '365'
        default: '7'
  responses:
    InvalidInput:
      description: "A query or path value is not valid (INVALID_INPUT; the message names the field), or the API key was sent in the URL (API_KEY_IN_QUERY)."
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: INVALID_INPUT
              message: "Invalid value for \"from\"."
    Unauthorized:
      description: "The key is missing, malformed, unknown or revoked (code API_KEY_INVALID)"
      headers:
        WWW-Authenticate:
          description: 'Bearer realm="Grid My Business API"'
          schema: { type: string }
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_KEY_INVALID
              message: "The API key is missing, invalid or revoked."
    PlanInsufficient:
      description: "The workspace has no API read access (code API_PLAN_INSUFFICIENT)"
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_PLAN_INSUFFICIENT
              message: "Your plan does not include API access."
    NotFound:
      description: "The resource does not exist or is not in this workspace (code API_RESOURCE_NOT_FOUND)"
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_RESOURCE_NOT_FOUND
              message: "Resource not found."
    RateLimited:
      description: "Rate limit reached (code API_RATE_LIMITED). Wait for Retry-After seconds."
      headers:
        Retry-After:
          description: Seconds to wait before you try again.
          schema: { type: integer }
          example: 34
        RateLimit-Policy:
          description: 'The limits of the bucket. q is the quota and w is the window in seconds.'
          schema: { type: string }
          example: '"standard-minute";q=60;w=60, "standard-day";q=10000;w=86400'
        RateLimit:
          description: 'Your state. r is the requests left in the window and t is the seconds until it resets.'
          schema: { type: string }
          example: '"standard-minute";r=0;t=34, "standard-day";r=9884;t=51022'
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_RATE_LIMITED
              message: "Rate limit reached. Wait and try again."
    UpstreamUnavailable:
      description: "Google or a partner did not answer (code API_UPSTREAM_UNAVAILABLE). Retry with backoff."
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_UPSTREAM_UNAVAILABLE
              message: "The data source did not answer. Try again later."
    WriteForbidden:
      description: "The workspace has no API write access (code API_PLAN_INSUFFICIENT)"
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_PLAN_INSUFFICIENT
              message: "Your plan does not include API access."
    WriteInvalid:
      description: "A value is not valid (INVALID_INPUT), the photo is not a JPEG or PNG up to 5 MB (API_MEDIA_FILE_INVALID), or Google refused the change (API_GOOGLE_REJECTED)"
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: INVALID_INPUT
              message: "Invalid value for \"event\"."
    MediaFileInvalid:
      description: "A value is not valid (INVALID_INPUT), or the file is missing, not a JPEG or PNG up to 5 MB, or not an MP4 up to 20 MB (API_MEDIA_FILE_INVALID)"
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_MEDIA_FILE_INVALID
              message: "Send one file: a JPEG or PNG photo up to 5 MB, or an MP4 video up to 20 MB."
    GoogleNotConnected:
      description: "The profile's Google connection is missing or expired; reconnect it in Grid My Business (code API_GOOGLE_NOT_CONNECTED)"
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            success: false
            error:
              code: API_GOOGLE_NOT_CONNECTED
              message: "This profile has no working Google connection. Reconnect it in Grid My Business."
  schemas:
    ErrorEnvelope:
      type: object
      required: [success, error]
      properties:
        success: { type: boolean, const: false, example: false }
        error:
          type: object
          required: [code, message]
          properties:
            code: { type: string, description: 'Stable code. Branch on this value.', example: API_RESOURCE_NOT_FOUND }
            message: { type: string, description: 'Plain text for people. It can change.', example: 'Resource not found.' }
    BatchItemError:
      type: object
      properties:
        code:
          type: string
          example: API_GOOGLE_NOT_CONNECTED
        message:
          type: string
          example: This profile has no working Google connection. Reconnect it in Grid My Business.
    Workspace:
      type: object
      properties:
        id: { type: string, description: Id of the workspace, example: '65a1f3c2e4b0a1d2c3e4f501' }
        name: { type: [string, 'null'], example: Sunrise Bakery Group }
        totalProfiles: { type: integer, description: Business profiles in the workspace, example: 3 }
        activeProfiles: { type: integer, description: Profiles that are active, example: 3 }
        protectedProfiles: { type: integer, description: Profiles with protection turned on, example: 2 }
        averageRating: { type: number, description: Average Google rating over the profiles, example: 4.7 }
    WorkspaceEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/Workspace' }
    ProfileSummary:
      type: object
      properties:
        id: { type: string, description: Id of the profile. Use it as profileId in other routes., example: '65a1f3c2e4b0a1d2c3e4f5a1' }
        name: { type: string, example: Sunrise Bakery }
        address: { type: string, example: '1204 Example St, Austin, TX 78704, USA' }
        placeId: { type: [string, 'null'], description: Google place id of the business, example: ChIJSunriseBakery0AustinTX }
        rating: { type: [number, 'null'], description: Average Google rating, example: 4.7 }
        totalReviews: { type: integer, example: 312 }
        gmbScore: { type: [number, 'null'], description: GMB Score from 0 to 100, example: 78 }
        avgPosition: { type: [number, 'null'], description: Average Maps rank over the last 30 days, example: 6.22 }
        tags: { type: array, items: { type: string }, example: [bakery, austin] }
        active: { type: boolean, example: true }
        source: { type: string, description: google or manual, example: google }
    Profile:
      allOf:
        - $ref: '#/components/schemas/ProfileSummary'
        - type: object
          properties:
            description: { type: [string, 'null'], example: 'Family bakery in South Austin. We bake sourdough, pastries and custom cakes every morning.' }
            phone: { type: [string, 'null'], example: '(512) 555-0142' }
            website: { type: [string, 'null'], example: 'https://sunrisebakery.example' }
            countryCode: { type: [string, 'null'], example: US }
            latitude: { type: [number, 'null'], example: 30.2501 }
            longitude: { type: [number, 'null'], example: -97.7502 }
            avgPositionMonitoredKeywords: { type: [number, 'null'], description: Average Maps rank over monitored keywords, example: 5.8 }
            protectionEnabled: { type: boolean, example: true }
            createdAt: { type: string, format: date-time, example: '2026-03-14T16:20:41.000Z' }
            updatedAt: { type: string, format: date-time, example: '2026-10-03T09:12:05.000Z' }
    ProfilePageEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data:
          type: object
          properties:
            items: { type: array, items: { $ref: '#/components/schemas/ProfileSummary' } }
            page: { type: integer, example: 1 }
            pageSize: { type: integer, example: 20 }
            total: { type: integer, description: 'Profiles that match the filters, over all pages', example: 3 }
    ProfileEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/Profile' }
    ProfileScore:
      type: object
      properties:
        profileId: { type: string, example: '65a1f3c2e4b0a1d2c3e4f5a1' }
        score:
          type: [number, 'null']
          description: GMB Score from 0 to 100. Null while the business is permanently closed or when nothing could be measured.
          example: 78
        provisional: { type: boolean, description: True when a check could not be read. The score can change on a later read., example: false }
        status: { type: [string, 'null'], description: 'active, temporarily_closed or permanently_closed', example: active }
        checks:
          type: array
          example:
            - { check: primaryCategory, state: scored, earned: 12, max: 12, overridden: false }
            - { check: reviewCount, state: scored, earned: 9, max: 12, overridden: false }
            - { check: specialHours, state: not_applicable, earned: 0, max: 3, overridden: true }
            - { check: citations, state: scored, earned: 7.5, max: 10, overridden: false }
          items:
            type: object
            properties:
              check: { type: string, description: Name of the check }
              state: { type: string, description: 'scored, not_applicable or unavailable' }
              earned: { type: number, description: Points earned }
              max: { type: number, description: Points possible }
              overridden: { type: boolean, description: True when the owner marked the check as not applicable }
    ProfileScoreEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/ProfileScore' }
    SortDirection:
      type: string
      enum:
        - asc
        - desc
    Coordinate:
      type: object
      properties:
        lat:
          type: number
        lng:
          type: number
    AiPlatform:
      type: string
      enum:
        - chatgpt
        - gemini
        - ai-mode
        - ai-overviews
    Sentiment:
      type: string
      enum:
        - positive
        - neutral
        - negative
        - mixed
    SentimentPinCount:
      type: object
      properties:
        positive:
          type: integer
        neutral:
          type: integer
        negative:
          type: integer
        mixed:
          type: integer
      description: Pins per sentiment
    GridSettings:
      type: object
      properties:
        gridSize:
          type: integer
          description: Pins per side of the grid. A gridSize of 3 gives a 3 x 3 grid of 9 pins.
          example: 3
        distance:
          type: number
          description: Distance from the grid center to its edge
          example: 3
        distanceUnit:
          type: integer
          enum:
            - 0
            - 1
          description: 0 is km, 1 is miles
          example: 1
        distanceUnitLabel:
          type: string
          enum:
            - km
            - miles
          example: miles
    MonitorFrequency:
      type: object
      properties:
        value:
          type: integer
        unit:
          type: string
          enum:
            - day
            - week
            - month
          description: Time unit of value
    Keyword:
      allOf:
        - $ref: '#/components/schemas/GridSettings'
        - type: object
          properties:
            keywordId:
              type: string
              description: Id of this keyword with its grid setup. Use it in /profiles/{profileId}/keywords/{keywordId}
              example: Fa6iGZD2Quf_Pne7
            keyword:
              type: string
              example: bakery near me
            avgPosition:
              type:
                - number
                - 'null'
              description: Average rank over the pins of the latest scan. An unranked pin counts as 21.
              example: 6.22
            monitored:
              type: boolean
              example: true
            lastScanned:
              type:
                - string
                - 'null'
              format: date-time
              example: '2026-10-03T06:00:12.000Z'
            totalScans:
              type: integer
              example: 24
            inLocal3Pack:
              type:
                - boolean
                - 'null'
              description: Null when no scan of the keyword ran a Local 3-Pack check
              example: true
            latestScanId:
              type:
                - string
                - 'null'
              example: '65b2c4d6e8f0a1b2c3d4e5f6'
    KeywordPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Keyword'
        page:
          type: integer
          example: 1
        pageSize:
          type: integer
          example: 20
        total:
          type: integer
          description: Rows that match the filters, over all pages
          example: 12
    KeywordPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/KeywordPage'
    KeywordPositionStat:
      type: object
      properties:
        last30Days:
          type:
            - number
            - 'null'
          description: Average rank over the last 30 days
        monitoredKeywords:
          type:
            - number
            - 'null'
          description: Average over monitored keywords only
    KeywordStats:
      type: object
      properties:
        totalKeywords:
          type: integer
          example: 12
        activeKeywords:
          type: integer
          example: 5
        averagePosition:
          $ref: '#/components/schemas/KeywordPositionStat'
          example: { last30Days: 7.1, monitoredKeywords: 6.3 }
        local3PackPresence:
          $ref: '#/components/schemas/KeywordPositionStat'
          description: Share of pins in the Local 3-Pack, in percent
          example: { last30Days: 31.5, monitoredKeywords: 38.2 }
    KeywordStatsEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/KeywordStats'
    KeywordPin:
      type: object
      properties:
        row:
          type: integer
          example: 0
        col:
          type: integer
          example: 1
        lat:
          type: number
          example: 30.2936
        lng:
          type: number
          example: -97.7502
        rank:
          type:
            - integer
            - 'null'
          description: Rank of the business at this pin. Null means outside the top 20.
          example: 3
    KeywordPerformer:
      type: object
      properties:
        name:
          type: string
          example: Demo Bakehouse
        averageRank:
          type: number
          description: Average rank over the pins where the business appears
          example: 4.89
        appearances:
          type: integer
          description: Pins where the business appears
          example: 9
        rating:
          type:
            - number
            - 'null'
          example: 4.8
        reviewCount:
          type:
            - integer
            - 'null'
          example: 540
    KeywordDetail:
      allOf:
        - $ref: '#/components/schemas/GridSettings'
        - type: object
          properties:
            keywordId:
              type: string
              example: Fa6iGZD2Quf_Pne7
            keyword:
              type: string
              example: bakery near me
            scanId:
              type: string
              example: '65b2c4d6e8f0a1b2c3d4e5f6'
            scannedAt:
              type: string
              format: date-time
              example: '2026-10-03T06:00:12.000Z'
            totalPins:
              type: integer
              example: 9
            pins:
              type: array
              items:
                $ref: '#/components/schemas/KeywordPin'
              example:
                - { row: 0, col: 0, lat: 30.2936, lng: -97.8004, rank: 5 }
                - { row: 0, col: 1, lat: 30.2936, lng: -97.7502, rank: 3 }
                - { row: 0, col: 2, lat: 30.2936, lng: -97.7, rank: 2 }
                - { row: 1, col: 0, lat: 30.2501, lng: -97.8004, rank: 8 }
                - { row: 1, col: 1, lat: 30.2501, lng: -97.7502, rank: 4 }
                - { row: 1, col: 2, lat: 30.2501, lng: -97.7, rank: 1 }
                - { row: 2, col: 0, lat: 30.2066, lng: -97.8004, rank: null }
                - { row: 2, col: 1, lat: 30.2066, lng: -97.7502, rank: 9 }
                - { row: 2, col: 2, lat: 30.2066, lng: -97.7, rank: 3 }
            topPerformers:
              type: array
              items:
                $ref: '#/components/schemas/KeywordPerformer'
              description: Best businesses on this scan, best average rank first
              example:
                - { name: Demo Bakehouse, averageRank: 4.89, appearances: 9, rating: 4.8, reviewCount: 540 }
                - { name: Sunrise Bakery, averageRank: 6.22, appearances: 8, rating: 4.7, reviewCount: 312 }
                - { name: Sample Pastry Co, averageRank: 9.33, appearances: 7, rating: 4.5, reviewCount: 188 }
    KeywordDetailEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/KeywordDetail'
    RankingPoint:
      type: object
      properties:
        date:
          type: string
          description: YYYY-MM-DD, or YYYY-MM for the month interval (UTC)
          example: '2026-10-03'
        avgRank:
          type:
            - number
            - 'null'
          description: Average rank over the grid. An unranked pin counts as 21.
          example: 6.22
        local3PackPercent:
          type:
            - number
            - 'null'
          description: Share of pins in the Local 3-Pack, in percent
          example: 44.4
    KeywordRanking:
      allOf:
        - $ref: '#/components/schemas/GridSettings'
        - type: object
          properties:
            keywordId:
              type: string
              example: Fa6iGZD2Quf_Pne7
            keyword:
              type: string
              example: bakery near me
            monitored:
              type: boolean
              example: true
            history:
              type: array
              items:
                $ref: '#/components/schemas/RankingPoint'
              example:
                - { date: '2026-10-01', avgRank: 6.78, local3PackPercent: 33.3 }
                - { date: '2026-10-02', avgRank: 6.44, local3PackPercent: 44.4 }
                - { date: '2026-10-03', avgRank: 6.22, local3PackPercent: 44.4 }
    Rankings:
      type: object
      properties:
        from:
          type: string
          format: date
          example: '2026-10-01'
        to:
          type: string
          format: date
          example: '2026-10-03'
        interval:
          type: string
          enum:
            - day
            - month
          example: day
        keywords:
          type: array
          items:
            $ref: '#/components/schemas/KeywordRanking'
    RankingsEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/Rankings'
    RankingsBatchItem:
      type: object
      properties:
        profileId:
          type: string
          example: '65a1f3c2e4b0a1d2c3e4f5a1'
        data:
          oneOf:
            - $ref: '#/components/schemas/Rankings'
            - type: 'null'
        error:
          oneOf:
            - $ref: '#/components/schemas/BatchItemError'
            - type: 'null'
    RankingsBatchEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/RankingsBatchItem'
    ScanSummary:
      allOf:
        - $ref: '#/components/schemas/GridSettings'
        - type: object
          properties:
            id:
              type: string
              example: '65b2c4d6e8f0a1b2c3d4e5f6'
            keywordId:
              type: string
              example: Fa6iGZD2Quf_Pne7
            keyword:
              type: string
              example: bakery near me
            scannedAt:
              type: string
              format: date-time
              example: '2026-10-03T06:00:12.000Z'
            avgPosition:
              type:
                - number
                - 'null'
              description: Average rank over the pins. An unranked pin counts as 21.
              example: 6.22
            local3PackPercent:
              type:
                - number
                - 'null'
              description: Share of pins in the Local 3-Pack, in percent
              example: 44.4
            local3Pack:
              type: boolean
              description: Whether the scan was set to run the Local 3-Pack check
              example: true
            monitored:
              type: boolean
              example: true
            completed:
              type: boolean
              description: False while pins still wait for results
              example: true
    ScanPin:
      type: object
      properties:
        number:
          type: integer
          description: 1-based, top-left to bottom-right
          example: 2
        row:
          type: integer
          description: Row of the pin, 0 for the top row
          example: 0
        col:
          type: integer
          description: Column of the pin, 0 for the left column
          example: 1
        lat:
          type: number
          example: 30.2936
        lng:
          type: number
          example: -97.7502
        rank:
          type:
            - integer
            - 'null'
          description: Null means outside the top 20
          example: 3
        local3PackRank:
          type:
            - integer
            - 'null'
          description: 1 to 3 when in the Local 3-Pack. Null when out of it or not checked.
          example: 3
    ScanSummaryStats:
      type: object
      properties:
        totalPins:
          type: integer
          example: 9
        rankedPins:
          type: integer
          description: Pins where the business ranks in the top 20
          example: 8
        unrankedPins:
          type: integer
          description: Pins where the business is outside the top 20
          example: 1
        bestRank:
          type:
            - integer
            - 'null'
          example: 1
    Scan:
      allOf:
        - $ref: '#/components/schemas/ScanSummary'
        - type: object
          properties:
            profileId:
              type:
                - string
                - 'null'
              example: '65a1f3c2e4b0a1d2c3e4f5a1'
            businessName:
              type:
                - string
                - 'null'
              example: Sunrise Bakery
            businessAddress:
              type:
                - string
                - 'null'
              example: 1204 Example St, Austin, TX 78704, USA
            center:
              oneOf:
                - $ref: '#/components/schemas/Coordinate'
                - type: 'null'
              example: { lat: 30.2501, lng: -97.7502 }
            summary:
              $ref: '#/components/schemas/ScanSummaryStats'
            pins:
              type: array
              items:
                $ref: '#/components/schemas/ScanPin'
              description: One entry per pin, numbered from the top-left pin to the bottom-right pin
              example:
                - { number: 1, row: 0, col: 0, lat: 30.2936, lng: -97.8004, rank: 5, local3PackRank: null }
                - { number: 2, row: 0, col: 1, lat: 30.2936, lng: -97.7502, rank: 3, local3PackRank: 3 }
                - { number: 3, row: 0, col: 2, lat: 30.2936, lng: -97.7, rank: 2, local3PackRank: 2 }
                - { number: 4, row: 1, col: 0, lat: 30.2501, lng: -97.8004, rank: 8, local3PackRank: null }
                - { number: 5, row: 1, col: 1, lat: 30.2501, lng: -97.7502, rank: 4, local3PackRank: null }
                - { number: 6, row: 1, col: 2, lat: 30.2501, lng: -97.7, rank: 1, local3PackRank: 1 }
                - { number: 7, row: 2, col: 0, lat: 30.2066, lng: -97.8004, rank: null, local3PackRank: null }
                - { number: 8, row: 2, col: 1, lat: 30.2066, lng: -97.7502, rank: 9, local3PackRank: null }
                - { number: 9, row: 2, col: 2, lat: 30.2066, lng: -97.7, rank: 3, local3PackRank: 3 }
    ScanEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/Scan'
    ScanPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ScanSummary'
        page:
          type: integer
          example: 1
        pageSize:
          type: integer
          example: 20
        total:
          type: integer
          description: Rows that match the filters, over all pages
          example: 24
    ScanPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ScanPage'
    ScanBatchPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/Scan'
            page:
              type: integer
              example: 1
            pageSize:
              type: integer
              example: 25
            total:
              type: integer
              example: 83
    Local3PackHistoryPoint:
      type: object
      properties:
        date:
          type: string
          description: Time of the scan (ISO 8601, UTC)
          example: '2026-10-03T06:00:12.000Z'
        pinsChecked:
          type: integer
          example: 9
        pinsAtRank1:
          type: integer
          example: 1
        pinsAtRank2:
          type: integer
          example: 1
        pinsAtRank3:
          type: integer
          example: 2
    Local3PackHistoryEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: array
          items:
            $ref: '#/components/schemas/Local3PackHistoryPoint'
          description: Pins at each Local 3-Pack rank, one point per day with a scan of the same keyword and grid
    Monitor:
      allOf:
        - $ref: '#/components/schemas/GridSettings'
        - type: object
          properties:
            keywordId:
              type: string
            keyword:
              type: string
            local3Pack:
              type: boolean
            frequency:
              oneOf:
                - $ref: '#/components/schemas/MonitorFrequency'
                - type: 'null'
              description: How often the monitor runs
            timezone:
              type:
                - string
                - 'null'
            runTime:
              type:
                - string
                - 'null'
              description: Time of day the monitor runs, HH:mm
            dayOfWeek:
              type:
                - array
                - 'null'
              items:
                type: string
            dayOfMonth:
              type:
                - array
                - 'null'
              items:
                oneOf:
                  - type: integer
                  - const: last
            nextRunAt:
              type:
                - string
                - 'null'
              format: date-time
            lastRunAt:
              type:
                - string
                - 'null'
              format: date-time
    MonitorPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Monitor'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    MonitorPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/MonitorPage'
    CompetitorPosition:
      type: object
      properties:
        last30Days:
          type:
            - number
            - 'null'
          description: Average over the last 30 days
        monitoredKeywords:
          type:
            - number
            - 'null'
          description: Average over monitored keywords only
    CompetitorChange:
      type: object
      properties:
        old:
          type:
            - number
            - string
            - 'null'
        new:
          type:
            - number
            - string
            - 'null'
        change:
          type:
            - string
            - 'null'
          description: A sentence for textual changes, where old and new carry no values
    CompetitorHistoryEntry:
      type: object
      properties:
        id:
          type: string
        createdAt:
          type: string
          format: date-time
        changes:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/CompetitorChange'
          description: Changed fields by name
    Competitor:
      type: object
      properties:
        id:
          type: string
        placeId:
          type: string
        name:
          type: string
        address:
          type: string
        rating:
          type:
            - number
            - 'null'
        totalReviews:
          type:
            - integer
            - 'null'
        imageUrl:
          type:
            - string
            - 'null'
        categories:
          type: array
          items:
            type: string
        monitored:
          type: boolean
        avgPosition:
          $ref: '#/components/schemas/CompetitorPosition'
        local3Pack:
          type:
            - boolean
            - 'null'
        local3PackPresence:
          $ref: '#/components/schemas/CompetitorPosition'
          description: Share of pins in the Local 3-Pack, in percent
        frequency:
          type:
            - integer
            - 'null'
        frequencyUnit:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
        history:
          type: array
          items:
            $ref: '#/components/schemas/CompetitorHistoryEntry'
          description: Changes of the last 90 days, newest first
    CompetitorPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Competitor'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    CompetitorPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/CompetitorPage'
    CompetitorPerformanceRow:
      type: object
      properties:
        placeId:
          type: string
        isYou:
          type: boolean
        isTracked:
          type: boolean
        name:
          type: string
        category:
          type:
            - string
            - 'null'
        address:
          type:
            - string
            - 'null'
        mainImage:
          type:
            - string
            - 'null'
        latitude:
          type:
            - number
            - 'null'
        longitude:
          type:
            - number
            - 'null'
        rating:
          type:
            - number
            - 'null'
        reviews:
          type:
            - integer
            - 'null'
        averagePosition:
          type: number
          description: Average rank over the measured pins. An unranked pin counts as 21.
        top3Points:
          type: integer
          description: Pins where the business is in the top 3
        positionChange:
          type:
            - number
            - 'null'
          description: Change of average rank against the scan before. Null when there is nothing to compare.
    CompetitorPerformanceSection:
      type: object
      properties:
        scanCount:
          type: integer
        measuredPoints:
          type: integer
          description: Pins that carry a result
        rows:
          type: array
          items:
            $ref: '#/components/schemas/CompetitorPerformanceRow'
    CompetitorPerformance:
      type: object
      properties:
        latest:
          $ref: '#/components/schemas/CompetitorPerformanceSection'
          description: Only the scans named by the scanId query. Empty, with scanCount 0, when none is sent. positionChange compares each scan with the scan before it.
        allTime:
          $ref: '#/components/schemas/CompetitorPerformanceSection'
          description: All scans in the plan history window. positionChange compares with the earlier scans in the window.
        historyDays:
          type:
            - integer
            - 'null'
          description: Days of scan history the plan keeps. Null when the plan keeps all.
    CompetitorPerformanceEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/CompetitorPerformance'
    CompetitorPositionPoint:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        avgPosition:
          $ref: '#/components/schemas/CompetitorPosition'
    CompetitorLocal3PackPoint:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        presence:
          $ref: '#/components/schemas/CompetitorPosition'
    CompetitorPositionHistoryEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: array
          items:
            $ref: '#/components/schemas/CompetitorPositionPoint'
          description: Average rank over time, one point per interval
    CompetitorLocal3PackHistoryEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: array
          items:
            $ref: '#/components/schemas/CompetitorLocal3PackPoint'
          description: Local 3-Pack presence over time, one point per interval
    AiScanConfig:
      type: object
      properties:
        radius:
          type: number
          example: 3
        radiusUnit:
          type: string
          enum:
            - km
            - mi
          example: mi
    AiPlatformMetrics:
      type: object
      properties:
        aiSov:
          type: number
          description: 'AI share of voice: pins that name the business out of pins that got an AI answer, in percent'
          example: 55.6
        avgPosition:
          type:
            - number
            - 'null'
          description: Pin-weighted position of the first mention. Null when never named.
          example: 2.4
        mentionedPinCount:
          type: integer
          example: 5
        answeredPinCount:
          type: integer
          description: Pins that got an AI answer
          example: 9
        noAnswerPinCount:
          type: integer
          description: Pins where the engine gave no AI answer at all
          example: 0
    AiScanPlatform:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/AiPlatform'
        status:
          type: string
          enum:
            - pending
            - scanning
            - completed
            - failed
        rejectedPinCount:
          type: integer
        metrics:
          $ref: '#/components/schemas/AiPlatformMetrics'
    AiScanSummary:
      type: object
      properties:
        id:
          type: string
          example: '65c3d5e7f9a1b2c3d4e5f607'
        query:
          type: string
          description: The question that the scan asked the AI engines
          example: best bakery in Austin
        status:
          type: string
          enum:
            - pending
            - scanning
            - completed
            - partial
            - failed
          example: completed
        scanConfig:
          $ref: '#/components/schemas/AiScanConfig'
        zoneCount:
          type: integer
          description: Distinct localities the grid resolved to
          example: 4
        pinCount:
          type: integer
          example: 9
        customPins:
          type: array
          items:
            $ref: '#/components/schemas/Coordinate'
        source:
          type:
            - string
            - 'null'
          enum:
            - monitor
            - null
          description: monitor for scheduled runs, null for runs started by a person
        platforms:
          type: array
          items:
            $ref: '#/components/schemas/AiScanPlatform'
        createdAt:
          type: string
          format: date-time
          example: '2026-10-03T07:00:03.000Z'
        updatedAt:
          type: string
          format: date-time
          example: '2026-10-03T07:06:41.000Z'
    AiScanPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/AiScanSummary'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    AiScanPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanPage'
    AiScan:
      allOf:
        - $ref: '#/components/schemas/AiScanSummary'
        - type: object
          properties:
            center:
              $ref: '#/components/schemas/Coordinate'
    AiScanEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScan'
    BusinessMention:
      type: object
      properties:
        name:
          type: string
        position:
          type: integer
          description: Order of the first mention in the answer, 1-based
        isTarget:
          type: boolean
          description: True for the profile business
        domain:
          type: string
          description: Site of the business. Absent on answers stored before 2026-08-27.
    AiCitation:
      type: object
      properties:
        url:
          type: string
        domain:
          type: string
        title:
          type: string
        owner:
          type: string
          enum:
            - yours
            - competitor
            - directory
            - editorial
            - ugc
    BrandPhrase:
      type: object
      properties:
        phrase:
          type: string
        sentiment:
          $ref: '#/components/schemas/Sentiment'
    AiScanZoneAnswer:
      type: object
      properties:
        pinCount:
          type: integer
        targetPosition:
          type:
            - integer
            - 'null'
          description: Position of the first mention of the profile business. Null when not named.
        businesses:
          type: array
          items:
            $ref: '#/components/schemas/BusinessMention'
        citations:
          type: array
          items:
            $ref: '#/components/schemas/AiCitation'
        phrases:
          type: array
          items:
            $ref: '#/components/schemas/BrandPhrase'
          description: At most five, about the profile business only
        sentiment:
          oneOf:
            - $ref: '#/components/schemas/Sentiment'
            - type: 'null'
          description: Null means not measured, not neutral
        noAiAnswer:
          type: boolean
          description: True when the engine gave no AI answer, as opposed to an answer that names nobody
    AiScanZone:
      type: object
      properties:
        slot:
          type: integer
          description: Lowest pin slot in the zone
        locality:
          type: string
        slots:
          type: array
          items:
            type: integer
        pinCount:
          type: integer
        markerSlot:
          type: integer
          description: Slot where the app draws the zone marker. Not the answer slot; use slots[0] for the answer route.
        status:
          type: string
          enum:
            - answered
            - no-answer
            - rejected
            - pending
        answer:
          oneOf:
            - $ref: '#/components/schemas/AiScanZoneAnswer'
            - type: 'null'
          description: Set when status is answered or no-answer
    AiScanZoneCoverage:
      type: object
      properties:
        zoneCount:
          type: integer
        answeredZoneCount:
          type: integer
        noAnswerZoneCount:
          type: integer
        rejectedPinCount:
          type: integer
        pendingPinCount:
          type: integer
        mentionedZoneCount:
          type: integer
        citedPinCount:
          type: integer
        citedZoneCount:
          type: integer
        sentimentPinCount:
          $ref: '#/components/schemas/SentimentPinCount'
        sentimentUnmeasuredPinCount:
          type: integer
    AiScanZonePin:
      type: object
      properties:
        lat:
          type: number
        lng:
          type: number
        slot:
          type: integer
    AiScanBusinessRollup:
      type: object
      properties:
        name:
          type: string
        variants:
          type: array
          items:
            type: string
        isTarget:
          type: boolean
        domain:
          type: string
          description: Site of the business. Empty when none was named.
        mentionedPinCount:
          type: integer
        mentionedZoneCount:
          type: integer
        avgPosition:
          type: number
        zoneSlots:
          type: array
          items:
            type: integer
    AiScanSourceRollup:
      type: object
      properties:
        domain:
          type: string
        owner:
          type: string
          enum:
            - yours
            - competitor
            - directory
            - editorial
            - ugc
        ownerMixed:
          type: boolean
        url:
          type: string
        title:
          type: string
        citedPinCount:
          type: integer
        citedZoneCount:
          type: integer
        zoneSlots:
          type: array
          items:
            type: integer
    AiScanPhraseRollup:
      type: object
      properties:
        phrase:
          type: string
        sentiment:
          $ref: '#/components/schemas/Sentiment'
        pinCount:
          type: integer
        zoneCount:
          type: integer
        zoneSlots:
          type: array
          items:
            type: integer
    AiScanZones:
      type: object
      properties:
        scanId:
          type: string
        query:
          type: string
        center:
          $ref: '#/components/schemas/Coordinate'
        scanConfig:
          $ref: '#/components/schemas/AiScanConfig'
        target:
          type: object
          properties:
            name:
              type: string
            domain:
              type: string
        createdAt:
          type: string
          format: date-time
        platform:
          $ref: '#/components/schemas/AiPlatform'
        metrics:
          $ref: '#/components/schemas/AiPlatformMetrics'
        coverage:
          $ref: '#/components/schemas/AiScanZoneCoverage'
        pins:
          type: array
          items:
            $ref: '#/components/schemas/AiScanZonePin'
        zones:
          type: array
          items:
            $ref: '#/components/schemas/AiScanZone'
          description: Most pins first
        businesses:
          type: array
          items:
            $ref: '#/components/schemas/AiScanBusinessRollup'
        sources:
          type: array
          items:
            $ref: '#/components/schemas/AiScanSourceRollup'
        phrases:
          type: array
          items:
            $ref: '#/components/schemas/AiScanPhraseRollup'
        businessTotalCount:
          type: integer
          description: Distinct businesses before the row limit on businesses
    AiScanZonesEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanZones'
    AiScanReport:
      type: object
      properties:
        scan:
          $ref: '#/components/schemas/AiScan'
        platforms:
          type: array
          items:
            $ref: '#/components/schemas/AiScanZones'
          description: One entry per platform of the scan
    AiScanReportEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanReport'
    AiScanZoneAnswerText:
      type: object
      properties:
        platform:
          $ref: '#/components/schemas/AiPlatform'
        slot:
          type: integer
        rawMarkdown:
          type: string
          description: The AI answer as stored, cut at 4,000 characters. Empty when the engine gave no AI answer.
        rawMarkdownTruncated:
          type: boolean
    AiScanZoneAnswerTextEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanZoneAnswerText'
    AiScanAnalysis:
      type: object
      properties:
        gapAnalysis:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              description:
                type: string
              impact:
                type: string
        competitiveStrengths:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              description:
                type: string
        actionItems:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              description:
                type: string
        dateAdded:
          type: string
          format: date-time
    AiScanAnalysisEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          oneOf:
            - $ref: '#/components/schemas/AiScanAnalysis'
            - type: 'null'
          description: The stored analysis, or null when none is stored yet
    AiScanQueryHistoryPin:
      type: object
      properties:
        date:
          type: string
        platform:
          $ref: '#/components/schemas/AiPlatform'
        aiSov:
          type: number
        mentionedPinCount:
          type: integer
        answeredPinCount:
          type: integer
        avgPosition:
          type:
            - number
            - 'null'
          description: Null when never named that day
    AiScanQueryHistory:
      type: object
      properties:
        query:
          type: string
        pins:
          type: array
          items:
            $ref: '#/components/schemas/AiScanQueryHistoryPin'
    AiScanQueryHistoryEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanQueryHistory'
    AiScanPlatformPinCounts:
      type: object
      properties:
        platform:
          $ref: '#/components/schemas/AiPlatform'
        mentionedPinCount:
          type: integer
        answeredPinCount:
          type: integer
    AiScanTrackedQuery:
      type: object
      properties:
        id:
          type: string
        query:
          type: string
        topicId:
          type:
            - string
            - 'null'
        monitorActive:
          type: boolean
        monitorPlatforms:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/AiPlatform'
        monitorSchedule:
          oneOf:
            - type: object
              properties:
                frequency:
                  $ref: '#/components/schemas/MonitorFrequency'
                runTime:
                  type: string
                timezone:
                  type: string
                dayOfWeek:
                  type: array
                  items:
                    type: string
                    enum:
                      - Mon
                      - Tue
                      - Wed
                      - Thu
                      - Fri
                      - Sat
                      - Sun
                dayOfMonth:
                  type: array
                  items:
                    oneOf:
                      - type: integer
                      - const: last
            - type: 'null'
        monitorNextRunAt:
          type:
            - string
            - 'null'
          format: date-time
        scanCount:
          type: integer
        pinCount:
          type: integer
        radius:
          type: number
        radiusUnit:
          type: string
        platforms:
          type: array
          items:
            $ref: '#/components/schemas/AiPlatform'
        mentionedPinCount:
          type: integer
        answeredPinCount:
          type: integer
        lastScannedAt:
          type:
            - string
            - 'null'
          format: date-time
        byPlatform:
          type: array
          items:
            $ref: '#/components/schemas/AiScanPlatformPinCounts'
        sentimentPinCount:
          $ref: '#/components/schemas/SentimentPinCount'
    AiScanTopic:
      type: object
      properties:
        id:
          type: string
          description: Empty string is the bucket of queries with no topic
        name:
          type: string
        queryCount:
          type: integer
        monitoredQueryCount:
          type: integer
        scanCount:
          type: integer
        mentionedPinCount:
          type: integer
        answeredPinCount:
          type: integer
        lastScannedAt:
          type:
            - string
            - 'null'
          format: date-time
        byPlatform:
          type: array
          items:
            $ref: '#/components/schemas/AiScanPlatformPinCounts'
    AiScanQueryInsightsPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/AiScanTrackedQuery'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
        topics:
          type: array
          items:
            $ref: '#/components/schemas/AiScanTopic'
          description: Totals cover the whole topic, not the page
        summary:
          type: object
          properties:
            scannedQueryCount:
              type: integer
            monitoredQueryCount:
              type: integer
          description: Counts the whole profile, ignoring the filters
    AiScanQueryInsightsPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanQueryInsightsPage'
    AiScanInsightRow:
      type: object
      properties:
        name:
          type: string
        pinCount:
          type: integer
    AiScanPlatformInsight:
      type: object
      properties:
        platform:
          $ref: '#/components/schemas/AiPlatform'
        scanCount:
          type: integer
        mentionedPinCount:
          type: integer
        answeredPinCount:
          type: integer
          description: The denominator for every share on this row
        noAnswerPinCount:
          type: integer
        citedPinCount:
          type: integer
        avgPosition:
          type:
            - number
            - 'null'
          description: Pin-weighted over the window. Null when never named.
        sentimentPinCount:
          $ref: '#/components/schemas/SentimentPinCount'
        sentimentUnmeasuredPinCount:
          type: integer
        lastScannedAt:
          type:
            - string
            - 'null'
          format: date-time
        topCompetitors:
          type: array
          items:
            $ref: '#/components/schemas/AiScanInsightRow'
        topSources:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/AiScanInsightRow'
              - type: object
                properties:
                  owner:
                    type: string
                    enum:
                      - yours
                      - competitor
                      - directory
                      - editorial
                      - ugc
    AiScanPlatformInsights:
      type: object
      properties:
        windowDays:
          type: integer
        platforms:
          type: array
          items:
            $ref: '#/components/schemas/AiScanPlatformInsight'
    AiScanPlatformInsightsEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanPlatformInsights'
    AiScanCompetitor:
      type: object
      properties:
        name:
          type: string
        isTarget:
          type: boolean
        mentionedPinCount:
          type: integer
        avgPosition:
          type:
            - number
            - 'null'
        platforms:
          type: array
          items:
            $ref: '#/components/schemas/AiPlatform'
        previousMentionedPinCount:
          type: integer
          description: Same count in the window before
        previousAvgPosition:
          type:
            - number
            - 'null'
          description: Same average in the window before. Null when not named then.
    AiScanCompetitorInsights:
      type: object
      properties:
        windowDays:
          type: integer
        answeredPinCount:
          type: integer
        previousAnsweredPinCount:
          type: integer
          description: 0 means the window before held no scans, not a zero share
        competitors:
          type: array
          items:
            $ref: '#/components/schemas/AiScanCompetitor'
    AiScanCompetitorInsightsEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanCompetitorInsights'
    AiScanRankHistory:
      type: object
      properties:
        queries:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              query:
                type: string
              monitorActive:
                type: boolean
              pinCount:
                type: integer
              radius:
                type: number
              radiusUnit:
                type: string
        rows:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
              cells:
                type: array
                items:
                  type: object
                  properties:
                    queryId:
                      type: string
                    aiSov:
                      type: number
                    mentionedPinCount:
                      type: integer
                    answeredPinCount:
                      type: integer
          description: One row per day with scans. Days with no scan are left out.
    AiScanRankHistoryEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AiScanRankHistory'
    CitationStatus:
      type: string
      enum:
        - todo
        - processing
        - active
        - lost
        - ignored
        - not_found
    Citation:
      type: object
      properties:
        id:
          type: string
        directory:
          type: string
        directoryWebsite:
          type:
            - string
            - 'null'
        link:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/CitationStatus'
        lastChecked:
          type:
            - string
            - 'null'
          format: date-time
        lastUpdated:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        nap:
          oneOf:
            - type: object
              properties:
                checkedAt:
                  type: string
                  format: date-time
                readable:
                  type: boolean
                  description: False when the listing page could not be read. found and matches mean nothing then.
                found:
                  oneOf:
                    - type: object
                      properties:
                        name:
                          type:
                            - string
                            - 'null'
                        address:
                          type:
                            - string
                            - 'null'
                        phone:
                          type:
                            - string
                            - 'null'
                    - type: 'null'
                matches:
                  type: object
                  properties:
                    name:
                      type: boolean
                    address:
                      type: boolean
                    phone:
                      type: boolean
                consistent:
                  type: boolean
                  description: True when name, address and phone all match the business profile
            - type: 'null'
          description: Name, address and phone found on the listing
    CitationPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Citation'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
        statusCounts:
          type: object
          additionalProperties:
            type: integer
          description: Citations per status over the whole profile, ignoring the filters
    CitationPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/CitationPage'
    CitationDirectory:
      type: object
      properties:
        name:
          type: string
        website:
          type: string
        tags:
          type: array
          items:
            type: string
        type:
          type: string
        domainAuthority:
          type:
            - number
            - 'null'
        countries:
          type: array
          items:
            type: string
    CitationDirectoryListEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: array
          items:
            $ref: '#/components/schemas/CitationDirectory'
          description: Directories available to the profile
    DistributionStatus:
      type: string
      enum:
        - draft
        - processing
        - approved
        - rejected
        - archived
    Distribution:
      type: object
      properties:
        id:
          type: string
        status:
          $ref: '#/components/schemas/DistributionStatus'
        headline:
          type:
            - string
            - 'null'
        summary:
          type:
            - string
            - 'null'
        body:
          type:
            - string
            - 'null'
        cityCountry:
          type:
            - string
            - 'null'
        companyBoilerplate:
          type:
            - string
            - 'null'
        publishAsap:
          type:
            - boolean
            - 'null'
        publishDate:
          type:
            - string
            - 'null'
          description: As entered by the user, in the timezone named by publishTimezone
        publishTimezone:
          type:
            - string
            - 'null'
        contact:
          oneOf:
            - type: object
              properties:
                organization:
                  type: string
                websiteUrl:
                  type: string
                name:
                  type: string
                email:
                  type: string
                phone:
                  type: string
                address:
                  type: string
            - type: 'null'
        createdAt:
          type: string
          format: date-time
        lastUpdated:
          type: string
          format: date-time
    DistributionPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Distribution'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    DistributionPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/DistributionPage'
    DistributionEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/Distribution'
    DistributionReport:
      type: object
      properties:
        distributionId:
          type: string
        title:
          type: string
        excerpt:
          type: string
        body:
          type: string
        submittedAt:
          type: string
        googlePickup:
          type: string
        currentPickup:
          type: integer
        potentialAudienceReach:
          type: integer
        syndication:
          type: array
          items:
            type: object
            properties:
              endpoint:
                type: string
              type:
                type: string
              industry:
                type: string
              top3Countries:
                type: string
              potentialAudience:
                type: string
              audienceUnit:
                type: string
              url:
                type: string
        transmission:
          type: array
          items:
            type: object
            properties:
              destination:
                type: string
              status:
                type: string
    DistributionReportEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/DistributionReport'
    ReviewReply:
      type: object
      properties:
        comment:
          type: string
          example: Thank you, Alex. We are glad you like the sourdough.
        updatedAt:
          type:
            - string
            - 'null'
          example: '2026-10-02T08:15:44.000Z'
    Review:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          example: AbFvOqmSampleReview0001
        reviewerName:
          type:
            - string
            - 'null'
          example: Alex R.
        isAnonymous:
          type: boolean
          example: false
        rating:
          type:
            - integer
            - 'null'
          description: Stars, 1 to 5
          example: 5
        comment:
          type:
            - string
            - 'null'
          example: Best sourdough in South Austin. The line moves fast and the staff remember your order.
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
          example: '2026-10-01T14:32:10.000Z'
        updatedAt:
          type:
            - string
            - 'null'
          format: date-time
          example: '2026-10-01T14:32:10.000Z'
        reply:
          oneOf:
            - $ref: '#/components/schemas/ReviewReply'
            - type: 'null'
          example: { comment: 'Thank you, Alex. We are glad you like the sourdough.', updatedAt: '2026-10-02T08:15:44.000Z' }
    ReviewList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Review'
          example:
            - id: AbFvOqmSampleReview0001
              reviewerName: Alex R.
              isAnonymous: false
              rating: 5
              comment: Best sourdough in South Austin. The line moves fast and the staff remember your order.
              createdAt: '2026-10-01T14:32:10.000Z'
              updatedAt: '2026-10-01T14:32:10.000Z'
              reply:
                comment: Thank you, Alex. We are glad you like the sourdough.
                updatedAt: '2026-10-02T08:15:44.000Z'
            - id: AbFvOqmSampleReview0002
              reviewerName: Jordan P.
              isAnonymous: false
              rating: 4
              comment: null
              createdAt: '2026-09-28T09:05:51.000Z'
              updatedAt: '2026-09-28T09:05:51.000Z'
              reply: null
        nextPageToken:
          type:
            - string
            - 'null'
          description: Send as pageToken for the next page. Null on the last page.
          example: CgwI0Zz0yAYQsample
        averageRating:
          type:
            - number
            - 'null'
          example: 4.7
        totalReviewCount:
          type:
            - integer
            - 'null'
          example: 312
    ReviewListEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ReviewList'
    ReviewGrowth:
      type: object
      properties:
        profileId:
          type: string
          example: '65a1f3c2e4b0a1d2c3e4f5a1'
        months:
          type: array
          example:
            - { month: '2026-08', totalReviews: 281 }
            - { month: '2026-09', totalReviews: 298 }
            - { month: '2026-10', totalReviews: 312 }
          items:
            type: object
            properties:
              month:
                type: string
                description: YYYY-MM
              totalReviews:
                type: integer
    ReviewGrowthEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ReviewGrowth'
    ReviewAnalysis:
      type: object
      properties:
        generatedAt:
          type: string
          format: date-time
        sentiment:
          type: object
          properties:
            positive:
              type: number
            neutral:
              type: number
            negative:
              type: number
        topics:
          type: array
          items:
            type: object
            properties:
              topic:
                type: string
              quotes:
                type: array
                items:
                  type: string
        customerSegments:
          type: array
          items:
            type: object
            properties:
              segmentName:
                type: string
              percentage:
                type: number
              characteristics:
                type: string
        painPoints:
          type: array
          items:
            type: string
        strengths:
          type: array
          items:
            type: string
        aspects:
          type: object
          properties:
            quality:
              type: number
            service:
              type: number
            value:
              type: number
            experience:
              type: number
            trust:
              type: number
    ReviewAnalysisEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          oneOf:
            - $ref: '#/components/schemas/ReviewAnalysis'
            - type: 'null'
          description: The stored analysis, or null when none is stored yet
    ReviewStreamEntry:
      type: object
      properties:
        id:
          type: string
        profileId:
          type: string
        profileName:
          type: string
        profileAddress:
          type: string
        averageRating:
          type: number
        totalReviewCount:
          type: integer
        events:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              reviewCreatedAt:
                type: string
                format: date-time
              detectedAt:
                type: string
                format: date-time
        createdAt:
          type: string
          format: date-time
    ReviewStreamPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ReviewStreamEntry'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    ReviewStreamPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ReviewStreamPage'
    AuditChange:
      type: object
      properties:
        previous:
          type:
            - number
            - 'null'
        current:
          type:
            - number
            - 'null'
    Audit:
      type: object
      properties:
        profileId:
          type: string
        createdAt:
          type: string
          format: date-time
        nextAuditAt:
          type:
            - string
            - 'null'
          format: date-time
          description: Null when the plan keeps only the first audit
        previousAuditAt:
          type:
            - string
            - 'null'
          format: date-time
        score:
          $ref: '#/components/schemas/AuditChange'
        stats:
          type: object
          properties:
            rating:
              $ref: '#/components/schemas/AuditChange'
            reviews:
              $ref: '#/components/schemas/AuditChange'
            photos:
              $ref: '#/components/schemas/AuditChange'
            posts:
              $ref: '#/components/schemas/AuditChange'
            position:
              $ref: '#/components/schemas/AuditChange'
        summary:
          type:
            - string
            - 'null'
        insights:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              description:
                type: string
              severity:
                type: string
        checks:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              status:
                type: string
                enum:
                  - pass
                  - fail
              facts:
                type: object
                properties:
                  count:
                    type: integer
                  added:
                    type: integer
                  total:
                    type: integer
                  percent:
                    type: integer
                    description: 0 to 100
                  missing:
                    type: array
                    items:
                      type: string
                      enum:
                        - name
                        - address
                        - phone
                        - description
                        - website
                        - logo
                        - cover
                  lost:
                    type: integer
                  todo:
                    type: integer
                description: The numbers behind the verdict. Each check sets only its own fields.
        actions:
          type: array
          items:
            type: object
            properties:
              action:
                type: string
              description:
                type: string
              reason:
                type:
                  - string
                  - 'null'
              dismissed:
                type: boolean
        reminders:
          type: array
          items:
            type: string
    AuditEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          oneOf:
            - $ref: '#/components/schemas/Audit'
            - type: 'null'
          description: The stored audit, or null when none is stored yet
    PostDate:
      type: object
      properties:
        year:
          type:
            - integer
            - 'null'
        month:
          type:
            - integer
            - 'null'
        day:
          type:
            - integer
            - 'null'
    PostTime:
      type: object
      properties:
        hours:
          type:
            - integer
            - 'null'
        minutes:
          type:
            - integer
            - 'null'
    PostContent:
      type: object
      properties:
        summary:
          type:
            - string
            - 'null'
        languageCode:
          type:
            - string
            - 'null'
        topicType:
          type:
            - string
            - 'null'
          enum:
            - LOCAL_POST_TOPIC_TYPE_UNSPECIFIED
            - STANDARD
            - EVENT
            - OFFER
            - ALERT
            - null
        alertType:
          type:
            - string
            - 'null'
          enum:
            - ALERT_TYPE_UNSPECIFIED
            - COVID_19
            - null
        callToAction:
          oneOf:
            - type: object
              properties:
                actionType:
                  type:
                    - string
                    - 'null'
                  enum:
                    - ACTION_TYPE_UNSPECIFIED
                    - BOOK
                    - ORDER
                    - SHOP
                    - LEARN_MORE
                    - SIGN_UP
                    - CALL
                    - null
                url:
                  type:
                    - string
                    - 'null'
            - type: 'null'
        event:
          oneOf:
            - type: object
              properties:
                title:
                  type:
                    - string
                    - 'null'
                startDate:
                  oneOf:
                    - $ref: '#/components/schemas/PostDate'
                    - type: 'null'
                startTime:
                  oneOf:
                    - $ref: '#/components/schemas/PostTime'
                    - type: 'null'
                endDate:
                  oneOf:
                    - $ref: '#/components/schemas/PostDate'
                    - type: 'null'
                endTime:
                  oneOf:
                    - $ref: '#/components/schemas/PostTime'
                    - type: 'null'
            - type: 'null'
        offer:
          oneOf:
            - type: object
              properties:
                couponCode:
                  type:
                    - string
                    - 'null'
                redeemOnlineUrl:
                  type:
                    - string
                    - 'null'
                termsConditions:
                  type:
                    - string
                    - 'null'
            - type: 'null'
    Post:
      allOf:
        - $ref: '#/components/schemas/PostContent'
        - type: object
          properties:
            id:
              type:
                - string
                - 'null'
            state:
              type:
                - string
                - 'null'
              enum:
                - LOCAL_POST_STATE_UNSPECIFIED
                - REJECTED
                - LIVE
                - PROCESSING
                - SCHEDULED
                - RECURRING
                - null
            media:
              type: array
              items:
                type: object
                properties:
                  format:
                    type:
                      - string
                      - 'null'
                    enum:
                      - PHOTO
                      - VIDEO
                      - MEDIA_FORMAT_UNSPECIFIED
                      - null
                  url:
                    type:
                      - string
                      - 'null'
            searchUrl:
              type:
                - string
                - 'null'
            createTime:
              type:
                - string
                - 'null'
              format: date-time
            updateTime:
              type:
                - string
                - 'null'
              format: date-time
    PostPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Post'
        nextPageToken:
          type:
            - string
            - 'null'
          description: Send as pageToken for the next page. Null on the last page.
    PostPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/PostPage'
    ScheduledPost:
      allOf:
        - $ref: '#/components/schemas/PostContent'
        - type: object
          properties:
            id:
              type: string
            status:
              type: string
              enum:
                - draft
                - scheduled
                - published
                - failed
            scheduledDatetime:
              type:
                - string
                - 'null'
              format: date-time
            timezone:
              type:
                - string
                - 'null'
            publishedAt:
              type:
                - string
                - 'null'
              format: date-time
            lastUpdated:
              type:
                - string
                - 'null'
              format: date-time
            automationId:
              type:
                - string
                - 'null'
            mediaCount:
              type: integer
            errorCode:
              type:
                - string
                - 'null'
            failedAt:
              type:
                - string
                - 'null'
              format: date-time
    ScheduledPostList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ScheduledPost'
    ScheduledPostListEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ScheduledPostList'
    PostAutomation:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        contentType:
          type: string
          enum:
            - tips
            - updates
        topicType:
          type: string
          enum:
            - LOCAL_POST_TOPIC_TYPE_UNSPECIFIED
            - STANDARD
            - EVENT
            - OFFER
            - ALERT
        tone:
          type:
            - string
            - 'null'
        length:
          type:
            - string
            - 'null'
          enum:
            - short
            - medium
            - long
            - null
        prompt:
          type:
            - string
            - 'null'
          description: The instruction the profile owner wrote in the app
        frequency:
          oneOf:
            - type: object
              properties:
                value:
                  type: integer
                unit:
                  type: string
                  enum:
                    - day
                    - week
                    - month
                publishTime:
                  type: string
                  description: Time of day, HH:mm
                timezone:
                  type: string
            - type: 'null'
        isActive:
          type: boolean
        autoPublish:
          type: boolean
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
        updatedAt:
          type:
            - string
            - 'null'
          format: date-time
        lastCreated:
          type:
            - string
            - 'null'
          format: date-time
    PostAutomationList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/PostAutomation'
    PostAutomationListEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/PostAutomationList'
    MediaFormat:
      type:
        - string
        - 'null'
      enum:
        - PHOTO
        - VIDEO
        - MEDIA_FORMAT_UNSPECIFIED
        - null
    MediaCategory:
      type:
        - string
        - 'null'
      enum:
        - CATEGORY_UNSPECIFIED
        - COVER
        - PROFILE
        - LOGO
        - EXTERIOR
        - INTERIOR
        - PRODUCT
        - AT_WORK
        - FOOD_AND_DRINK
        - MENU
        - COMMON_AREA
        - ROOMS
        - TEAMS
        - ADDITIONAL
        - null
    MediaItem:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
        format:
          $ref: '#/components/schemas/MediaFormat'
        category:
          $ref: '#/components/schemas/MediaCategory'
        googleUrl:
          type:
            - string
            - 'null'
        thumbnailUrl:
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        width:
          type:
            - integer
            - 'null'
        height:
          type:
            - integer
            - 'null'
        viewCount:
          type:
            - integer
            - 'null'
        createTime:
          type:
            - string
            - 'null'
          format: date-time
    MediaPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/MediaItem'
        nextPageToken:
          type:
            - string
            - 'null'
          description: Send as pageToken for the next page. Null on the last page.
        total:
          type: integer
          description: All media items of the profile on Google
    MediaPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/MediaPage'
    ScheduledMedia:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          enum:
            - scheduled
            - failed
        format:
          $ref: '#/components/schemas/MediaFormat'
        category:
          $ref: '#/components/schemas/MediaCategory'
        description:
          type:
            - string
            - 'null'
        publishAt:
          type:
            - string
            - 'null'
          format: date-time
        timezone:
          type:
            - string
            - 'null'
        errorCode:
          type:
            - string
            - 'null'
        failedAt:
          type:
            - string
            - 'null'
          format: date-time
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
    ScheduledMediaPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ScheduledMedia'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    PostDateInput:
      type: object
      additionalProperties: false
      required: [year, month, day]
      properties:
        year: { type: integer, minimum: 2000, maximum: 2100 }
        month: { type: integer, minimum: 1, maximum: 12 }
        day: { type: integer, minimum: 1, maximum: 31 }
    PostTimeInput:
      type: object
      additionalProperties: false
      required: [hours, minutes]
      properties:
        hours: { type: integer, minimum: 0, maximum: 23 }
        minutes: { type: integer, minimum: 0, maximum: 59 }
    PostEventInput:
      type: object
      additionalProperties: false
      required: [title, schedule]
      properties:
        title: { type: string, minLength: 1, maxLength: 58 }
        schedule:
          type: object
          additionalProperties: false
          required: [startDate, endDate]
          properties:
            startDate: { $ref: '#/components/schemas/PostDateInput' }
            startTime: { $ref: '#/components/schemas/PostTimeInput' }
            endDate: { $ref: '#/components/schemas/PostDateInput' }
            endTime: { $ref: '#/components/schemas/PostTimeInput' }
    PostCallToActionInput:
      type: object
      additionalProperties: false
      required: [actionType]
      properties:
        actionType:
          type: string
          enum: [BOOK, ORDER, SHOP, LEARN_MORE, SIGN_UP, CALL]
        url:
          type: string
          format: uri
          description: Needed for every actionType except CALL.
    PostOfferInput:
      type: object
      additionalProperties: false
      properties:
        couponCode: { type: string }
        redeemOnlineUrl: { type: string, format: uri }
        termsConditions: { type: string }
    PostRequest:
      type: object
      additionalProperties: false
      required: [summary]
      properties:
        summary: { type: string, minLength: 1, maxLength: 1500 }
        topicType:
          type: string
          enum: [STANDARD, EVENT, OFFER]
          default: STANDARD
        languageCode: { type: string, example: en }
        callToAction: { $ref: '#/components/schemas/PostCallToActionInput' }
        event: { $ref: '#/components/schemas/PostEventInput' }
        offer: { $ref: '#/components/schemas/PostOfferInput' }
    UpdatePostRequest:
      type: object
      additionalProperties: false
      properties:
        summary: { type: string, minLength: 1, maxLength: 1500 }
        callToAction: { $ref: '#/components/schemas/PostCallToActionInput' }
        event: { $ref: '#/components/schemas/PostEventInput' }
        offer: { $ref: '#/components/schemas/PostOfferInput' }
    SchedulePostRequest:
      allOf:
        - $ref: '#/components/schemas/PostRequest'
        - type: object
          required: [publishAt]
          properties:
            publishAt: { type: string, format: date-time, description: 'With an offset, e.g. 2026-12-01T09:00:00+08:00.' }
            timezone: { type: string, default: UTC, description: 'IANA time zone the app shows the time in.' }
    UpdateScheduledPostRequest:
      allOf:
        - $ref: '#/components/schemas/UpdatePostRequest'
        - type: object
          properties:
            publishAt: { type: string, format: date-time }
            timezone: { type: string }
    PostMultipartRequest:
      type: object
      required: [post]
      properties:
        post: { type: string, description: 'A PostRequest as JSON text.' }
        file: { type: string, format: binary, description: 'Optional photo: JPEG or PNG up to 5 MB.' }
    UpdatePostMultipartRequest:
      type: object
      properties:
        post: { type: string, description: 'An UpdatePostRequest as JSON text.' }
        file: { type: string, format: binary, description: 'A new photo: JPEG or PNG up to 5 MB.' }
    SchedulePostMultipartRequest:
      type: object
      required: [post]
      properties:
        post: { type: string, description: 'A SchedulePostRequest as JSON text.' }
        file: { type: string, format: binary, description: 'Optional photo: JPEG or PNG up to 5 MB.' }
    UpdateScheduledPostMultipartRequest:
      type: object
      properties:
        post: { type: string, description: 'An UpdateScheduledPostRequest as JSON text.' }
        file: { type: string, format: binary, description: 'A new photo: JPEG or PNG up to 5 MB.' }
    PostEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/Post' }
    ScheduledPostEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/ScheduledPost' }
    ReviewReplyRequest:
      type: object
      additionalProperties: false
      required: [comment]
      properties:
        comment: { type: string, minLength: 1, maxLength: 4096 }
    ReviewReplyEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/ReviewReply' }
    PublishMediaRequest:
      type: object
      additionalProperties: false
      required: [file, category]
      properties:
        file:
          type: string
          format: binary
          description: One JPEG or PNG photo up to 5 MB, or one MP4 video up to 20 MB.
        category: { $ref: '#/components/schemas/WritableMediaCategory' }
    MediaItemEnvelope:
      type: object
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/MediaItem' }
    WritableMediaCategory:
      type: string
      description: Google photo category. COVER and PROFILE replace the profile's cover and profile photo.
      enum:
        - COVER
        - PROFILE
        - LOGO
        - EXTERIOR
        - INTERIOR
        - PRODUCT
        - AT_WORK
        - FOOD_AND_DRINK
        - MENU
        - COMMON_AREA
        - ROOMS
        - TEAMS
        - ADDITIONAL
    ScheduleMediaRequest:
      type: object
      additionalProperties: false
      required: [file, publishAt, category]
      properties:
        file:
          type: string
          format: binary
          description: One JPEG or PNG photo up to 5 MB, or one MP4 video up to 20 MB.
        publishAt:
          type: string
          format: date-time
          description: When to publish, with an offset, e.g. 2026-12-01T09:00:00+08:00.
        timezone:
          type: string
          description: IANA time zone the app shows the time in, e.g. Asia/Kuala_Lumpur.
        category:
          $ref: '#/components/schemas/WritableMediaCategory'
    UpdateScheduledMediaRequest:
      type: object
      additionalProperties: false
      minProperties: 1
      properties:
        publishAt:
          type: string
          format: date-time
        timezone:
          type: string
        category:
          $ref: '#/components/schemas/WritableMediaCategory'
    ReplaceScheduledMediaRequest:
      type: object
      additionalProperties: false
      required: [file]
      properties:
        file:
          type: string
          format: binary
          description: The new file. Same rules as when scheduling.
        publishAt:
          type: string
          format: date-time
        timezone:
          type: string
        category:
          $ref: '#/components/schemas/WritableMediaCategory'
    ScheduledMediaEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ScheduledMedia'
    DeletedEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            deleted:
              type: boolean
              const: true
    ScheduledMediaPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/ScheduledMediaPage'
    InfoDate:
      type: object
      properties:
        year:
          type:
            - integer
            - 'null'
        month:
          type:
            - integer
            - 'null'
        day:
          type:
            - integer
            - 'null'
    InfoTime:
      type: object
      properties:
        hours:
          type: integer
          description: 0 to 24
        minutes:
          type: integer
    InfoCategory:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
    HoursPeriod:
      type: object
      properties:
        openDay:
          type:
            - string
            - 'null'
          enum:
            - DAY_OF_WEEK_UNSPECIFIED
            - MONDAY
            - TUESDAY
            - WEDNESDAY
            - THURSDAY
            - FRIDAY
            - SATURDAY
            - SUNDAY
            - null
        openTime:
          oneOf:
            - $ref: '#/components/schemas/InfoTime'
            - type: 'null'
        closeDay:
          type:
            - string
            - 'null'
          enum:
            - DAY_OF_WEEK_UNSPECIFIED
            - MONDAY
            - TUESDAY
            - WEDNESDAY
            - THURSDAY
            - FRIDAY
            - SATURDAY
            - SUNDAY
            - null
        closeTime:
          oneOf:
            - $ref: '#/components/schemas/InfoTime'
            - type: 'null'
    BusinessInformation:
      type: object
      properties:
        title:
          type:
            - string
            - 'null'
        storeCode:
          type:
            - string
            - 'null'
        languageCode:
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        primaryPhone:
          type:
            - string
            - 'null'
        additionalPhones:
          type: array
          items:
            type: string
        website:
          type:
            - string
            - 'null'
        primaryCategory:
          oneOf:
            - $ref: '#/components/schemas/InfoCategory'
            - type: 'null'
        additionalCategories:
          type: array
          items:
            $ref: '#/components/schemas/InfoCategory'
        address:
          oneOf:
            - type: object
              properties:
                regionCode:
                  type:
                    - string
                    - 'null'
                postalCode:
                  type:
                    - string
                    - 'null'
                administrativeArea:
                  type:
                    - string
                    - 'null'
                locality:
                  type:
                    - string
                    - 'null'
                sublocality:
                  type:
                    - string
                    - 'null'
                addressLines:
                  type: array
                  items:
                    type: string
            - type: 'null'
        latitude:
          type:
            - number
            - 'null'
        longitude:
          type:
            - number
            - 'null'
        regularHours:
          type: array
          items:
            $ref: '#/components/schemas/HoursPeriod'
        specialHours:
          type: array
          items:
            type: object
            properties:
              startDate:
                oneOf:
                  - $ref: '#/components/schemas/InfoDate'
                  - type: 'null'
              endDate:
                oneOf:
                  - $ref: '#/components/schemas/InfoDate'
                  - type: 'null'
              openTime:
                oneOf:
                  - $ref: '#/components/schemas/InfoTime'
                  - type: 'null'
              closeTime:
                oneOf:
                  - $ref: '#/components/schemas/InfoTime'
                  - type: 'null'
              closed:
                type: boolean
        moreHours:
          type: array
          items:
            type: object
            properties:
              hoursTypeId:
                type:
                  - string
                  - 'null'
              periods:
                type: array
                items:
                  $ref: '#/components/schemas/HoursPeriod'
        serviceArea:
          oneOf:
            - type: object
              properties:
                businessType:
                  type:
                    - string
                    - 'null'
                  enum:
                    - BUSINESS_TYPE_UNSPECIFIED
                    - CUSTOMER_LOCATION_ONLY
                    - CUSTOMER_AND_BUSINESS_LOCATION
                    - null
                regionCode:
                  type:
                    - string
                    - 'null'
                places:
                  type: array
                  items:
                    type: object
                    properties:
                      placeId:
                        type:
                          - string
                          - 'null'
                      name:
                        type:
                          - string
                          - 'null'
            - type: 'null'
        openInfo:
          oneOf:
            - type: object
              properties:
                status:
                  type:
                    - string
                    - 'null'
                  enum:
                    - OPEN_FOR_BUSINESS_UNSPECIFIED
                    - OPEN
                    - CLOSED_PERMANENTLY
                    - CLOSED_TEMPORARILY
                    - null
                canReopen:
                  type:
                    - boolean
                    - 'null'
                openingDate:
                  oneOf:
                    - $ref: '#/components/schemas/InfoDate'
                    - type: 'null'
            - type: 'null'
        labels:
          type: array
          items:
            type: string
        services:
          type: array
          items:
            type: object
            properties:
              serviceTypeId:
                type:
                  - string
                  - 'null'
              name:
                type:
                  - string
                  - 'null'
              description:
                type:
                  - string
                  - 'null'
              price:
                oneOf:
                  - type: object
                    properties:
                      currencyCode:
                        type:
                          - string
                          - 'null'
                      units:
                        type:
                          - string
                          - 'null'
                        description: Whole units, as a string
                      nanos:
                        type:
                          - integer
                          - 'null'
                        description: Billionths of a unit
                  - type: 'null'
        mapsUrl:
          type:
            - string
            - 'null'
        newReviewUrl:
          type:
            - string
            - 'null'
    BusinessInformationEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/BusinessInformation'
    Attribute:
      type: object
      properties:
        id:
          type: string
        valueType:
          type:
            - string
            - 'null'
          enum:
            - ATTRIBUTE_VALUE_TYPE_UNSPECIFIED
            - BOOL
            - ENUM
            - URL
            - REPEATED_ENUM
            - null
        values:
          type: array
          items: {}
          description: Raw values from Google. Their type depends on valueType.
        setValues:
          type: array
          items:
            type: string
        unsetValues:
          type: array
          items:
            type: string
        urls:
          type: array
          items:
            type: string
    AttributeList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Attribute'
    AttributeListEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/AttributeList'
    Performance:
      type: object
      properties:
        from:
          type: string
          format: date
          example: '2026-10-01'
        to:
          type: string
          format: date
          example: '2026-10-02'
        summary:
          type: array
          description: One row per metric, with TOTAL_ENGAGEMENT first
          example:
            - { metric: TOTAL_ENGAGEMENT, currentSum: 501, previousSum: 462, change: 39, direction: up, hasData: true }
            - { metric: CALL_CLICKS, currentSum: 12, previousSum: 14, change: -2, direction: down, hasData: true }
            - { metric: WEBSITE_CLICKS, currentSum: 22, previousSum: 22, change: 0, direction: none, hasData: true }
            - { metric: BUSINESS_DIRECTION_REQUESTS, currentSum: 28, previousSum: 20, change: 8, direction: up, hasData: true }
          items:
            type: object
            properties:
              metric:
                type: string
                description: Metric name, such as CALL_CLICKS or WEBSITE_CLICKS
              currentSum:
                type: number
                description: Total over the selected range
              previousSum:
                type: number
                description: Total over the range of the same length before
              change:
                type: number
                description: currentSum minus previousSum
              direction:
                type: string
                enum:
                  - up
                  - down
                  - none
                  - unavailable
              hasData:
                type: boolean
        history:
          type: array
          example:
            - timestamp: '2026-10-01'
              granularity: day
              totalEngagement: 253
              metrics:
                BUSINESS_IMPRESSIONS_DESKTOP_MAPS: 21
                BUSINESS_IMPRESSIONS_DESKTOP_SEARCH: 14
                BUSINESS_IMPRESSIONS_MOBILE_MAPS: 96
                BUSINESS_IMPRESSIONS_MOBILE_SEARCH: 88
                CALL_CLICKS: 7
                WEBSITE_CLICKS: 12
                BUSINESS_DIRECTION_REQUESTS: 15
            - timestamp: '2026-10-02'
              granularity: day
              totalEngagement: 248
              metrics:
                BUSINESS_IMPRESSIONS_DESKTOP_MAPS: 18
                BUSINESS_IMPRESSIONS_DESKTOP_SEARCH: 12
                BUSINESS_IMPRESSIONS_MOBILE_MAPS: 99
                BUSINESS_IMPRESSIONS_MOBILE_SEARCH: 91
                CALL_CLICKS: 5
                WEBSITE_CLICKS: 10
                BUSINESS_DIRECTION_REQUESTS: 13
          items:
            type: object
            properties:
              timestamp:
                type: string
                description: The day, YYYY-MM-DD (UTC). There is one point for each day of the range.
              granularity:
                type: string
                enum:
                  - day
              totalEngagement:
                type: number
              metrics:
                type: object
                additionalProperties:
                  type: number
                description: Value per metric name
        syncWarning:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                message:
                  type: string
            - type: 'null'
          description: Set when some Google data could not be read. The numbers may be partial.
    PerformanceEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/Performance'
    PerformanceBatchItem:
      type: object
      properties:
        profileId:
          type: string
          example: '65a1f3c2e4b0a1d2c3e4f5a1'
        data:
          oneOf:
            - $ref: '#/components/schemas/Performance'
            - type: 'null'
        error:
          oneOf:
            - $ref: '#/components/schemas/BatchItemError'
            - type: 'null'
    PerformanceBatchEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/PerformanceBatchItem'
    SearchKeywords:
      type: object
      properties:
        from:
          type: string
          format: date
          example: '2026-10-01'
        to:
          type: string
          format: date
          example: '2026-10-03'
        keywords:
          type: array
          items:
            type: object
            properties:
              keyword:
                type: string
              impressions:
                type: integer
          description: Most impressions first
          example:
            - { keyword: bakery near me, impressions: 412 }
            - { keyword: sourdough bread austin, impressions: 187 }
            - { keyword: birthday cake pickup, impressions: 96 }
        syncWarning:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                message:
                  type: string
            - type: 'null'
          description: Set when some Google data could not be read. The numbers may be partial.
    SearchKeywordsEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/SearchKeywords'
    Embed:
      type: object
      properties:
        id:
          type: string
        embedId:
          type: string
          description: Public id used in the widget snippet
        name:
          type: string
        status:
          type: string
          enum:
            - active
            - disabled
        allowedDomains:
          type: array
          items:
            type: string
        defaultGridSize:
          type: string
        defaultRadius:
          type: number
        defaultRadiusUnit:
          type: string
        createdAt:
          type: string
          format: date-time
        lastUsedAt:
          type:
            - string
            - 'null'
          format: date-time
    EmbedList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Embed'
    EmbedListEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/EmbedList'
    EmbedLead:
      type: object
      properties:
        scanId:
          type: string
        embedId:
          type: string
        email:
          type: string
        businessName:
          type: string
        businessPlaceId:
          type: string
        keyword:
          type: string
        rank:
          type:
            - integer
            - 'null'
          description: Rank of the business in the visitor scan. Null means outside the top 20.
        createdAt:
          type: string
          format: date-time
    EmbedLeadPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/EmbedLead'
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
          description: Rows that match the filters, over all pages
    EmbedLeadPageEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/EmbedLeadPage'
    EmbedScan:
      type: object
      properties:
        id:
          type: string
        embedId:
          type: string
        keyword:
          type: string
        businessName:
          type: string
        businessPlaceId:
          type: string
        avgRank:
          type:
            - number
            - 'null'
        status:
          type: string
          enum:
            - completed
            - in_progress
        gridSize:
          type: integer
        radius:
          type: number
        radiusUnit:
          type: string
        centerLatitude:
          type: number
        centerLongitude:
          type: number
        pins:
          type: array
          items:
            type: object
            properties:
              latitude:
                type: number
              longitude:
                type: number
              rank:
                type:
                  - integer
                  - 'null'
                description: Null means outside the top 20
        createdAt:
          type: string
          format: date-time
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
    EmbedScanEnvelope:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/EmbedScan'
