# Webhooks

### Overview

Webhooks allow you to send messages and create threads inside of Glue by making a simple POST to the webhook endpoint. Here is a basic example that sends a message to the group chat for the group with ID `grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk`.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "text": "New bug reported!"
  }' \
  "https://app.gluegroups.com/webhook/wbh_123.../456..."
```

<figure><img src="/files/m2ROyl2DKKe4HGD85W65" alt="" width="563"><figcaption></figcaption></figure>

### Create a webhook

In Glue, navigate to the **Apps** section of the workspace settings.

<img src="/files/wnXpAMctuGXwYV0xfgKh" alt="" width="563">

Locate **Webhook** in the list and click **Add**.

<img src="/files/YN79oZs1VT1pIHsyQ0gR" alt="" width="563">

Enter a name and description, and then click **Create**.

After creating, you can see and copy the URL for the webhook.

<img src="/files/bLihgkei6vrlZ92MqrC7" alt="" width="563">

### Obtain a target ID

In order to send a webhook, you'll need the ID of a group or thread.

To do this, navigate to the appropriate group or thread, open the menu, and then select **Copy share link**.

<img src="/files/nMCwIytIfbiLdiLdS5jE" alt="" width="563">

Paste the link and then look for an identifier in the URL. Group IDs start with `grp_...` and thread IDs start with `thr_...`

If you are using the app from your browser, you can also look for these values in the URL bar. Note that at times, multiple IDs may be present depending on what you're viewing.

In this case, you can see the group ID of `grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk` in the following URL:

{% code overflow="wrap" %}

```
https://app.gluegroups.com/grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk?t=Chat
```

{% endcode %}

Use this value in the `target` field of your webhook payload.

### Specify the target in the URL

If you can't control the body of the request — for example, when pasting a webhook URL into a third-party tool like an alerting, monitoring, or deployment service — you can put the target directly in the webhook URL as a query parameter:

```
https://app.gluegroups.com/webhook/wbh_123.../456...?target=grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk
```

When `target` is included in the URL, you can leave it out of the body. The webhook will send to the thread or group identified by the query parameter.

{% hint style="info" %}
If `target` is present in both the URL and the body, the value in the body wins.
{% endhint %}

This makes it easy to drop a Glue webhook URL into any "paste a webhook URL here" integration without needing to customize the request body.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Deploy finished!"
  }' \
  "https://app.gluegroups.com/webhook/wbh_123.../456...?target=grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk"
```

### Webhook payload

Here are the fields that you can send to the webhook endpoint. These fields should be sent as JSON with Content-Type `application/json` .

<table><thead><tr><th width="183">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>text</code></td><td>Required. The text of the message to send. By default, this is treated as markdown.</td></tr><tr><td><code>target</code></td><td><p>Required, unless you specify the target as a query parameter on the webhook URL (see <a href="#specify-the-target-in-the-url">Specify the target in the URL</a>). The ID of a thread or group to send to.</p><p>For a group, a message will be sent to the chat unless a <code>threadSubject</code> is specific - in this case a thread will be created in the group instead.</p><p>For a thread, a message will be sent to the thread. When specifying a thread target, you cannot create threads by specifying a <code>threadSubject</code>.<br><br>Note: For the workspace wide, "General" group, the workspace id (<code>wks_...</code>) functions as the group ID. Use the full ID including "wks_".</p></td></tr><tr><td><code>threadSubject</code></td><td><p>If specified, a thread will be created instead of just sending a message.</p><p>The <code>target</code> must be a group if a subject is specified.</p></td></tr><tr><td><code>uniqueBy</code></td><td>Specify a value here to be able to update this message after it is created. If you call the webhook again with the same value, it will update the existing message instead of generating a new one.<br><br>The uniqueBy value should be unique for the the thread or chat that the message is sent to.</td></tr><tr><td><code>threadBy</code></td><td>If specified, the webhook will send follow up messages to created threads with the same value. The first message will create the thread and then the following messages will be appending to that thread.</td></tr></tbody></table>

### Examples

At a minimum, you must specify a `target` and `text` to send a message via a webhook.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "thr_2hTJ4DGsxUAeEhKOyJ2PMePFL0c",
    "text": "New bug reported!"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

