# Rename

`POST` `https://api.pushwoosh.com/messaging/v2/rename`

Sets or clears the **campaign name** of a previously created message, identified by its `message_code`. Nothing else about the message changes. Content, audience, and schedule stay exactly as they were.

Rename is available only while the message is **pending** — created but not yet picked up for sending. A message that has moved to `waiting`, `processing`, or any later state can no longer be renamed. In the Control Panel this state shows as **Scheduled** in the Status column, not literally "Pending." See [Message statuses](/product/statistics-and-analytics/message-history/#message-statuses).

<Aside type="caution" title="Important">

- The name is trimmed of leading and trailing whitespace and cut to 255 characters. An empty (or whitespace-only) name clears the campaign name entirely, and the message falls back to its default title in [Message History](/product/statistics-and-analytics/message-history/).

- This call is idempotent: sending the same name again reapplies the same value. It still touches the message's last-modified time on every call, whether or not the name actually changed, so a repeated call can move the message to the top of Message History's default **Last modified** sort.
</Aside>

To check whether a message is still in a renamable state, see [Checking message status](#checking-message-status).

## Request

Authenticate with your [Server API token](/developer/api-reference/api-access-token/#server-api-token) in the `Authorization: Token <API_TOKEN>` header.

| Field | Type | Required | Description |
|---|---|---|---|
| `message_code` | string | Yes | [Message code](/developer/api-reference/api-identifiers/#message-code) of the message to rename, as returned by [`Notify`](/developer/api-reference/messaging-api-v2/notify/) in `result.message_code`. |
| `campaign_name` | string | Yes | New campaign name. Trimmed and cut to 255 characters. An empty string clears the name. |

### Example request

```bash
curl -X POST https://api.pushwoosh.com/messaging/v2/rename \
  -H "Authorization: Token YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message_code": "XXXX-XXXXXXXX-XXXXXXXX",
    "campaign_name": "Flash_Sale_Push"
  }'
```

## Response

On success, returns HTTP 200 with an empty JSON body.

```json
{}
```

## Errors

Errors use the standard gRPC-Gateway error envelope: `{ "code": ..., "message": ..., "details": [...] }`.

| HTTP status | Condition |
|---|---|
| `400` | `message_code` is missing. |
| `400` | The message is not in a renamable state (it is no longer `pending`). |
| `403` | The message belongs to another account. |
| `404` | No message exists for the given `message_code`. |
| `500` | An internal error occurred while loading the message or applying the new name. Retry the request. |


**Example**

Renaming a message that has already started sending returns HTTP `400`:

```json
{
  "code": 9,
  "message": "message status \"waiting\" is not renamable",
  "details": []
}
```

## Checking message status

Before renaming, you can verify whether a message is still in a renamable state. Besides reading the **Status** column in the messages table in the Control Panel ([**Campaigns → One-time messages**](/product/statistics-and-analytics/message-history/)), where a renamable message reads **Scheduled** rather than literally "Pending," you can query the status programmatically with [`messages:list`](/developer/api-reference/statistics-api/message-statistics-api/#messageslist):

- Pass the `message_code` in the `filters.messages_codes` array (alongside the required `filters.application`).
- Read the `status` field of the matching entry in `items[]`.

<Aside type="note">
`messages:list` is part of the Statistics API and uses a different auth header than this endpoint: `Authorization: Api <Server Key>`.
</Aside>

## Related

<CardGrid>
  <LinkCard title="Notify" href="/developer/api-reference/messaging-api-v2/notify/" />
  <LinkCard title="Update" href="/developer/api-reference/messaging-api-v2/update/" />
  <LinkCard title="Cancel" href="/developer/api-reference/messaging-api-v2/cancel/" />
  <LinkCard title="Message statistics" href="/developer/api-reference/statistics-api/message-statistics-api/#messageslist" />
  <LinkCard title="Messaging API v2 overview" href="/developer/api-reference/messaging-api-v2/" />
  <LinkCard title="Migration from v1" href="/developer/api-reference/messaging-api-v2/migration-from-v1/" />
</CardGrid>