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

# Share a Google review’s draft

> Turns the draft’s preview share link on or off.

```ts TypeScript wrap theme={"dark"}
import { createSiteClient } from '@fetchski/attract-cms-sdk';

const site = createSiteClient();
const googleReview = await site.googleReviews().shareGoogleReview({ id: 'clx8m2k4p0000a1b2c3d4e5f6' });
```

```json 200 wrap theme={"dark"}
{
  "title": "Example title",
  "reviewerName": "Example reviewer name",
  "isAnonymous": false,
  "rating": 5,
  "reviewText": "Example review text",
  "reviewedAt": "2026-10-24",
  "featured": false,
  "slug": "example-slug",
  "visibility": "public",
  "scheduledPublish": "Example scheduled publish",
  "scheduledUnpublish": "Example scheduled unpublish",
  "reviewerPhotoUrl": "https://acme.example/example",
  "ownerReply": "Example owner reply",
  "replyState": "Example reply state",
  "replyPolicyViolation": "Example reply policy violation",
  "stagedReply": "Example staged reply",
  "stagedReplyAction": "Example staged reply action",
  "reviewUrl": "https://acme.example/example",
  "source": "manual",
  "sourceId": "clx8m2k4p0000a1b2c3d4e5f6",
  "gbpLocationId": "clx8m2k4p0000a1b2c3d4e5f6",
  "archived": false,
  "_id": "clx8m2k4p0000a1b2c3d4e5f6",
  "type": "Example type",
  "createdAt": "2026-10-24T09:30:00.000Z",
  "updatedAt": "2026-10-24T09:30:00.000Z",
  "aposShareKey": "k3v9x2m7q1z8w4p6"
}
```

## In your app

A function makes the call on the client it is given, so your code passes the real one and a test passes a fake.

**1. Add the function**

```ts src/attract/share-google-review.ts theme={"dark"}
import type { SiteClient } from '@fetchski/attract-cms-sdk';

export async function shareGoogleReview(site: SiteClient, id: string) {
  return site.googleReviews().shareGoogleReview({ id });
}
```

**2. Call it**

A script makes the client once and calls the function:

```ts scripts/share-google-review.ts theme={"dark"}
import { createSiteClient } from '@fetchski/attract-cms-sdk';
import { shareGoogleReview } from '../src/attract/share-google-review.ts';

const site = createSiteClient();
console.log(await shareGoogleReview(site, 'clx8m2k4p0000a1b2c3d4e5f6'));
```

```bash Terminal theme={"dark"}
node --env-file=.env scripts/share-google-review.ts
```

A route handler, a job or a queue worker calls it the same way.

Takes the draft’s exact `_id` (`…:en:draft`). Answers the draft, with its `aposShareKey` while the link is on: the link is the draft’s `_url` with `aposShareKey` and `aposShareId` (the draft’s `_id`) in its query.

## Find the id

`id` is the document’s `_id`, from a list. Ask the list for only the fields you need: each row is a document’s `id` and those fields.

```ts TypeScript wrap theme={"dark"}
import { createSiteClient } from '@fetchski/attract-cms-sdk';

const site = createSiteClient();
const row = (await site.googleReviews().listGoogleReviewsPick(['title', 'slug'])).find((each) => each.slug === 'getting-started'); // { id, title, slug }, or undefined
```

