# Messages

# Reactions

## Add a reaction

`client.Chats.Messages.Reactions.Add(ctx, messageID, params) (*ChatMessageReactionAddResponse, error)`

**post** `/v1/chats/{chatID}/messages/{messageID}/reactions`

Add a reaction to an existing message.

### Parameters

- `messageID string`

  Message ID.

- `params ChatMessageReactionAddParams`

  - `ChatID param.Field[string]`

    Path param: Chat ID. Input routes also accept the local chat ID from this installation when available.

  - `ReactionKey param.Field[string]`

    Body param: Reaction key to add (emoji, shortcode, or custom emoji key)

  - `TransactionID param.Field[string]`

    Body param: Optional transaction ID for deduplication and send tracking

### Returns

- `type ChatMessageReactionAddResponse struct{…}`

  - `ChatID string`

    Chat ID. Input routes also accept the local chat ID from this installation when available.

  - `MessageID string`

    Message ID.

  - `ReactionKey string`

    Reaction key that was added.

  - `Success bool`

    Always true. Indicates the reaction was queued; failures return an error response.

    - `const ChatMessageReactionAddResponseSuccessTrue ChatMessageReactionAddResponseSuccess = true`

  - `TransactionID string`

    Transaction ID used for send tracking.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/beeper/desktop-api-go"
  "github.com/beeper/desktop-api-go/option"
)

func main() {
  client := beeperdesktopapi.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  response, err := client.Chats.Messages.Reactions.Add(
    context.TODO(),
    "1343993",
    beeperdesktopapi.ChatMessageReactionAddParams{
      ChatID: "!NCdzlIaMjZUmvmvyHU:beeper.com",
      ReactionKey: "x",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ChatID)
}
```

#### Response

```json
{
  "chatID": "!whatsapp_15550101002:ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc.local-whatsapp.localhost",
  "messageID": "1343993",
  "reactionKey": "❤️",
  "success": true,
  "transactionID": "txn_v3a8f4c9d2e1"
}
```

## Remove a reaction

`client.Chats.Messages.Reactions.Delete(ctx, reactionKey, body) (*ChatMessageReactionDeleteResponse, error)`

**delete** `/v1/chats/{chatID}/messages/{messageID}/reactions/{reactionKey}`

Remove the reaction added by the authenticated user from an existing message.

### Parameters

- `reactionKey string`

  Reaction key to remove (emoji, shortcode, or custom emoji key)

- `body ChatMessageReactionDeleteParams`

  - `ChatID param.Field[string]`

    Chat ID. Input routes also accept the local chat ID from this installation when available.

  - `MessageID param.Field[string]`

    Message ID.

### Returns

- `type ChatMessageReactionDeleteResponse struct{…}`

  - `ChatID string`

    Chat ID. Input routes also accept the local chat ID from this installation when available.

  - `MessageID string`

    Message ID.

  - `ReactionKey string`

    Reaction key that was removed.

  - `Success bool`

    Always true. Indicates the reaction removal was queued; failures return an error response.

    - `const ChatMessageReactionDeleteResponseSuccessTrue ChatMessageReactionDeleteResponseSuccess = true`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/beeper/desktop-api-go"
  "github.com/beeper/desktop-api-go/option"
)

func main() {
  client := beeperdesktopapi.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  reaction, err := client.Chats.Messages.Reactions.Delete(
    context.TODO(),
    "x",
    beeperdesktopapi.ChatMessageReactionDeleteParams{
      ChatID: "!NCdzlIaMjZUmvmvyHU:beeper.com",
      MessageID: "1343993",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", reaction.ChatID)
}
```

#### Response

```json
{
  "chatID": "!whatsapp_15550101002:ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc.local-whatsapp.localhost",
  "messageID": "1343993",
  "reactionKey": "❤️",
  "success": true
}
```
