Skip to content

POST /v1/projects/{id}/platforms/telegram/bots

Starts a free managed Telegram bot connection. Each project may own one current bot and have one unfinished Telegram provision, including user interaction and failure cleanup. A matching Idempotency-Key replays its original operation before either conflict check, even after completion or while a newer setup is active. For a different key, an unfinished provision takes precedence over an existing bot and returns 409 TELEGRAM_PROVISION_IN_PROGRESS with its operationId and operationUrl; resume it, cancel it while cancellation is available, or wait for it to finish. Only when no provision is active does an existing non-retired bot return 409 TELEGRAM_BOT_ALREADY_CONNECTED with its resourceId; disconnect it before connecting another, even if messaging is disabled or disconnect is unfinished. Rejected keys remain reusable. Open detail.setupUrl to create a new bot, whose name and username are chosen in Telegram, or to connect an existing managed bot, then poll Location. The link remains usable while the operation is active and never expires. POST, GET and list share the same operation details. The API includes detail.setupUrl only for callers with platforms:write for the project; read-only callers receive the other details unchanged. If the operation fails, its error is the problem of one of these codes: TELEGRAM_BOT_ALREADY_CONNECTED, TELEGRAM_CONFIGURATION_FAILED.

photon.projects.platforms.connectTelegramBot(input: ConnectTelegramBotInput, options?: RequestOptions): Promise<ConnectTelegramBotOutput>
import { Photon } from "@photon-ai/api";

const photon = new Photon({
  headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.platforms.connectTelegramBot({
  path: {
    id: "id",
  },
  headers: {
    idempotencyKey: "idempotencyKey",
  },
  body: {},
});
{
  "cancellable": true,
  "createdAt": "2026-01-01T00:00:00.000Z",
  "detail": {},
  "endedAt": "2026-01-01T00:00:00.000Z",
  "error": {
    "code": "CHARGE_REFUSED",
    "remediation": {
      "action": "Check the payment method in Billing, then request the purchase again."
    },
    "status": 402,
    "title": "Charge Refused",
    "type": "https://photon.codes/docs/problems/charge-refused"
  },
  "operationId": "string",
  "projectId": "string",
  "reason": "charge_refused",
  "resourceId": "string",
  "resourceType": "string",
  "startedAt": "2026-01-01T00:00:00.000Z",
  "state": "pending",
  "type": "resource.provision",
  "updatedAt": "2026-01-01T00:00:00.000Z"
}

Parameters

Photon-VersionPhotonVersion

Selects the API contract date. Without it, the request is served as 2026-07-01.

Idempotency-Keystringrequired

Identifies one logical mutation across retries.

idstringrequired

Returns

202 Setup accepted. Open detail.setupUrl and poll the operation. Operation

Headers: Location, Photon-Version. The raw response carries these headers; see Raw responses.

cancellablebooleanrequired
createdAtstring (date-time)required
detailobject
endedAtstring (date-time)
errorOperationError

Why the operation failed: the problem of its code, the same object the endpoint returns when it rejects a request, with the status that rejection would have had (the poll itself answers 200). Every code an operation can end with is a branch below, and the endpoint that starts the operation lists its codes. Branch on code, never on status, and keep a default: a code added after your client was generated arrives as a generic problem with type: about:blank and status: 500. That 500 means this document does not describe the code yet, not that the request failed on our side or that retrying will help.

operationIdstringrequired
projectIdstringrequired
reasonOperationReason
resourceIdstring
resourceTypestringrequired
startedAtstring (date-time)
stateOperationStaterequired
typeOperationTyperequired
updatedAtstring (date-time)required