# Messages

# Reactions

## Add a reaction

`$client->chats->messages->reactions->add(string messageID, string chatID, string reactionKey, ?string transactionID): ReactionAddResponse`

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

Add a reaction to an existing message.

### Parameters

- `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 to add (emoji, shortcode, or custom emoji key)

- `transactionID?:optional string`

  Optional transaction ID for deduplication and send tracking

### Returns

- `ReactionAddResponse`

  - `string chatID`

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

  - `string messageID`

    Message ID.

  - `string reactionKey`

    Reaction key that was added.

  - `true success`

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

  - `string transactionID`

    Transaction ID used for send tracking.

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(accessToken: 'My Access Token');

$response = $client->chats->messages->reactions->add(
  '1343993',
  chatID: '!NCdzlIaMjZUmvmvyHU:beeper.com',
  reactionKey: 'x',
  transactionID: 'transactionID',
);

var_dump($response);
```

#### 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(string reactionKey, string chatID, string messageID): ReactionDeleteResponse`

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

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

### Parameters

- `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 to remove (emoji, shortcode, or custom emoji key)

### Returns

- `ReactionDeleteResponse`

  - `string chatID`

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

  - `string messageID`

    Message ID.

  - `string reactionKey`

    Reaction key that was removed.

  - `true success`

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

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(accessToken: 'My Access Token');

$reaction = $client->chats->messages->reactions->delete(
  'x', chatID: '!NCdzlIaMjZUmvmvyHU:beeper.com', messageID: '1343993'
);

var_dump($reaction);
```

#### Response

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