> ## Documentation Index
> Fetch the complete documentation index at: https://www.dropfans.io/developers/llms.txt
> Use this file to discover all available pages before exploring further.

# PUT /api/external/notifications — Update Telegram notification settings

> An action-dispatch endpoint — the `action` field picks one of three operations:

- Source: https://www.dropfans.io/developers/reference/update-notifications
- Section: API reference
- OpenAPI: https://www.dropfans.io/developers/openapi.json

An action-dispatch endpoint — the `action` field picks one of three operations:

- `save-handle` — store the creator's Telegram @handle (`telegramHandle`, leading @ stripped).
- `disconnect` — clear the personal chat, the group, or both (`type`: "personal" | "group" | "all").
- `add-group` — register a group/channel by chat id (`groupChatId`, e.g. "-100…"). The bot must already be a member: the id is verified against Telegram before saving, and private-chat ids are rejected.

> [!WARNING] This rewrites the creator's live notification settings
> The same fields power the creator's own Dropfans → Telegram sale notifications. Changing them here changes where the creator's notifications go — including notifications your app has nothing to do with. Only call this when the creator explicitly asked for it.

## Authentication

`Authorization: Bearer dpfn_...` — an API key generated in the creator's dashboard (Vault → API Connect). One key = one creator. Missing or invalid keys return 401 `{"error":"Unauthorized","code":"unauthorized"}`.

## Request body (application/json)

| Field | Type | Required | Description |
|---|---|---|---|
| `action` | `save-handle` \\| `disconnect` \\| `add-group` | yes | Which operation to perform. |
| `telegramHandle` | string |  | save-handle only: the @handle (leading @ is stripped). |
| `type` | `personal` \\| `group` \\| `all` |  | disconnect only: what to clear. |
| `groupChatId` | string |  | add-group only: the Telegram chat id of a group/channel the bot is in. |

Example — Save the creator’s handle:

```json
{
  "action": "save-handle",
  "telegramHandle": "valeria_tg"
}
```

Example — Register a notification group:

```json
{
  "action": "add-group",
  "groupChatId": "-1001234567890"
}
```

Example — Disconnect everything:

```json
{
  "action": "disconnect",
  "type": "all"
}
```

## Responses

### 200

Action applied. save-handle echoes `telegramHandle`; add-group echoes `groupName`; disconnect returns `{success:true}` alone.

| Field | Type | Required | Description |
|---|---|---|---|
| `success` | boolean | yes | Always true. |
| `telegramHandle` | string |  | save-handle only: the stored handle (without @). |
| `groupName` | string |  | add-group only: the group’s title as Telegram reports it. |

```json
{
  "success": true,
  "groupName": "Valeria sales"
}
```

## Errors

| Status | Body | When |
|---|---|---|
| 400 | `{"error":"Invalid JSON body"}` | The body is not valid JSON. |
| 400 | `{"error":"telegramHandle is required"}` | save-handle without a handle. |
| 400 | `{"error":"Invalid telegram handle"}` | save-handle with an empty handle after stripping @. |
| 400 | `{"error":"type must be \"personal\", \"group\", or \"all\""}` | disconnect with a bad type. |
| 400 | `{"error":"groupChatId is required"}` | add-group without a chat id. |
| 400 | `{"error":"Could not find this group. Make sure the bot has been added to the group first."}` | Telegram does not know the chat, or the bot is not a member. |
| 400 | `{"error":"This ID belongs to a private chat, not a group or channel."}` | add-group with a personal chat id. |
| 400 | `{"error":"Unknown action"}` | `action` is none of the three. |
| 401 | `{"error":"Unauthorized","code":"unauthorized"}` | Missing or invalid API key. |

## Rate limiting

Per-key fixed windows by tier (Personal 60/min · 5,000/day; approved apps 300/min · 50,000/day; Dropfans-operated integrations exempt). Read the live values from X-RateLimit-Tier, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset and their -Day variants; a 429 carries Retry-After and `{"error":"Rate limit exceeded","code":"rate_limited"}`. See [Rate limits](https://www.dropfans.io/developers/concepts/rate-limits.md).

## Code samples

### curl

```bash
curl -X PUT "https://www.dropfans.io/api/external/notifications" \
  -H "Authorization: Bearer $DROPFANS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "action": "save-handle",
  "telegramHandle": "valeria_tg"
}'
```

### Node

```javascript
const res = await fetch(`https://www.dropfans.io/api/external/notifications`, {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.DROPFANS_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "action": "save-handle",
    "telegramHandle": "valeria_tg"
  }),
});
console.log(await res.json());
```

### Python

```python
import os
import requests

