# React to a Message

`POST /messages/react`

Add or remove an emoji reaction to a previously sent message.

## Authentication

Send your API key in the `PINNACLE-API-KEY` header.

## Request body

Required.

Content type: `application/json`.

### Fields

- `messageId` — `string`, minimum: 1. Unique identifier of the message. This identifier is a string that always begins with the prefix `msg_`, for example: `msg_1234567890`.
- `options` — `ReactMessageOptions`, optional
- `options.force` — `boolean`, optional, default: false. By default, only messages sent with the `options.tracking` field can be precisely reacted to.

Set `options.force` to true to bypass this restriction (may react to a different message).

For MMS and RCS, only messages containing text can be tracked. Otherwise, `options.force` is ignored.
- `reaction` — `string`. Unicode emoji to add.

Use `null` to remove existing reaction.

### Example

```json
{
  "messageId": "msg_1234567890",
  "reaction": "👍",
  "options": {
    "force": true
  }
}
```

## Responses

### 200

Successfully added or removed a reaction from the message.

Content type: `application/json`. Schema: `ReactionResult`.

- `messageId` — `string`. Unique identifier of the message. This identifier is a string that always begins with the prefix `msg_`, for example: `msg_1234567890`.
- `reactionMessageId` — `string`. Unique identifier of the message with the reaction. This identifier is a string that always begins with the prefix `msg_`, for example: `msg_1234567890`.

Example:

```json
{
  "reactionMessageId": "msg_1234567890",
  "messageId": "msg_1234567890"
}
```

### 400

The request was unacceptable, often due to providing an invalid update.

Errors may originate from invalid payload or from Pinnacle's additional validation checks. For example, providing an URL that cannot be accessed, updating a campaign that is currently being reviewed, updating data that you cannot access, sending a malformed message, and so on.

For `Pinnacle Validation Error` inspect the `error` payload to determine the source of the failure. These errors are likely due to additional validation and business logic checks.

For `Request Validation Error` inspect the `description` and `errors` payload to determine the source of failure. These errors are likely due to invalid payload inside the request.

Content type: `application/json`. Schema: `Request Validation Error | Pinnacle Validation Error`.

- Variant: variant 1
- `description` — `string`. Human-readable summary of validation failures.
- `errors` — `object`. Structured dictionary of issues containing two main sections:
- `errors`: Array of global validation errors not tied to specific fields
- `properties`: Object mapping field names to their specific validation errors, where each field contains an `errors` array
- Variant: variant 2
- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "description": "✖ Invalid input: expected string, received number\n  → at example_field",
  "errors": {
    "errors": [],
    "properties": {
      "example_field": {
        "errors": [
          "Invalid input: expected string, received NaN"
        ]
      }
    }
  }
}
```

### 401

The request lacks valid authentication credentials or the provided credentials are invalid.

Ensure you're including a valid API key in the request headers and that your account has the necessary permissions to access this endpoint.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "Invalid API key."
}
```

### 402

Insufficient credits to complete this request.

This occurs when your account balance is below the required amount for processing the operation.
Please add credits to your account to continue using the service.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "Insufficient credits to complete this request."
}
```

### 403

Your subscription does not include access to this feature.

This occurs when attempting to use functionality that requires a higher subscription tier.
Please upgrade your subscription to access this feature.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "Your subscription does not include access to this feature."
}
```

### 404

The requested resource could not be found.

This may occur if the identifier is incorrect, the resource has been deleted, or you don't have permission to access it.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "The requested resource could not be found."
}
```

### 500

An unexpected error occurred on Pinnacle's servers while processing your request.

If this error persists, please contact support with the request details.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "An unexpected error occurred while processing your request."
}
```

### 501

The requested functionality is not implemented on the server.

This typically indicates that the feature or endpoint you attempted to access is unavailable or not yet supported.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "This feature has not been implemented yet."
}
```

## SDK examples

### TypeScript

```typescript
import { PinnacleClient } from "rcs-js";

const client = new PinnacleClient({
  apiKey: process.env.PINNACLE_API_KEY!,
});

await client.messages.react({
    messageId: "msg_1234567890",
    options: {
        force: true
    },
    reaction: "\uD83D\uDC4D"
});
```

### Python

```python
import os
from rcs import Pinnacle
from rcs.messages import ReactMessageOptions

client = Pinnacle(
    api_key=os.environ["PINNACLE_API_KEY"],
)

client.messages.react(
    message_id="msg_1234567890",
    options=ReactMessageOptions(
        force=True,
    ),
    reaction="👍",
)
```

### Ruby

```ruby
require "rcs"

client = Pinnacle::Client.new(
  api_key: ENV.fetch("PINNACLE_API_KEY")
)

client.messages.react(
  message_id: "msg_1234567890",
  options: {
    force: true
  },
  reaction: "👍"
)
```

## Machine-readable schema

[OpenAPI 3.1 JSON](https://docs.pinnacle.sh/openapi.json)
