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

# insertTextLink

> Insert a text link into the main layer of the currently opened note page.

<Note>
  Links can only be inserted into the main layer; other layers are not supported. This API supports undo/redo in notes.
</Note>

```ts theme={null}
static insertTextLink(textLink: {
 destPath: string;
 destPage?: number;
 style: number;
 linkType: number;
 rect: Rect;
 fontSize: number;
 fullText: string;
 showText: string;
 isItalic: number;
}): Promise<APIResponse<number>>;
```

**Parameters**

| Parameter           | Type                                                    | Description                                                                                                                                                                                                                                                                                                 |
| ------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `textLink.destPath` | `string`                                                | Destination path / URL: when `linkType === 4`, set this to the URL; otherwise set it to the destination file path                                                                                                                                                                                           |
| `textLink.destPage` | `number`                                                | Destination page (only valid when `linkType === 0` or `linkType === 2`)<br />For `linkType === 0`: must be a non-negative integer, meaning the target note page<br />For `linkType === 2`: a negative value jumps to the document current page; a non-negative integer jumps to the specified document page |
| `textLink.style`    | `number`                                                | Link style: `0` solid underline, `1` solid border, `2` dashed border                                                                                                                                                                                                                                        |
| `textLink.linkType` | `number`                                                | Link type: `0` note page, `1` note file, `2` document, `3` image, `4` URL                                                                                                                                                                                                                                   |
| `textLink.rect`     | [`Rect`](/en/api-reference/supernote-plugin/types/rect) | Text region rectangle (must be non-zero area)                                                                                                                                                                                                                                                               |
| `textLink.fontSize` | `number`                                                | Font size (positive number)                                                                                                                                                                                                                                                                                 |
| `textLink.fullText` | `string`                                                | Full text (required for text links)                                                                                                                                                                                                                                                                         |
| `textLink.showText` | `string`                                                | Display text (required for text links)                                                                                                                                                                                                                                                                      |
| `textLink.isItalic` | `number`                                                | Italic: `0` no, `1` yes                                                                                                                                                                                                                                                                                     |

<Note>
  Supported `linkType` ranges may differ across APIs. Currently, `insertTextLink` only allows `0..4`.
  When reading lasso link data, you may encounter `linkType=6` (digest link). This type is currently read-only and cannot be created via this API. See [`Link`](/en/api-reference/supernote-plugin/types/link) / [`LassoLink`](/en/api-reference/supernote-plugin/types/lasso-link).
</Note>

**Returns**

* [`APIResponse<number>`](/en/api-reference/supernote-plugin/types/api-response):
  `result` is a status code (convention: `0` success, `-1` failure, `-2` target file requires upgrade)

## Example

```ts wrap theme={null}
import { PluginNoteAPI, type Rect } from 'sn-plugin-lib';

/**
 * Example: insert a text link into the current note page.
 */
export async function exampleInsertTextLink() {
 const rect: Rect = { left: 100, top: 100, right: 300, bottom: 160 };
 const res = await PluginNoteAPI.insertTextLink({
 destPath: '/storage/emulated/0/Note/demo.note',
 destPage: 1,
 style: 0,
 linkType: 0,
 rect,
 fontSize: 32,
 fullText: 'Full Text',
 showText: 'Show Text',
 isItalic: 0,
 });

 if (!res.success) {
 throw new Error(res.error?.message ?? 'insertTextLink call failed');
 }
 return res.result;
}
```