<div align="left"><figure><img src="/files/jmVQjHCfhxOwqD2aVc4O" alt="" width="375"><figcaption></figcaption></figure></div>

The additional examples below demonstrate more advanced functionality.

<details>

<summary>Example: Sending and updating a message</summary>

To send a message, simply provide a `target` field with a thread or group ID and a `text` field with the message text. Optionally, you can pass a `uniqueBy` value that you can use to update the message by calling the webhook again with the same value.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "thr_2hTJ4DGsxUAeEhKOyJ2PMePFL0c",
    "text": "New bug reported: [BUG154](https://example.com/BUG154)",
    "uniqueBy": "BUG154"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

![](/files/glE8cWtGDS8g4lQUwDFZ)

To update the previously sent message, call the webhook again with the same `uniqueBy` value.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "thr_2hTJ4DGsxUAeEhKOyJ2PMePFL0c",
    "text": "New bug reported: [BUG154](https://example.com/BUG154) \n\nResolved by Jason",
    "uniqueBy": "BUG154"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

![](/files/tk28X2VRUYclVv4JXONp)

To generate a new message, simply provide a new `uniqueBy` value, or omit the `uniqueBy` value if you do not need to update the message.

</details>

<details>

<summary>Example: Formatting messages</summary>

Glue uses markdown to format messages. The following features are supported:

* Text styling
  * Bold
  * Italics
  * Strikethrough
* Links
* User mentions
* Inline code
* Code blocks
* Blockquotes
* Paragraphs
* Lists
  * Ordered
  * Unordered

These features are described in detail below.

**1. Text Styling**

**Bold**

To make text bold, wrap it with two asterisks (`**`) or two underscores (`__`). For example:

```
**This is bold text**
__This is also bold text__
```

Displays as:

![](/files/C5zgwt9FHr0OiPgQoq2J)

**Italics**

To italicize text, wrap it with one asterisk (`*`) or one underscore (`_`). For example:

```
*This is italic text*
_This is also italic text_
```

Displays as:

![](/files/xJmWCo1apunlkReWBr6V)

**Strikethrough**

To strikethrough text, wrap it with two tildes (`~~`). For example:

```
~~This text is strikethrough~~
```

Displays as:

![](/files/TbAGETgCWhLxon3q86RP)

**Bold and Italics Combined**

You can combine bold and italics for even more emphasis. For example:

```
***This is bold and italic text***
___This is also bold and italic text___
```

Displays as:

![](/files/9pDKw6psA5d8VN2SiiBz)

**2. Links**

To create a hyperlink, use square brackets `[ ]` to set the text and parentheses `( )` to set the URL. For example:

```
[Glue](https://glue.ai)
```

Displays as:

![](/files/JpmIj99v47mo1z24V76T)

**User Mentions**

To mention a user in our chat app, use the following format:

```
[Jason Yonker](glue:usr_2PtTG7GFSgcgwfpeDOBGEQtyB24)
```

Displays as:

![](/files/EqQL7spn5Qucd84YdsJD)

**3. Inline Code**

