---
updatedAt: 2025-11-20T08:08:09.000Z
agentTools:
  projectIndex: https://partner-docs.gupshup.io/llms.txt
---

# Template Comparison API

Use this API to compare templates. This endpoint allows you to analyze and compare the performance of multiple WhatsApp message templates side by side, providing insights into metrics like block rate, message sends, and block reasons.

> 📘 Note
>
> 1. The API needs at least **1,000 messages** sent per template in the given time frame to work
> 2. The difference between the start and end timestamps must be **exactly** 604800 (7 days), 2592000 (30 days), 5184000 (60 days), or 7776000 (90 days) seconds.
> 3. All templates must be in **approved** status.
> 4. You must be the **owner** of all templates being compared.
> 5. Rate limit: **10 requests per hour** (3600 seconds).
> 6. **Common Use Cases:**
>    * A/B testing to determine which template variant performs better.
>    * Template optimization to identify templates needing improvement.
>    * Quality monitoring to track template quality over time.
>    * Campaign planning to choose best-performing templates

## Request Parameters

| Key              | Description                                                      | Constraints                                             |
| :--------------- | :--------------------------------------------------------------- | :------------------------------------------------------ |
| Authorization    | Access Token for the application                                 | Should be a valid Partner App Access Token              |
| appId            | AppId of the app for which the embed link needs to be generated. | Should be a valid appId associated with the account.    |
| gsTemplateId Id  | ID of the WhatsApp Message Template to target.                   | Should be a valid template ID                           |
| template\_ids    | Array of template Ids to compare.                                | The array should contain exactly one valid template id. |
| start\_timestamp | Start time                                                       | start time is in **seconds** in long form               |
| end\_timestamp   | End time                                                         | end time is in **seconds** in long form                 |

## Sample Request

```curl
curl --location --request GET 'https://partner.gupshup.io/partner/app/3c7a7716-e731-45db-9478-f93fb011af7d/template/analytics/88dcc6a4-deb7-4785-9ce5-f8c6fa09b745/compare?templateList=c0222c17-7d49-49c6-ab1c-f0be0796fb77&end=1717113600&start=1709337600' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}'
```

## Sample Response

```
{
    "data": [
        {
            "metric": "BLOCK_RATE",
            "order_by_relative_metric": [ {{list_of_gs_templateId}} ],
            "type": "RELATIVE"
        },
        {
            "metric": "MESSAGE_SENDS",
            "number_values": [
                {
                    "key": "{{gs_template_id_1}}",
                    "value": {{Number_of_messages_sent}}
                },
                {
                    "key": "{{gs_template_id_2}}",
                    "value": {{Number_of_messages_sent}}
                }
            ],
            "type": "NUMBER_VALUES"
        },
        {
            "metric": "TOP_BLOCK_REASON",
            "string_values": [
                {
                    "key": "{{gs_template_id}}",
                    "value": "{{block_reason}}"
                },
                {
                    "key": "{{gs_template_id}}",
                    "value": "{{block_reason}}"
                }
            ],
            "type": "STRING_VALUES"
        }
    ],
    "status": "success"
}
```

## Status Code

