> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Sharing

> Fetch shareable-link configuration and build links for supported social content

Shareable links are configured at the network level. The SDKs fetch the configured domain and URL patterns so your app can build links to Social+ content using your own routing scheme.

The current SDKs expose this configuration differently:

| Platform   | SDK surface                                                                                                            |
| ---------- | ---------------------------------------------------------------------------------------------------------------------- |
| TypeScript | `Client.getShareableLinkConfiguration()` returns helper methods such as `generateLink`, `getPattern`, and `isEnabled`. |
| iOS        | `client.getShareableLinkConfiguration()` returns `domain` and `patterns`.                                              |
| Android    | `AmityCoreClient.getShareableLinkConfiguration().getShareableLink()` returns `domain` and `patterns`.                  |
| Flutter    | No public shareable-link configuration API was found in the current Flutter SDK source.                                |

<Info>
  The SDK reads the configured patterns. It does not create the destination screens in your app. Your app still needs routes that can open the generated URLs.
</Info>

## Parameters

| Operation            | Parameter       | Required | Description                                                       |
| -------------------- | --------------- | -------- | ----------------------------------------------------------------- |
| Fetch configuration  | None            | No       | Reads the network-level shareable-link configuration.             |
| Generate a post link | `postId`        | Yes      | Post ID used to replace `{postId}` in the configured URL pattern. |
| Generate a post link | `posts` pattern | Yes      | Pattern returned by the backend configuration for post links.     |
| Generate a post link | `domain`        | Yes      | Configured shareable-link domain returned by the SDK.             |

## Supported Pattern Keys

TypeScript maps content types to these pattern keys:

| Content type | Pattern key   | Placeholder     |
| ------------ | ------------- | --------------- |
| Post         | `posts`       | `{postId}`      |
| Community    | `communities` | `{communityId}` |
| User         | `users`       | `{userId}`      |
| Livestream   | `livestream`  | `{livestream}`  |
| Event        | `events`      | `{eventId}`     |

iOS and Android return the backend `patterns` map directly. Check that the key you need exists before generating a link.

## Generate a Post Link

Fetch the shareable-link configuration before generating a post link, then fall back gracefully if the needed pattern is missing.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { AmitySharableContentType, Client } from "@amityco/ts-sdk";

  async function getPostShareLink(postId: string) {
    const config = await Client.getShareableLinkConfiguration();

    return config.generateLink(AmitySharableContentType.POST, postId);
  }
  ```

  ```swift iOS theme={null}
  let postId = "post-id"
  let config = try await client.getShareableLinkConfiguration()

  if let pattern = config.patterns["posts"] {
      let link = config.domain + pattern.replacingOccurrences(
          of: "{postId}",
          with: postId
      )
      showInfo(link)
  }
  ```

  ```kotlin Android theme={null}
  AmityCoreClient.getShareableLinkConfiguration()
      .getShareableLink()
      .subscribe({ config ->
          val pattern = config.getPatterns()["posts"]
          val link = pattern?.let {
              config.getDomain() + it.replace("{postId}", postId)
          }
      }, { error ->
          handleGeneralError(error)
      })
  ```
</CodeGroup>

## Generate an Event Link

Event links are the primary use case for shareable links: an app can copy or share a direct link to an event detail screen. Gate the share UI on `isEnabled` first, then generate the link — `generateLink` returns `null` when the event pattern is not configured.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { AmitySharableContentType, Client } from "@amityco/ts-sdk";

  async function getEventShareLink(eventId: string) {
    const config = await Client.getShareableLinkConfiguration();

    // Feature gate — hide the share action when event links aren't configured
    if (!config.isEnabled(AmitySharableContentType.EVENT)) return null;

    return config.generateLink(AmitySharableContentType.EVENT, eventId);
    // → "https://app.example.com/events/abc123" or null
  }
  ```

  ```swift iOS theme={null}
  let eventId = "event-id"
  let config = try await client.getShareableLinkConfiguration()

  // Feature gate — hide the share action when event links aren't configured
  guard config.isEnabled(.event) else { return }

  if let link = config.generateLink(.event, referenceId: eventId) {
      showInfo(link)
  }
  ```

  ```kotlin Android theme={null}
  AmityCoreClient.getShareableLinkConfiguration()
      .subscribe({ config ->
          // Feature gate — hide the share action when event links aren't configured
          if (config.isEnabled(AmitySharableContentType.EVENT)) {
              val link = config.generateLink(AmitySharableContentType.EVENT, eventId)
              // ... copy or share `link`
          }
      }, { error ->
          handleGeneralError(error)
      })
  ```
</CodeGroup>

<Note>
  Shareable links are available on TypeScript, iOS, and Android. Flutter has no public shareable-link configuration API in the current SDK source.
</Note>

## Best Practices

* Treat missing patterns as a disabled share target for that content type.
* Generate links only after the content exists and you have the final content ID.
* Keep app route handling separate from link generation so deleted or restricted content can show a useful fallback screen.
* Cache the configuration during a session if your sharing UI needs it often.

## Related Topics

<CardGroup cols={3}>
  <Card title="Posts Overview" href="./posts/overview" icon="pen-to-square">
    Learn how posts are modeled and created.
  </Card>

  <Card title="Communities" href="../communities-spaces/overview" icon="users">
    Share community destinations after configuring community URL patterns.
  </Card>

  <Card title="User Management" href="../../core-concepts/user-management/overview" icon="user">
    Share user profile destinations after configuring user URL patterns.
  </Card>

  <Card title="Events" href="../events/overview" icon="calendar">
    Share event links after configuring the event URL pattern.
  </Card>
</CardGroup>