res = requests.put(
    "https://www.dropfans.io/api/external/notifications",
    headers={"Authorization": f"Bearer {os.environ['DROPFANS_API_KEY']}"},
    json={
        "action": "save-handle",
        "telegramHandle": "valeria_tg",
    },
)
print(res.json())
```

## OpenAPI

```json
{
  "method": "PUT",
  "path": "/api/external/notifications",
  "operationId": "updateNotifications",
  "tags": [
    "notifications"
  ],
  "summary": "Update Telegram notification settings",
  "description": "An action-dispatch endpoint — the `action` field picks one of three operations:\n\n- `save-handle` — store the creator's Telegram @handle (`telegramHandle`, leading @ stripped).\n- `disconnect` — clear the personal chat, the group, or both (`type`: \"personal\" | \"group\" | \"all\").\n- `add-group` — register a group/channel by chat id (`groupChatId`, e.g. \"-100…\"). The bot must already be a member: the id is verified against Telegram before saving, and private-chat ids are rejected.\n\n> [!WARNING] This rewrites the creator's live notification settings\n> The same fields power the creator's own Dropfans → Telegram sale notifications. Changing them here changes where the creator's notifications go — including notifications your app has nothing to do with. Only call this when the creator explicitly asked for it.",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "action": {
              "type": "string",
              "description": "Which operation to perform.",
              "enum": [
                "save-handle",
                "disconnect",
                "add-group"
              ]
            },
            "telegramHandle": {
              "type": "string",
              "description": "save-handle only: the @handle (leading @ is stripped).",
              "example": "valeria_tg"
            },
            "type": {
              "type": "string",
              "description": "disconnect only: what to clear.",
              "enum": [
                "personal",
                "group",
                "all"
              ]
            },
            "groupChatId": {
              "type": "string",
              "description": "add-group only: the Telegram chat id of a group/channel the bot is in.",
              "example": "-1001234567890"
            }
          },
          "required": [
            "action"
          ]
        },
        "examples": {
          "saveHandle": {
            "summary": "Save the creator’s handle",
            "value": {
              "action": "save-handle",
              "telegramHandle": "valeria_tg"
            }
          },
          "addGroup": {
            "summary": "Register a notification group",
            "value": {
              "action": "add-group",
              "groupChatId": "-1001234567890"
            }
          },
          "disconnect": {
            "summary": "Disconnect everything",
            "value": {
              "action": "disconnect",
              "type": "all"
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Action applied. save-handle echoes `telegramHandle`; add-group echoes `groupName`; disconnect returns `{success:true}` alone.",
      "headers": {
        "X-RateLimit-Tier": {
          "description": "Rate-limit tier of the key: personal, app or first_party (first_party is unlimited).",
          "schema": {
            "type": "string",
            "enum": [
              "personal",
              "app",
              "first_party"
            ]
          }
        },
        "X-RateLimit-Limit": {
          "description": "Requests allowed per minute for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining": {
          "description": "Requests left in the current minute window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset": {
          "description": "Epoch seconds when the minute window resets.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Limit-Day": {
          "description": "Requests allowed per UTC day for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining-Day": {
          "description": "Requests left in the current UTC day window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset-Day": {
          "description": "Epoch seconds when the day window resets.",
          "schema": {
            "type": "integer"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean",
                "description": "Always true.",
                "example": true
              },
              "telegramHandle": {
                "type": "string",
                "description": "save-handle only: the stored handle (without @)."
              },
              "groupName": {
                "type": "string",
                "description": "add-group only: the group’s title as Telegram reports it."
              }
            },
            "required": [
              "success"
            ]
          },
          "example": {
            "success": true,
            "groupName": "Valeria sales"
          }
        }
      }
    },
    "400": {
      "description": "The body is not valid JSON. Also: save-handle without a handle. Also: save-handle with an empty handle after stripping @. Also: disconnect with a bad type. Also: add-group without a chat id. Also: Telegram does not know the chat, or the bot is not a member. Also: add-group with a personal chat id. Also: `action` is none of the three.",
      "headers": {
        "X-RateLimit-Tier": {
          "description": "Rate-limit tier of the key: personal, app or first_party (first_party is unlimited).",
          "schema": {
            "type": "string",
            "enum": [
              "personal",
              "app",
              "first_party"
            ]
          }
        },
        "X-RateLimit-Limit": {
          "description": "Requests allowed per minute for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining": {
          "description": "Requests left in the current minute window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset": {
          "description": "Epoch seconds when the minute window resets.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Limit-Day": {
          "description": "Requests allowed per UTC day for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining-Day": {
          "description": "Requests left in the current UTC day window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset-Day": {
          "description": "Epoch seconds when the day window resets.",
          "schema": {
            "type": "integer"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Human-readable message describing what went wrong.",
                "example": "Vault item not found"
              }
            },
            "required": [
              "error"
            ]
          },
          "example": {
            "error": "Invalid JSON body"
          }
        }
      }
    },
    "401": {
      "description": "Missing or invalid API key.",
      "headers": {
        "X-RateLimit-Tier": {
          "description": "Rate-limit tier of the key: personal, app or first_party (first_party is unlimited).",
          "schema": {
            "type": "string",
            "enum": [
              "personal",
              "app",
              "first_party"
            ]
          }
        },
        "X-RateLimit-Limit": {
          "description": "Requests allowed per minute for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining": {
          "description": "Requests left in the current minute window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset": {
          "description": "Epoch seconds when the minute window resets.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Limit-Day": {
          "description": "Requests allowed per UTC day for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining-Day": {
          "description": "Requests left in the current UTC day window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset-Day": {
          "description": "Epoch seconds when the day window resets.",
          "schema": {
            "type": "integer"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Human-readable message.",
                "example": "Rate limit exceeded"
              },
              "code": {
                "type": "string",
                "description": "Machine-readable code: unauthorized, app_suspended, first_party_only, rate_limited, username_required.",
                "example": "rate_limited"
              }
            },
            "required": [
              "error",
              "code"
            ]
          },
          "example": {
            "error": "Unauthorized",
            "code": "unauthorized"
          }
        }
      }
    },
    "403": {
      "description": "The app this key belongs to has been suspended by Dropfans. Every request fails with this until the app is reinstated — surface it to the creator and contact Dropfans.",
      "headers": {
        "X-RateLimit-Tier": {
          "description": "Rate-limit tier of the key: personal, app or first_party (first_party is unlimited).",
          "schema": {
            "type": "string",
            "enum": [
              "personal",
              "app",
              "first_party"
            ]
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Human-readable message.",
                "example": "Rate limit exceeded"
              },
              "code": {
                "type": "string",
                "description": "Machine-readable code: unauthorized, app_suspended, first_party_only, rate_limited, username_required.",
                "example": "rate_limited"
              }
            },
            "required": [
              "error",
              "code"
            ]
          },
          "example": {
            "error": "This integration has been suspended by Dropfans. Contact the app developer.",
            "code": "app_suspended"
          }
        }
      }
    },
    "429": {
      "description": "Rate limit exceeded for the current minute or day window. Wait Retry-After seconds and retry.",
      "headers": {
        "X-RateLimit-Tier": {
          "description": "Rate-limit tier of the key: personal, app or first_party (first_party is unlimited).",
          "schema": {
            "type": "string",
            "enum": [
              "personal",
              "app",
              "first_party"
            ]
          }
        },
        "X-RateLimit-Limit": {
          "description": "Requests allowed per minute for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining": {
          "description": "Requests left in the current minute window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset": {
          "description": "Epoch seconds when the minute window resets.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Limit-Day": {
          "description": "Requests allowed per UTC day for this key (absent on first_party).",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Remaining-Day": {
          "description": "Requests left in the current UTC day window.",
          "schema": {
            "type": "integer"
          }
        },
        "X-RateLimit-Reset-Day": {
          "description": "Epoch seconds when the day window resets.",
          "schema": {
            "type": "integer"
          }
        },
        "Retry-After": {
          "description": "Seconds to wait before retrying (sent with 429s).",
          "schema": {
            "type": "integer"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Human-readable message.",
                "example": "Rate limit exceeded"
              },
              "code": {
                "type": "string",
                "description": "Machine-readable code: unauthorized, app_suspended, first_party_only, rate_limited, username_required.",
                "example": "rate_limited"
              }
            },
            "required": [
              "error",
              "code"
            ]
          },
          "example": {
            "error": "Rate limit exceeded",
            "code": "rate_limited"
          }
        }
      }
    }
  },
  "x-codeSamples": [
    {
      "lang": "cURL",
      "label": "curl",
      "source": "curl -X PUT \"https://www.dropfans.io/api/external/notifications\" \\\n  -H \"Authorization: Bearer $DROPFANS_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"action\": \"save-handle\",\n  \"telegramHandle\": \"valeria_tg\"\n}'"
    },
    {
      "lang": "JavaScript",
      "label": "Node",
      "source": "const res = await fetch(`https://www.dropfans.io/api/external/notifications`, {\n  method: 'PUT',\n  headers: {\n    Authorization: `Bearer ${process.env.DROPFANS_API_KEY}`,\n    'Content-Type': 'application/json',\n  },\n  body: JSON.stringify({\n    \"action\": \"save-handle\",\n    \"telegramHandle\": \"valeria_tg\"\n  }),\n});\nconsole.log(await res.json());"
    },
    {
      "lang": "Python",
      "source": "import os\nimport requests\n\nres = requests.put(\n    \"https://www.dropfans.io/api/external/notifications\",\n    headers={\"Authorization\": f\"Bearer {os.environ['DROPFANS_API_KEY']}\"},\n    json={\n        \"action\": \"save-handle\",\n        \"telegramHandle\": \"valeria_tg\",\n    },\n)\nprint(res.json())"
    }
  ],
  "x-dropfans-docs": "https://www.dropfans.io/developers/reference/update-notifications"
}
```

---

Previous: [Read the Telegram notification status](https://www.dropfans.io/developers/reference/get-notifications.md) · Next: [Register the creator’s personal notification chat](https://www.dropfans.io/developers/reference/register-telegram-chat.md) · All pages: [llms.txt](https://www.dropfans.io/developers/llms.txt)
