# Retrieve Batch

{% hint style="danger" %}
We will be updating our response payload to include a `creatorId` field from **24 Feb 2025**. Please read the last section to find out where the amendment is and update your own systems if necessary, **before 24 Feb 2025.**
{% endhint %}

Retrieves messages and their delivery statuses given a batch ID. Please refer to this table in [possible message statuses](/endpoints-for-api-users/the-message-object.md#lateststatus-string) and what they mean on what each message status means.

{% code title="Endpoint #6" %}

```sh
GET /campaigns/:campaignId/batch/:batchId/messages
```

{% endcode %}

### Supported Query Parameters

#### `limit` string (Mandatory)

You can specify the number of messages to return per page using the `limit` query parameter. The minimum value is 1, and the maximum value is 1000.

#### `after` string (Optional)

Find messages after the cursorId

#### `before` string (Optional)

Find messages before the cursorId

#### `search` string (Optional)

This supports searching by recipient phone number only.

It is a substring match, eg. a "11" would match with "91122233"

**\[Now to 26 Jan 2025] Example response body**

{% code title="Example response body" overflow="wrap" %}

```json
{
    "data": [
        {
            "createdAt": "2024-05-16T16:34:06.582+08:00",
            "updatedAt": "2024-05-16T16:35:13.122+08:00",
            "id": "<YOUR_MESSAGE_ID>",
            "recipient": "6522222222",
            "values": {
                "body": "test"
            },
            "fullMessage": "This is a test message used for training purposes.\n\nOpen Government Products\n\n---\n\ntest\n\n---\n\nThis is an automated message sent by the Singapore Government.",
            "latestStatus": "failure",
            "templateBodyId": "<YOUR_GENERATED_TEMPLATE_ID>",
            "campaignId": "<YOUR_GENERATED_CAMPAIGN_ID>",
            "templateBody": {
                "createdAt": "2024-05-06T11:00:03.467+08:00",
                "updatedAt": "2024-05-06T11:00:03.467+08:00",
                "id": "<YOUR_GENERATED_TEMPLATE_BODY_ID>",
                "templateId": "<YOUR_GENERATED_TEMPLATE_ID>",
                "language": "english",
                "body": "{{body}}",
                "creatorId": "<YOUR_GENERATED_CREATOR_ID>"
            },
            "messageAttempts": [
                {
                    "sentAt": "2024-05-16T16:35:13.118+08:00",
                    "deliveredAt": null,
                    "createdAt": "2024-05-16T16:34:06.604+08:00",
                    "updatedAt": "2024-05-16T16:35:13.118+08:00",
                    "id": "<YOUR_GENERATED_MESSAGE_ATTEMPT_ID>",
                    "messageId": "<YOUR_GENERATED_MESSAGE_ID>",
                    "externalAttemptId": "",
                    "status": "failure",
                    "errorType": "server_error",
                    "errorCode": "server_unknown_error",
                    "metadata": {},
                    "creatorId": "<YOUR_GENERATED_CREATOR_ID>",
                    "creator": {
                        "email": "<YOUR_GENERATED_CAMAPIGN_CREATOR_EMAIL>"
                    }
                }
            ],
            "language": "english",
            "creatorEmail": "<YOUR_GENERATED_CAMPAIGN_CREATOR_EMAIL>",
            "numAttempts": 1
        },
        {
            "createdAt": "2024-05-16T16:34:06.582+08:00",
            "updatedAt": "2024-05-16T16:35:13.093+08:00",
            "id": "<YOUR_GENERATED_MESSAGE_ID>",
            "recipient": "6511119999",
            "values": {
                "body": "test"
            },
            "fullMessage": "This is a test message used for training purposes.\n\nOpen Government Products\n\n---\n\ntest\n\n---\n\nThis is an automated message sent by the Singapore Government.",
            "latestStatus": "failure",
            "templateBodyId": "<YOUR_GENERATED_TEMPLATE_ID>",
            "campaignId": "<YOUR_GENERATED_CAMPAIGN_ID>",
            "templateBody": {
                "createdAt": "2024-05-06T11:00:03.467+08:00",
                "updatedAt": "2024-05-06T11:00:03.467+08:00",
                "id": "<YOUR_GENERATED_TEMPLATE_BODY_ID>",
                "templateId": "<YOUR_GENERATED_TEMPLATE_ID>",
                "language": "english",
                "body": "{{body}}",
                "creatorId": "<YOUR_GENERATED_CREATOR_ID>"
            },
            "messageAttempts": [
                {
                    "sentAt": "2024-05-16T16:35:13.089+08:00",
                    "deliveredAt": null,
                    "createdAt": "2024-05-16T16:34:06.604+08:00",
                    "updatedAt": "2024-05-16T16:35:13.090+08:00",
                    "id": "<YOUR_GENERATED_MESSAGE_ATTEMPT_ID>",
                    "messageId": "<YOUR_GENERATED_MESSAGE_ID>",
                    "externalAttemptId": "",
                    "status": "failure",
                    "errorType": "delivery_error",
                    "errorCode": "delivery_unknown_error",
                    "metadata": {},
                    "creatorId": "<YOUR_GENERATED_CREATOR_ID>",
                    "creator": {
                        "email": "<YOUR_GENERATED_CAMAPIGN_CREATOR_EMAIL>"
                    }
                }
            ],
            "language": "english",
            "creatorEmail": <YOUR_GENERATED_CAMAPIGN_CREATOR_EMAIL>,
            "numAttempts": 1
        },
        {
            "createdAt": "2024-05-16T16:34:06.582+08:00",
            "updatedAt": "2024-05-16T16:36:05.595+08:00",
            "id": <YOUR_GENERATED_MESSAGE_ID>,
            "recipient": "6599999999",
            "values": {
                "body": "test"
            },
            "fullMessage": "This is a test message used for training purposes.\n\nOpen Government Products\n\n---\n\ntest\n\n---\n\nThis is an automated message sent by the Singapore Government.",
            "latestStatus": "success",
            "templateBodyId": "<YOUR_GENERATED_TEMPLATE_ID>",
            "campaignId": "<YOUR_GENERATED_CAMPAIGN_ID>",
            "templateBody": {
                "createdAt": "2024-05-06T11:00:03.467+08:00",
                "updatedAt": "2024-05-06T11:00:03.467+08:00",
                "id": "<YOUR_GENERATED_TEMPLATE_BODY_ID>",
                "templateId": "<YOUR_GENERATED_TEMPLATE_ID>",
                "language": "english",
                "body": "{{body}}",
                "creatorId": "<YOUR_GENERATED_CREATOR_ID>"
            },
            "messageAttempts": [
                {
                    "sentAt": "2024-05-16T16:35:43.009+08:00",
                    "deliveredAt": null,
                    "createdAt": "2024-05-16T16:34:06.604+08:00",
                    "updatedAt": "2024-05-16T16:36:05.593+08:00",
                    "id": "<YOUR_GENERATED_MESSAGE_ATTEMPT_ID>",
                    "messageId": "<YOUR_GENERATED_MESSAGE_ID>",
                    "externalAttemptId": "<YOUR_GENERATED_EXTERNAL_ATTEMPT_ID>",
                    "status": "success",
                    "errorType": null,
                    "errorCode": null,
                    "metadata": {},
                    "creatorId": "<YOUR_GENERATED_CREATOR_ID>",
                    "creator": {
                        "email": "<YOUR_GENERATED_CAMAPIGN_CREATOR_EMAIL>"
                    }
                }
            ],
            "language": "english",
            "creatorEmail": <YOUR_GENERATED_CAMAPIGN_CREATOR_EMAIL>,
            "numAttempts": 1
        }
    ],
    "pageData": {
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": "WyIyMDI0LTA1LTE2VDE2OjM0OjA2LjU5MCswODowMCIsIjMwMjE5Il0=",
        "endCursor": "WyIyMDI0LTA1LTE2VDE2OjM0OjA2LjU5MCswODowMCIsIjMwMjE3Il0="
    }
}
```

{% endcode %}

**\[From 24 Feb 2025] The `creatorId` field will be inserted in the response payload for each message object from 24 Feb 2025.  In this above example it will be inserted once per message object i.e. total of 3 times. Please amend your own code accordingly for**&#x20;

`"creatorId": "<USER_ID_OF_MESSAGE_CREATOR>"`

<figure><img src="/files/tI8G0cR8PVeadZoQubP5" alt=""><figcaption></figcaption></figure>


---

# 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://postman-v2.guides.gov.sg/endpoints-for-api-users/retrieve-batch.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.
