> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/sdk/domains-api/fen-xiang/share.createlink.md).

# Share.createLink

> 函数式 API `getTossShareLink`也可以用来实现同样的功能。函数式 API `getTossShareLink(path, ogImageUrl)` 会接收这种形式的位置参数。

### 功能说明

会创建一个可以在 Toss App 中打开指定路径的分享链接。分享这个链接时，会启动 Toss App 并进入指定路径。没有 Toss App 的人会在 iOS 上跳转到 App Store，在 Android 上跳转到 Play Store。

路径 `intoss://`必须是以……开头的深度链接格式。例如 `intoss://my-app` 或 `intoss://my-app/about?name=test`这样编写。

可以选择性地传入 OG 图片 URL（`ogImageUrl`） `ogImageUrl`仅适用于 Toss App Android `5.240.0`, iOS `5.239.0` 及以上版本。在更低版本中，会在默认分享链接后附加 `deep_link_value` 查询参数来生成链接。

### 类型

```ts
Share.createLink(params: { path: string; ogImageUrl?: string }): Promise<string>;
```

**参数**

```ts
{
  /** 要通过深度链接打开的路径。必须以 `intoss://` 开头。 */
  path: string;
  /** 用于分享链接预览的 OG 图片 URL。 */
  ogImageUrl?: string;
}
```

**响应**

返回可在 Toss App 中打开的分享链接字符串。

### 示例代码

#### JavaScript

```js
import { Share } from "@apps-in-toss/web-framework";

try {
  const tossLink = await Share.createLink({ path: "intoss://my-app" });
  await Share.sendMessage({ message: tossLink });
} catch (error) {
  console.error(error);
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/sdk/domains-api/fen-xiang/share.createlink.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
