> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/whiskeysockets/Baileys/llms.txt
> Use this file to discover all available pages before exploring further.

# Disappearing Messages

> Enable disappearing messages in chats and send ephemeral messages that auto-delete after a specified time using Baileys

## Overview

Disappearing messages automatically delete after a set period. You can enable this feature for entire chats or send individual messages that disappear.

## Ephemeral Durations

Supported time periods for disappearing messages:

| Time   | Seconds   |
| ------ | --------- |
| Remove | 0         |
| 24h    | 86,400    |
| 7d     | 604,800   |
| 90d    | 7,776,000 |

<Info>
  You need to pass in **seconds**, not milliseconds. The default is 7 days.
</Info>

## WA\_DEFAULT\_EPHEMERAL Constant

Baileys provides a constant for the default 7-day duration:

```ts theme={null}
import { WA_DEFAULT_EPHEMERAL } from '@whiskeysockets/baileys'

// WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60 = 604,800 seconds
```

Defined in `src/Defaults/index.ts:23`:

```ts theme={null}
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
```

## Enable Disappearing Messages in a Chat

Turn on disappearing messages for all future messages in a chat:

```ts theme={null}
// Turn on disappearing messages (7 days)
await sock.sendMessage(
    jid,
    { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
)
```

### Custom Duration

```ts theme={null}
// 24 hours
await sock.sendMessage(
    jid,
    { disappearingMessagesInChat: 86400 }
)

// 90 days  
await sock.sendMessage(
    jid,
    { disappearingMessagesInChat: 7776000 }
)
```

## Disable Disappearing Messages

Turn off disappearing messages in a chat:

```ts theme={null}
await sock.sendMessage(
    jid,
    { disappearingMessagesInChat: false }
)
```

<Note>
  This only affects future messages. Previously sent disappearing messages will still delete at their scheduled time.
</Note>

## Send Individual Disappearing Messages

Send a single message that will disappear without enabling the feature for the entire chat:

```ts theme={null}
// Send a disappearing text message (7 days)
await sock.sendMessage(
    jid, 
    { text: 'hello' }, 
    { ephemeralExpiration: WA_DEFAULT_EPHEMERAL }
)
```

### Custom Expiration

```ts theme={null}
// Send a message that disappears after 24 hours
await sock.sendMessage(
    jid,
    { text: 'This message will disappear in 24 hours' },
    { ephemeralExpiration: 86400 }
)

// Send media with disappearing
await sock.sendMessage(
    jid,
    { 
        image: { url: './image.jpg' },
        caption: 'Disappearing image'
    },
    { ephemeralExpiration: WA_DEFAULT_EPHEMERAL }
)
```

## Complete Example

```ts theme={null}
import { makeWASocket, WA_DEFAULT_EPHEMERAL } from '@whiskeysockets/baileys'

const sock = makeWASocket({ /* config */ })
const jid = '1234567890@s.whatsapp.net'

// Enable disappearing messages for the chat (7 days)
await sock.sendMessage(jid, {
    disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL
})

// Send a regular message (will disappear after 7 days)
await sock.sendMessage(jid, { text: 'This will disappear' })

// Send a one-time disappearing message (24 hours)
await sock.sendMessage(
    jid,
    { text: 'Custom expiration' },
    { ephemeralExpiration: 86400 }
)

// Disable disappearing messages
await sock.sendMessage(jid, {
    disappearingMessagesInChat: false
})

// Future messages won't disappear
await sock.sendMessage(jid, { text: 'This is permanent' })
```

## Update Default Disappearing Mode

Set a default disappearing message duration for all new chats:

```ts theme={null}
// Set default to 24 hours for new chats
await sock.updateDefaultDisappearingMode(86400)

// Disable default disappearing mode
await sock.updateDefaultDisappearingMode(0)
```

<Tip>
  See [Privacy Settings](/privacy/privacy-settings#update-default-disappearing-mode) for more details on default disappearing mode.
</Tip>

## Implementation Details

From `src/Utils/messages.ts:465` and `src/Utils/messages.ts:717`:

```ts theme={null}
// When enabling for chat
if (content.disappearingMessagesInChat !== undefined) {
    // Sets chat-level ephemeral setting
    // Uses WA_DEFAULT_EPHEMERAL if true
}

// When sending individual message
if (options.ephemeralExpiration) {
    message.ephemeralMessage = {
        message: message,
        expiration: options.ephemeralExpiration || WA_DEFAULT_EPHEMERAL
    }
}
```

<Warning>
  * Disappearing messages can still be saved by recipients through screenshots or forwarding before deletion
  * The timer starts when the message is read, not when it's sent
  * Media files are deleted from WhatsApp servers when messages expire
</Warning>

## Time Conversion Helper

```ts theme={null}
// Helper function to convert days/hours to seconds
const toSeconds = {
    hours: (h: number) => h * 60 * 60,
    days: (d: number) => d * 24 * 60 * 60
}

// Usage
await sock.sendMessage(jid, 
    { text: 'Disappears in 1 day' },
    { ephemeralExpiration: toSeconds.days(1) }
)
```
