postStory
Publica una historia en nombre de una cuenta empresarial.
Devuelve: Si la llamada tiene éxito, devuelve Story.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
business_connection_id | String | Sí | ID de la conexión empresarial |
content | InputStoryContent | Sí | Objeto JSON InputStoryContent |
active_period | Integer | Sí | Período de actividad en segundos: 21600, 43200, 86400 o 172800 |
caption | String | Opcional | Leyenda (0-2048) |
parse_mode | String | Opcional | HTML, Markdown o MarkdownV2 |
caption_entities | Array of MessageEntity | Opcional | Array JSON de MessageEntity |
areas | Array of StoryArea | Opcional | Array JSON de StoryArea |
post_to_chat_page | Boolean | Opcional | Publicar en la página del chat |
protect_content | Boolean | Opcional | Proteger el contenido |
Ejemplo de solicitud
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/postStory" \
-H "Content-Type: application/json" \
-d '{
"business_connection_id": "BUSINESS_CONNECTION_ID",
"content": {
"type": "photo",
"photo": "attach://photo"
},
"active_period": 86400
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/postStory",
json={
"business_connection_id": "BUSINESS_CONNECTION_ID",
"content": {
"type": "photo",
"photo": "attach://photo"
},
"active_period": 86400
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/postStory`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"business_connection_id": "BUSINESS_CONNECTION_ID",
"content": {
"type": "photo",
"photo": "attach://photo"
},
"active_period": 86400
}),
});
console.log(await res.json());
Guía paso a paso: Cómo crear un bot en Telegram paso a paso: de BotFather a tu primer mensaje
Métodos relacionados
editStoryEdita una historia en nombre de una cuenta empresarial.deleteStoryElimina una historia en nombre de una cuenta empresarial.repostStoryRepublica una historia entre cuentas empresariales (Bot API 9.3).