# Pin a message

The `pinMessage` function exposed by the SDK allows you to pin at the top of a chat a message, specified by its `messageId`.

If another message is already pinned, it is replaced.

Currently it is not possible to programmatically unpin a message.&#x20;

The user needs to be owner of the room to be able to pin the message, otherwise an error will be returned.

&#x20;**Parameters**

<table><thead><tr><th width="191">Parameter</th><th width="132.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>messageId</td><td>string</td><td>Id of the message to be pinned.</td></tr></tbody></table>

#### Returned promise

The Pin message function returns a [**JavaScript Promise**](https://www.w3schools.com/js/js_promise.asp) that will resolve once the action has been completed. The promise has the following interface:

```javascript
Promise<true | SdkError>;
```

Success

&#x20; \- In case of success, the promise returns `true`.

Error

&#x20; \- In case of error, the promise returns a `SdkError` structure, with the following properties:

<table><thead><tr><th width="196">Parameter</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>Type of error: <br><code>ERROR</code> for generic errors;<br><code>MESSAGE_ID_NOT_FOUND</code> if the message Id is not valid</td></tr><tr><td>message</td><td>string</td><td>Description of the error.</td></tr><tr><td>data</td><td>Object</td><td>Additional data on the error, with the message Id that was specified for the pin method.</td></tr></tbody></table>

#### Example

```javascript
const result = await window.symphony.sdk.pinMessage('ORRT7G00Bm0skftV+kK2tX///nZz1Vs4bQ==');
```


---

# Agent Instructions: 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:

```
GET https://docs.developers.symphony.com/embedded-modules/embedded-mode/pin-a-message.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