| Status Code | Response                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Comment                                                                                                      |
| :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------- |
| **Success** |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |                                                                                                              |
| 200         | `{       "data": \[           {               "metric": "BLOCK_RATE",               "order_by_relative_metric": [ {{list_of_gs_templateId}} ],               "type": "RELATIVE"           },           {               "metric": "MESSAGE_SENDS",               "number_values": [                   {                       "key": "{{gs_template_id_1}}",                       "value": {{Number_of_messages_sent}}                   },                   {                       "key": "{{gs_template_id_2}}",                       "value": {{Number_of_messages_sent}}                   }               ],               "type": "NUMBER_VALUES"           },           {               "metric": "TOP_BLOCK_REASON",               "string_values": [                   {                       "key": "{{gs_template_id}}",                       "value": "{{block_reason}}"                   },                   {                       "key": "{{gs_template_id}}",                       "value": "{{block_reason}}"                   }               ],               "type": "STRING_VALUES"           }       ],       "status": "success"   }` | The speed\_processed may not be the same as the one sent in the request as it depends on the payment gateway |
| **Error**   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |                                                                                                              |
| 400         | `{           "status": "error",           "message": "Authentication Failed"   }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                              |
| 400         | `{       "status": "error",       "message": "Invalid parameter - Templates not eligible for comparison, Templates must have been sent at least 1,000 times in the specified time frame."   }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |                                                                                                              |
| 400         | `{     "status": "error",     "message": "(#100) The parameter template_ids is required. - null, null" }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |                                                                                                              |
| 400         | `{       "message": "The difference between start and end times should be the number of seconds in 604800(7 days), 2592000(30 days), 5184000(60 days), 7776000(90 days).",       "status": "error"   }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                              |
| 400         | `{       "message": "One or more templates in the list is not approved.",       "status": "error"   }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |                                                                                                              |
| 400         | `{       "message": "The parameter start_timestamp should be less than end_timestamp.",       "status": "error"   }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |                                                                                                              |
| 400         | `{ "message": "Not Template Owner", "status": "error" }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |                                                                                                              |
| 429         | `{     "status": "error",     "message": "Too Many Requests"   }`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | When request rate limit exceeds.                                                                             |

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Partner Release 8.5 Apis",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://partner.gupshup.io"
    }
  ],
  "tags": [
    {
      "name": "Template Comparison"
    }
  ],
  "paths": {
    "/partner/app/{appId}/template/analytics/{templateId}/compare": {
      "get": {
        "tags": [
          "Template Comparison"
        ],
        "summary": "Template Comparison API",
        "description": "Using this api you can compare templates",
        "parameters": [
          {
            "name": "token",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Your app token, please refer [**Get access token api**](https://docs.gupshup.io/reference/get_partner-app-appid-token) to get the token from partner documentation.",
            "example": "sk_61b3021c97214370b341f8baaae0xxxx",
            "required": true
          },
          {
            "name": "templateList",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "example": "0aaba456-6f57-4f63-b9c8-c7b6efc5xxxx",
            "required": true
          },
          {
            "name": "end",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": "1719964800",
            "required": true
          },
          {
            "name": "start",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "example": "1712188800",
            "required": true
          },
          {
            "name": "appId",
            "in": "path",
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "Unique identifier of the app.",
            "example": "9e97650d-xxxx-xxxx-xxxx-4cdf47c3fa68"
          },
          {
            "name": "templateId",
            "in": "path",
            "schema": {
              "type": "string"
            },
            "required": true,
            "example": "73c7e112-ef66-41eb-b4c1-0fb5d85526d2"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "metric": {
                            "type": "string",
                            "example": "BLOCK_RATE"
                          },
                          "order_by_relative_metric": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "eb955f0b-837c-4b2f-a761-a0d71c3b8a0e"
                            },
                            "example": [
                              "eb955f0b-837c-4b2f-a761-a0d71c3b8a0e"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "example": "RELATIVE"
                          },
                          "number_values": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "key": {
                                  "type": "string",
                                  "example": "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6"
                                },
                                "value": {
                                  "type": "integer",
                                  "format": "int32",
                                  "example": "1116"
                                }
                              }
                            },
                            "example": [
                              {
                                "key": "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6",
                                "value": 1116
                              }
                            ]
                          },
                          "string_values": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "key": {
                                  "type": "string",
                                  "example": "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6"
                                },
                                "value": {
                                  "type": "string",
                                  "example": "UNKNOWN_BLOCK_REASON"
                                }
                              }
                            },
                            "example": [
                              {
                                "key": "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6",
                                "value": "UNKNOWN_BLOCK_REASON"
                              }
                            ]
                          }
                        }
                      },
                      "example": [
                        {
                          "metric": "BLOCK_RATE",
                          "order_by_relative_metric": [
                            "eb955f0b-837c-4b2f-a761-a0d71c3b8a0e",
                            "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6"
                          ],
                          "type": "RELATIVE"
                        },
                        {
                          "metric": "MESSAGE_SENDS",
                          "number_values": [
                            {
                              "key": "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6",
                              "value": 1116
                            },
                            {
                              "key": "eb955f0b-837c-4b2f-a761-a0d71c3b8a0e",
                              "value": 1666
                            }
                          ],
                          "type": "NUMBER_VALUES"
                        },
                        {
                          "metric": "TOP_BLOCK_REASON",
                          "string_values": [
                            {
                              "key": "7ee65d64-a3d5-49a5-9e05-0a75d5f7f8f6",
                              "value": "UNKNOWN_BLOCK_REASON"
                            },
                            {
                              "key": "eb955f0b-837c-4b2f-a761-a0d71c3b8a0e",
                              "value": "UNKNOWN_BLOCK_REASON"
                            }
                          ],
                          "type": "STRING_VALUES"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template_comparision_bad_request1"
                }
              },
              "application/json ": {
                "schema": {
                  "$ref": "#/components/schemas/Template_comparision_bad_request2"
                }
              },
              "application/json  ": {
                "schema": {
                  "$ref": "#/components/schemas/Template_comparision_bad_request3"
                }
              },
              "application/json   ": {
                "schema": {
                  "$ref": "#/components/schemas/Template_comparision_bad_request4"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "You do not have the required permissions to access this API"
                    },
                    "status": {
                      "type": "integer",
                      "example": 403
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Internal server error. Please try again later and If Issue still persist than contact Gupshup Dev Support"
                    },
                    "status": {
                      "type": "integer",
                      "example": 500
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Template_comparision_bad_request1": {
        "title": "Not Template Owner",
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "error"
          },
          "message": {
            "type": "string",
            "example": "Not Template Owner"
          }
        }
      },
      "Template_comparision_bad_request2": {
        "title": "The parameter start_timestamp should be less than end_timestamp",
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "error"
          },
          "message": {
            "type": "string",
            "example": "The parameter start_timestamp should be less than end_timestamp."
          }
        }
      },
      "Template_comparision_bad_request3": {
        "title": "The difference between start and end times should be the number of seconds in 7, 30, 60 or 90 days",
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "error"
          },
          "message": {
            "type": "string",
            "example": "The difference between start and end times should be the number of seconds in 7, 30, 60 or 90 days."
          }
        }
      },
      "Template_comparision_bad_request4": {
        "title": "One or more templates in the list is not approved",
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "error"
          },
          "message": {
            "type": "string",
            "example": "One or more templates in the list is not approved."
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```