Pass `row.id` as `id`. Drafts: list with `{ aposMode: 'draft' }` to get the draft’s id ([Find an id](https://docs.fetchski-attract.com/find-an-id.md)).

> [accordion] Required parameters
>
> One object, e.g. `shareGoogleReview({ id })`; leave out the optional fields.
>
> **id** `string` *required*
>
> **Required.** The draft’s exact `_id` (`…:en:draft`).

> [accordion] Optional parameters
>
> **share** `boolean | null | undefined`
>
> **Optional.** Leave it out (or pass `null`) and it isn’t sent: the site’s default applies. true adds a share key (`aposShareKey`) to the draft; false (the default) removes it.

> [accordion] Returns
>
> A `GoogleReview`. GoogleReview content type. Read its properties (`googleReview.title`): each says whether the site always sends it. The example answer is the site’s wire JSON: one key differs from the property names (`_id` → `id`).
>
> **title** `string`
>
> **Always sent.** Its title: the name it goes by in every list, and the heading of its page where it has one.
>
> **reviewerName** `string`
>
> **Always sent.** Reviewer name.
>
> **slug** `string`
>
> **Always sent.** The URL name: lowercase words joined by hyphens (letters outside a–z, even emoji, are kept).
>
> **id** `string`
>
> **Always sent.** The document’s id. On a type with drafts it ends in its locale and mode (`…:en:published`, `…:en:draft`): the part before the first colon is its `aposDocId`, shared by both copies. The `{_id}` the type’s routes take.
>
> **type** `string`
>
> **Always sent.** The document type’s name: always this type’s.
>
> **isAnonymous** `boolean | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Set when Google returned no reviewer name. The frontend shows a generic label + initial avatar.
>
> **rating** `number | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Rating (1–5).
>
> **reviewText** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Review text.
>
> **reviewedAt** `Date | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Review date. Format: an ISO 8601 date (`YYYY-MM-DD`).
>
> **featured** `boolean | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Hand-curation flag. The widget can be set to show only featured reviews.
>
> **visibility** `Visibility | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Select whether this content is public or private. One of `public`, `loginRequired`; a newer site may send others, so keep a fallback.
>
> **scheduledPublish** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. An ISO 8601 date and time, e.g. `2026-10-21T14:30:00.000Z`.
>
> **scheduledUnpublish** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. An ISO 8601 date and time, e.g. `2026-10-21T14:30:00.000Z`.
>
> **reviewerPhotoUrl** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. The reviewer’s Google avatar URL, stored as-is (not downloaded). The frontend renders it directly and falls back to a lettered avatar if missing or stale. When set, a URL; empty or null when not.
>
> **ownerReply** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. The business’s public reply to this review, if any.
>
> **replyState** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Google moderates owner replies asynchronously: PENDING until reviewed, then APPROVED or REJECTED. Synced from the Business Profile API; blank for manual rows or replies predating moderation visibility.
>
> **replyPolicyViolation** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. The policy reason Google gave when it rejected the owner reply, if any.
>
> **stagedReply** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. A reply drafted in the Google Business Dashboard and not yet pushed to Google. Managed by the dashboard’s Review & push flow, never edited here.
>
> **stagedReplyAction** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. What the staged reply will do when pushed: “reply” (create/update the owner reply) or “delete” (remove it). Blank when nothing is staged.
>
> **reviewUrl** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Permalink to the review on Google, when the provider supplies one. When set, a URL; empty or null when not.
>
> **source** `GoogleReviewSource | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. Source. One of `manual`, `places-api`, `business-profile`, `demo`; a newer site may send others, so keep a fallback.
>
> **sourceId** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. The review’s stable Google resource id — the de-duplication key set by a sync. Leave blank for manual entries.
>
> **gbpLocationId** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. The Google Business Profile location this review belongs to (bare location id) — set by the Business Profile sync; ties the review to its gbp-location mirror row and the dashboard’s Reviews section.
>
> **archived** `boolean | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. In the archive: kept, but out of every list and off the site until it is restored. `false` (or null) for a live document.
>
> **createdAt** `Date | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. When it was created (ISO 8601). Format: an ISO 8601 date and time.
>
> **updatedAt** `Date | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. When it last changed (ISO 8601). Format: an ISO 8601 date and time.
>
> **aposShareKey** `string | null`
>
> **Sometimes sent:** `undefined` when the site leaves it out, and it can be `null`. The draft’s preview share key, while its share link is on: the link is the draft’s `_url` with `aposShareKey` and `aposShareId` (the draft’s `_id`) in its query. Absent otherwise, and on published documents.

> [accordion] Errors
>
> Nothing to catch: the SDK retries what is safe, and throws the rest as the classes below; catch only what you want to react to (see [Errors and testing](https://docs.fetchski-attract.com/typescript/errors.md)).
>
> **ValidationFailed** `400`
>
> The site refused what was sent: `errors` lists each field’s problem, `siteMessage` the first.
>
> **Retried first:** No. **Read:** `errors` (field → messages), `siteMessage`.
>
> **AuthenticationFailed** `401`
>
> The API key is missing or refused (malformed, revoked, expired), or a signature its signing mode needs is missing or stale.
>
> **Retried first:** No. **Read:** `siteMessage`, `errorName`, `data`.
>
> **Forbidden** `403`
>
> The key may not do this: a scope it lacks, or an address outside its allowlist. `siteMessage` names it.
>
> **Retried first:** No. **Read:** `siteMessage`, `errorName`, `data`.
>
> **NotFound** `404`
>
> Nothing matches, or the caller may not see it.
>
> **Retried first:** No. **Read:** `siteMessage`, `errorName`, `data`.
>
> **SiteError** `500`
>
> The site failed. Its logs say why.
>
> **Retried first:** No: a write may have landed. **Read:** `siteMessage`, `errorName`, `data`.
>
> **SiteUnreachable** `no answer`
>
> No answer: DNS, a refused connection, TLS, or the timeout (15 s per attempt by default).
>
> **Retried first:** Only when nothing reached the site (`neverConnected()`); never after a timeout, when it may have landed. **Read:** `reason`, `neverConnected`.
>
> **RequestNotSent** `not sent`
>
> The client refused to send it (e.g. a path segment of `..`); the site never saw it.
>
> **Retried first:** No. **Read:** `reason` (what to change).
>
> **SiteRequestFailed** `any other`
>
> Any other status, or a success whose JSON doesn’t match this SDK version’s types (update the SDK).
>
> **Retried first:** No. **Read:** `reason`, `status`.
>
> **UnknownSite** `setup`
>
> `sites.forSite('acme')` named a slug your sites (`createSiteClients()`) don’t have.
>
> **Retried first:** No: nothing was sent. **Read:** `message`, `slug`.
>
> **SiteConfigurationError** `setup`
>
> The client’s settings are wrong: no `FETCHSKI_ATTRACT_URL` (or `baseUrl`), or a malformed API key.
>
> **Retried first:** No: nothing was sent. **Read:** `message` (what to fix).

## Behavior

* **Access:** an API key with `content:google-reviews:write` (or a master above it: `content:google-reviews:all`, `content:all`, `admin:all`). A signed-in person may call it as far as their own permissions allow; anyone else gets 403.
* **Rate limit:** the key’s own writes-per-minute limit, set when the key is created (default 120); over it, 429 with `Retry-After`. The client waits and retries for you; you see `RateLimited` only if that runs out.
* **Retries:** a write is sent again only after a 429 (refused before it acted) or when it never reached the site. After a timeout or a 5xx it may have landed: check before you send it again.
* **Timeout:** 15 s per attempt by default; raise `timeout` (milliseconds) on the client for longer.

## Test it

It calls the function above with a fake client: the fake answers every call with a valid example, so nothing leaves your machine and no settings or key are needed. Run it with `node --test`.

```ts tests/googleReviews-shareGoogleReview.test.ts theme={"dark"}
import { test } from 'node:test';
import { fakeSite } from '@fetchski/attract-cms-sdk/testing';
import { shareGoogleReview } from '../src/attract/share-google-review.ts';

test('googleReviews.shareGoogleReview', async () => {
  const site = fakeSite();
  await shareGoogleReview(site, 'clx8m2k4p0000a1b2c3d4e5f6');
  site.assertCalled('googleReviews.shareGoogleReview', (args) => args.id === 'clx8m2k4p0000a1b2c3d4e5f6');
});
```

**Answer with your own values:** fake `googleReviews.shareGoogleReview` with `factories.GoogleReview({...})`, the fields you give over a valid example.

```ts tests/googleReviews-shareGoogleReview-answer.test.ts theme={"dark"}
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { factories, fakeSite } from '@fetchski/attract-cms-sdk/testing';

test('googleReviews.shareGoogleReview answers your values', async () => {
  const site = fakeSite({
    'googleReviews.shareGoogleReview': factories.GoogleReview({ title: 'Your value' })
  });
  const googleReview = await site.googleReviews().shareGoogleReview({ id: 'clx8m2k4p0000a1b2c3d4e5f6' });
  assert.equal(googleReview.title, 'Your value');
});
```

## Related

> [card] [List a Google review’s locales](https://docs.fetchski-attract.com/typescript/reference/google-reviews/get-google-review-locales.md)
>
> `site.googleReviews().getGoogleReviewLocales()`

> [card] [List Google reviews](https://docs.fetchski-attract.com/typescript/reference/google-reviews/list-google-reviews.md)
>
> `site.googleReviews().listGoogleReviews()`

> [card] [Create a Google review](https://docs.fetchski-attract.com/typescript/reference/google-reviews/create-google-review.md)
>
> `site.googleReviews().createGoogleReview()`

> [card] [Get a Google review](https://docs.fetchski-attract.com/typescript/reference/google-reviews/get-google-review.md)
>
> `site.googleReviews().getGoogleReview()`

> [card] [Replace a Google review](https://docs.fetchski-attract.com/typescript/reference/google-reviews/replace-google-review.md)
>
> `site.googleReviews().replaceGoogleReview()`

> [card] [Delete a Google review](https://docs.fetchski-attract.com/typescript/reference/google-reviews/delete-google-review.md)
>
> `site.googleReviews().deleteGoogleReview()`

> [card] [POST /google-review/\{\_id}/share](https://docs.fetchski-attract.com/api-reference/google-reviews/share-a-google-review’s-draft.md)
>
> The endpoint this calls, in the API reference: the HTTP request and answer, and every rule the site checks.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.