SuperAPI AI 工具集

telnyx-account-notifications-javascript

办公与效率

查看项目

更新于 10-16 04:50

技能介绍

Telnyx Account Notifications - JavaScript 是一个面向 Telnyx 平台的技能资料,主题是配置账户告警与事件的通知渠道和设置,并提供 JavaScript SDK 示例。

用途 该技能用于在 JavaScript 项目中通过 Telnyx SDK 管理账户通知相关资源,包括通知渠道、通知事件、通知事件条件、通知配置文件以及通知设置。

安装与初始化 安装命令为:npm install telnyx。使用前需按示例初始化客户端:import Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'] }); 其中 apiKey 为默认参数,可省略。以下所有示例均假设 client 已按此方式初始化。

主要能力 资料列出的接口能力包括:列出通知渠道(GET /notification_channels)、创建通知渠道(POST /notification_channels)、获取单个通知渠道(GET /notification_channels/{id})、更新通知渠道(PATCH /notification_channels/{id})、删除通知渠道(DELETE /notification_channels/{id});列出全部通知事件条件(GET /notification_event_conditions);列出全部通知事件(GET /notification_events);列出全部通知配置文件(GET /notification_profiles)、创建通知配置文件、获取、更新与删除通知配置文件;列出通知设置(GET /notification_settings)、添加通知设置(POST /notification_settings)、获取单个通知设置、删除通知设置。通知渠道类型枚举为 sms、voice、email、webhook。通知设置状态枚举包括 enabled、enable-received、enable-pending、enable-submitted、delete-received、delete-pending、delete-submitted、deleted。

使用方式 通过 client.notificationChannels、client.notificationEventConditions、client.notificationEvents、client.notificationProfiles、client.notificationSettings 等资源对象调用对应方法。创建通知渠道示例中传入 channelTypeId(如 'webhook')与 channelDestination(如 'https://example.com/webhooks')。创建通知配置文件示例中传入 name。列表方法返回自动分页迭代器,可用 for await (const item of result) 自动遍历所有页。

错误处理 资料建议生产代码始终处理错误。示例区分了 Telnyx.APIConnectionError(网络错误,检查连通性并重试)、Telnyx.RateLimitError(429 限流,按 retry-after 头等待并以指数退避重试)、Telnyx.APIError(如 422 校验错误,检查必填字段与格式)。常见错误码包括 401 API Key 无效、403 权限不足、404 资源不存在、422 校验错误、429 限流。

返回字段 通知渠道返回 channel_destination、channel_type_id、created_at、id、notification_profile_id、updated_at。通知事件条件返回 allow_multiple_channels、associated_record_type(枚举 account、phone_number)、asynchronous、created_at、description、enabled、id、name、notification_event_id、parameters、supported_channels、updated_at。通知事件返回 created_at、enabled、id、name、notification_category、updated_at。通知配置文件返回 created_at、id、name、updated_at。通知设置返回 associated_record_type、associated_record_type_value、created_at、id、notification_channel_id、notification_event_condition_id、notification_profile_id、parameters、status、updated_at。

适用场景与限制 适用于需要在 JavaScript 环境中集成 Telnyx 账户通知配置能力的开发者。资料未提供收费、价格、平台适用范围或效果等信息,暂未提供。