# Operations and Message Tracking

## What is an Operation?

An Operation represents a request that creates more than one resource, such as sending a message to multiple recipients. When you submit the request, the Communications API validates the input and returns an HTTP `202 Accepted` response that includes an `operationId` header. Use the `operationId` value to monitor the status and progress of the Operation.

As the Operation is processed, it generates a Message with an associated `messageId` (different from a typical message SID) for each recipient. Each Message then creates at least one SM/MM message SID, one for each channel that we attempt.

![A flowchart showing Twilio message delivery with RCS attempts and SMS/WhatsApp fallbacks.](https://docs-resources.prod.twilio.com/ed32c95bc03a1ef479569a6f955f8e1b559348d3d8f5b68a056fae0afdec38a4.png)

You can associate every delivery attempt (each try to send a message to a recipient over a specific channel) with its parent Message and Operation resource by using the `messageId` and `operationId` values included in each status callback event.

## Retrieve the Operation

You can make a `GET` request with the Operation ID to retrieve its status.

```bash
curl -X GET 'https://comms.twilio.com/preview/Messages/Operations/{operationId}' \
--header 'Content-Type: application/json' \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

**Sample response**:

```json
{
   "id": "comms_operation_01h2xcejqtf2nbrexx3vqjhp41",
   "status": "COMPLETED",
   "stats": {
       "total": 1,
       "recipients": 1,
       "attempts": 1,
       "unaddressable": 0,
       "queued": 0,
       "sent": 0,
       "scheduled": 0,
       "delivered": 1,
       "read": 0,
       "undelivered": 0,
       "failed": 0,
       "canceled": 0
   },
   "createdAt": "2024-04-05T06:20:00Z",
   "updatedAt": "2024-04-05T06:20:00Z"
}
```

See the [Message Operation API reference](/docs/api/comms/preview/Messages#fetch-message-operation).

## Retrieve the Messages created by an Operation

You can also use the List Message endpoint to retrieve the Message resources that an Operation created.

```bash
curl -X GET 'https://comms.twilio.com/preview/Messages?operation_id={operation_id}' \
--header 'Content-Type: application/json' \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

**Sample response**:

```json
{
   "messages": [
       {
           "id": "comms_message_01h2xcejqtf2nbrexx3vqjhp41",
           "from": {
               "address": "+12065558844",
               "channel": "WHATSAPP",
               "senderId": "comms_sender_01h9krwprkeee8fzqspvwy6nq8"
           },
           "to": [
               {
                   "address": "+14153901002",
                   "channel": "PHONE",
                   "contactId": "comms_contact_01h9krwprkeee8fzqspvwy6nq7"
               }
           ],
           "status": "SENT",
           "related": [
               {
                   "name": "operation",
                   "id": "comms_operation_01h2xcejqtf2nbrexx3vqjhp41",
                   "uri": "/Messages/Operations/01h2xcejqtf2nbrexx3vqjhp41"
               }
           ],
           "tags": {},
           "scheduledFor": null,
           "createdAt": "2023-08-24T14:15:22Z",
           "updatedAt": "2023-08-24T14:15:22Z",
           "deletedAt": null
       }
   ],
   "pagination": {
       "next": null,
       "self": "https://comms.twilio.com/preview/Messages"
   }
}
```

For more details, see the [List Messages API reference](/docs/api/comms/preview/Messages#list-messages).

## Next steps

See the [Personalization guide](./comms/personalization) to learn how to personalize messages for each recipient.
