Skip to content

Gateways API

Gateways are communication channels that allow users to interact with agents via external platforms (Telegram, Email, WhatsApp, etc.).

Endpoints

MethodEndpointDescription
GET/api/agents/{id}/gatewaysList gateways
POST/api/agents/{id}/gatewaysCreate gateway
GET/api/agents/{id}/gateways/{gatewayId}Get gateway
PUT/api/agents/{id}/gateways/{gatewayId}Update gateway
DELETE/api/agents/{id}/gateways/{gatewayId}Delete gateway
POST/api/agents/{id}/gateways/{gatewayId}/verifyVerify credentials
POST/api/agents/{id}/gateways/{gatewayId}/webhook/registerRegister webhook
POST/api/agents/{id}/gateways/{gatewayId}/webhookIncoming webhook

List Gateways

bash
GET /api/agents/{id}/gateways

Response

json
{
  "gateways": [
    {
      "id": "gateway-123",
      "type": "telegram",
      "name": "Support Bot",
      "status": "active",
      "is_default": true,
      "verified": true,
      "event_count": 1523,
      "last_event_at": "2025-01-20T10:30:00Z",
      "webhook_url": "/api/agents/{agentId}/gateways/{gatewayId}/webhook"
    }
  ]
}

Create Gateway

bash
POST /api/agents/{id}/gateways
Content-Type: application/json

Request Body

json
{
  "type": "telegram",
  "name": "Support Bot",
  "config": {
    "botToken": "123456:ABC..."
  },
  "is_default": true
}

Response

json
{
  "id": "gateway-123",
  "type": "telegram",
  "name": "Support Bot",
  "status": "inactive",
  "webhook_url": "/api/agents/agent-1/gateways/gateway-123/webhook",
  "webhook_secret": "generated-secret-token"
}

Verify Credentials

Verify gateway credentials before activating.

bash
POST /api/agents/{id}/gateways/{gatewayId}/verify

Response (Telegram)

json
{
  "success": true,
  "info": {
    "id": 123456789,
    "username": "my_support_bot",
    "firstName": "Support Bot"
  }
}

Register Webhook

Register the webhook URL with the external platform.

bash
POST /api/agents/{id}/gateways/{gatewayId}/webhook/register

Request Body (optional)

json
{
  "baseUrl": "https://custom-domain.com"
}

Response

json
{
  "success": true,
  "webhookUrl": "https://manage.uranus.im/api/agents/agent-1/gateways/gateway-123/webhook"
}

Gateway Types

TypeDescriptionConfig Fields
telegramTelegram BotbotToken
emailEmail (Resend/MailChannels)provider, fromAddress, fromName, apiKey
whatsappWhatsApp Businessprovider, phoneNumber, accountSid, authToken
slackSlack AppbotToken, signingSecret
discordDiscord BotbotToken, applicationId, publicKey
smsSMS via TwilioaccountSid, authToken, phoneNumber
webhookCustom webhookurl, secret, headers

Platform-Specific Configuration

Telegram

json
{
  "type": "telegram",
  "config": {
    "botToken": "123456:ABC-DEF...",
    "webhookSecret": "optional-verification-token"
  }
}

Email (Resend)

json
{
  "type": "email",
  "config": {
    "provider": "resend",
    "fromAddress": "[email protected]",
    "fromName": "Support Team",
    "apiKey": "re_..."
  }
}

Email (MailChannels)

json
{
  "type": "email",
  "config": {
    "provider": "mailchannels",
    "fromAddress": "[email protected]",
    "fromName": "Support Team"
  }
}

WhatsApp (Twilio)

json
{
  "type": "whatsapp",
  "config": {
    "provider": "twilio",
    "phoneNumber": "+1234567890",
    "accountSid": "AC...",
    "authToken": "..."
  }
}

Slack

json
{
  "type": "slack",
  "config": {
    "botToken": "xoxb-...",
    "signingSecret": "..."
  }
}

Webhook URL Structure

Each gateway gets a unique webhook URL:

/api/agents/{agentId}/gateways/{gatewayId}/webhook

This URL should be registered with the external platform (e.g., Telegram's setWebhook).

Event Tracking

Gateways track incoming events:

FieldDescription
event_countTotal events received
events_todayEvents received today
last_event_atTimestamp of last event
last_errorLast error message
last_error_atTimestamp of last error

Gateway Status

StatusDescription
inactiveNot yet configured/verified
pending_verificationAwaiting credential verification
activeVerified and receiving events
errorConfiguration error