To include inline code, wrap your text with backticks (\`). For example:

```
Here is some inline code: `print("Hello, World!")`
```

Displays as:

![](/files/rYIubgBZkyYWaObDX9a5)

**4. Code Blocks**

For longer code snippets, use triple backticks (\`\`\`) before and after your code block. You can also specify the language for syntax highlighting. For example:

````
```python
for i in range(10):
    print(i)
```
````

Displays as:

![](/files/ymmABTSbSqbjzsJVCN7h)

**5. Blockquotes**

To create a blockquote, use the greater than (`>`) symbol followed by a space. For example:

```
> This is a blockquote.
```

Displays as:

![](/files/IrowQ0EDWUi8ypKGY1mP)

**6. Paragraphs**

To create paragraphs, simply separate your text with one or more blank lines. For example:

```
This is the first paragraph.

This is the second paragraph.
```

Displays as:

![](/files/60ksLTAOL36lpPw517Q0)

**7. Lists**

**Unordered Lists**

To create an unordered list, use `-`, `*`, or `+` followed by a space. For example:

```
- Item 1
- Item 2
  - Subitem 1
  - Subitem 2
* Item 3
+ Item 4
```

Displays as:

![](/files/WrpsAaF7Aw1oEghFe78Q)

**Ordered Lists**

To create an ordered list, use numbers followed by a period and a space. For example:

```
1. First item
2. Second item
   1. Subitem 1
   2. Subitem 2
3. Third item
```

Displays as:

![](/files/olr757hkd3Lx2gQsOxG7)

</details>

<details>

<summary>Example: Creating threads</summary>

To create a thread instead of just sending a message, specify a `threadSubject` and ensure that the `target` value is a group. This will result in a thread created in the group with the subject of `threadSubject` and starter message from `text`. The `threadBy` and `uniqueBy` values are optional values that let us update this message (`uniqueBy`) and post more messages to the thread (`threadBy`).

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "threadSubject": "New crash in main.js",
    "text": "ReferenceError: reference to undefined property x",
    "threadBy": "BUG268",
    "uniqueBy": "BUG268-starter-message"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

![](/files/U8jz857ItOSwPiykMcnm)

When you specify a `threadBy` value, you can send follow up messages to the thread by calling the webhook again with the same `threadBy` value. In this case we're using the value `BUG268`. The value is normally and identifier from the external system that is generating the message.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "threadSubject": "New crash in main.js",
    "text": "Jason, can you look into this?",
    "threadBy": "BUG268"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

![](/files/MGFjyMuRiRf9cVoaVPgG)

Because we specified a `uniqueBy` value for the starter message, we can call the webhook again to update that starter message (rather than send a new message). Here we're using `"uniqueBy": "BUG268-starter-message"` which is the value we passed in the first webhook to start the thread.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "threadSubject": "New crash in main.js",
    "text": "ReferenceError: reference to undefined property x \n\nAssigned to: Jason",
    "threadBy": "BUG268",
    "uniqueBy": "BUG268-starter-message"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

![](/files/mThL3im4Q39Ezy9qo6Lw)

To create a different thread, send a new `threadBy` value or, if the thread by value is omitted, a new thread will alsways be created.

```bash
curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "threadSubject": "New crash in index.js",
    "text": "ReferenceError: reference to undefined property y",
    "threadBy": "BUG269",
    "uniqueBy": "BUG269-starter-message"
  }' \
  "https://app.glue.ai/webhook/wbh_123.../456..."
```

![](/files/4SOIYNQ40EK1n3bYgPfw)

</details>

<details>

<summary>Example: Attachments</summary>

To send a message with an attachment, start by uploading the attachment. To do this, append `/attachment` to the end of your webhook URL and make a PUT request. The body of the request should contain the raw contents of the file you are uploading.

The following headers are required:

1. `Content-Length`: The length of the file/body of the request
2. `Content-MD5`: The MD5 computed from the contents of the file
3. `X-File-Name`: The name of the file to be uploaded.

A PUT request is required. POST is not accepted. Also `multipart/form-data` is not accepted.

```
FILE="yourfile.pdf"
FILENAME=$(basename "$FILE")
CONTENT_LENGTH=$(wc -c < "$FILE" | tr -d ' ')
CONTENT_MD5=$(openssl dgst -md5 -binary "$FILE" | openssl base64)

curl -X PUT "https://api.gluegroups.com/webhook/wbh_123.../456.../attachment" \
  --data-binary @"$FILE" \
  -H "Content-Length: $CONTENT_LENGTH" \
  -H "Content-MD5: $CONTENT_MD5" \
  -H "X-File-Name: $FILENAME"
```

You will receive a JSON response back with the `id` of the file that was uploaded.

```
{"id":"fil_2ymM4HRuRY4A7ed8OvVaUYxQ812"}
```

To send a message with the uploaded file attached, simply include an `attachments` field with an array containing the file IDs you want to attach. You can attach up to 10 files per message.

```
  curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "thr_2kbzWHxtQvfVEgwEdQduuxRTYG3",
    "text": "New report available!",
    "attachments": ["fil_2ymM4HRuRY4A7ed8OvVaUYxQ812"]
  }' \
  "https://api.gluegroups.com/webhook/wbh_123.../456..."
```

</details>

### Coming soon

* Automatic link parsing
* Link previews
* Option to send plain text instead of markdown for the `text` field


---

# 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.glue.ai/integrations/integrations-overview/webhooks.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.
