telnyx-messaging-hosted-curl
ホストされたSMS番号、フリーダイヤルによる認証、RCSメッセージングをセットアップできます。番号の移行またはリッチメッセージング機能を有効にする際に使用します。このスキルではREST API(curl)の例を提供しています。
description の原文を見る
Set up hosted SMS numbers, toll-free verification, and RCS messaging. Use when migrating numbers or enabling rich messaging features. This skill provides REST API (curl) examples.
SKILL.md 本文
Telnyx メッセージング ホステッド - curl
インストール
# curl は macOS、Linux、Windows 10 以降にプリインストールされています
セットアップ
export TELNYX_API_KEY="YOUR_API_KEY_HERE"
以下の例では、認証に $TELNYX_API_KEY を使用しています。
エラーハンドリング
すべての API 呼び出しは、ネットワークエラー、レート制限 (429)、検証エラー (422)、または認証エラー (401) で失敗する可能性があります。本番環境のコードでは必ずエラーを処理してください。
# レスポンスの HTTP ステータスコードを確認します
response=$(curl -s -w "\n%{http_code}" \
-X POST "https://api.telnyx.com/v2/messages" \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+13125550001", "from": "+13125550002", "text": "Hello"}')
http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | sed '$d')
case $http_code in
2*) echo "Success: $body" ;;
422) echo "Validation error — check required fields and formats" ;;
429) echo "Rate limited — retry after delay"; sleep 1 ;;
401) echo "Authentication failed — check TELNYX_API_KEY" ;;
*) echo "Error $http_code: $body" ;;
esac
一般的なエラーコード: 401 は無効な API キー、403 は権限不足、404 はリソースが見つからない、422 は検証エラー (フィールド形式を確認)、429 はレート制限 (指数バックオフで再試行)。
重要な注釈
- 電話番号は E.164 形式である必要があります (例:
+13125550001)。+プレフィックスと国番号を含めてください。スペース、ハイフン、括弧は使用できません。 - ページネーション: リストエンドポイントはページネーション結果を返します。
page[number]とpage[size]クエリパラメータを使用してページをナビゲートします。レスポンスのmeta.total_pagesを確認してください。
RCS メッセージを送信
POST /messages/rcs — 必須: agent_id、to、messaging_profile_id、agent_message
オプション: mms_fallback (オブジェクト)、sms_fallback (オブジェクト)、type (列挙型: RCS)、webhook_url (URL)
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "Agent007",
"to": "+13125551234",
"messaging_profile_id": "550e8400-e29b-41d4-a716-446655440000",
"agent_message": {}
}' \
"https://api.telnyx.com/v2/messages/rcs"
戻り値: body (オブジェクト)、direction (文字列)、encoding (文字列)、from (オブジェクト)、id (文字列)、messaging_profile_id (文字列)、organization_id (文字列)、received_at (日時)、record_type (文字列)、to (オブジェクト配列)、type (文字列)、wait_seconds (浮動小数点数)
RCS ディープリンクを生成
特定のエージェントとの RCS 会話を開始するために使用できるディープリンク URL を生成します。
GET /messages/rcs/deeplinks/{agent_id}
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messages/rcs/deeplinks/{agent_id}?phone_number=%2B18445550001&body=hello%20world"
戻り値: url (文字列)
すべての RCS エージェントをリスト表示
GET /messaging/rcs/agents
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging/rcs/agents"
戻り値: agent_id (文字列)、agent_name (文字列)、created_at (日時)、enabled (ブール値)、profile_id (UUID)、updated_at (日時)、user_id (文字列)、webhook_failover_url (URL)、webhook_url (URL)
RCS エージェントを取得
GET /messaging/rcs/agents/{id}
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging/rcs/agents/550e8400-e29b-41d4-a716-446655440000"
戻り値: agent_id (文字列)、agent_name (文字列)、created_at (日時)、enabled (ブール値)、profile_id (UUID)、updated_at (日時)、user_id (文字列)、webhook_failover_url (URL)、webhook_url (URL)
RCS エージェントを変更
PATCH /messaging/rcs/agents/{id}
オプション: profile_id (UUID)、webhook_failover_url (URL)、webhook_url (URL)
curl \
-X PATCH \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
"https://api.telnyx.com/v2/messaging/rcs/agents/550e8400-e29b-41d4-a716-446655440000"
戻り値: agent_id (文字列)、agent_name (文字列)、created_at (日時)、enabled (ブール値)、profile_id (UUID)、updated_at (日時)、user_id (文字列)、webhook_failover_url (URL)、webhook_url (URL)
RCS 機能をチェック (バッチ)
POST /messaging/rcs/bulk_capabilities — 必須: agent_id、phone_numbers
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "TestAgent",
"phone_numbers": [
"+13125551234"
]
}' \
"https://api.telnyx.com/v2/messaging/rcs/bulk_capabilities"
戻り値: agent_id (文字列)、agent_name (文字列)、features (文字列配列)、phone_number (文字列)、record_type (列挙型: rcs.capabilities)
RCS 機能をチェック
GET /messaging/rcs/capabilities/{agent_id}/{phone_number}
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging/rcs/capabilities/{agent_id}/+13125550001"
戻り値: agent_id (文字列)、agent_name (文字列)、features (文字列配列)、phone_number (文字列)、record_type (列挙型: rcs.capabilities)
RCS テスト番号を追加
RCS エージェントにテスト用の電話番号を追加します。
PUT /messaging/rcs/test_number_invite/{id}/{phone_number}
curl \
-X PUT \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
"https://api.telnyx.com/v2/messaging/rcs/test_number_invite/550e8400-e29b-41d4-a716-446655440000/+13125550001"
戻り値: agent_id (文字列)、phone_number (文字列)、record_type (列挙型: rcs.test_number_invite)、status (文字列)
メッセージング ホステッド番号注文をリスト表示
GET /messaging_hosted_number_orders
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_hosted_number_orders"
戻り値: id (UUID)、messaging_profile_id (文字列 | null)、phone_numbers (オブジェクト配列)、record_type (文字列)、status (列挙型: carrier_rejected、compliance_review_failed、deleted、failed、incomplete_documentation、incorrect_billing_information、ineligible_carrier、loa_file_invalid、loa_file_successful、pending、provisioning、successful)
メッセージング ホステッド番号注文を作成
POST /messaging_hosted_number_orders
オプション: messaging_profile_id (文字列)、phone_numbers (文字列配列)
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
"https://api.telnyx.com/v2/messaging_hosted_number_orders"
戻り値: id (UUID)、messaging_profile_id (文字列 | null)、phone_numbers (オブジェクト配列)、record_type (文字列)、status (列挙型: carrier_rejected、compliance_review_failed、deleted、failed、incomplete_documentation、incorrect_billing_information、ineligible_carrier、loa_file_invalid、loa_file_successful、pending、provisioning、successful)
ホステッド メッセージングの適格性をチェック
POST /messaging_hosted_number_orders/eligibility_numbers_check — 必須: phone_numbers
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone_numbers": [
"+13125550001"
]
}' \
"https://api.telnyx.com/v2/messaging_hosted_number_orders/eligibility_numbers_check"
戻り値: phone_numbers (オブジェクト配列)
メッセージング ホステッド番号注文を取得
GET /messaging_hosted_number_orders/{id}
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_hosted_number_orders/550e8400-e29b-41d4-a716-446655440000"
戻り値: id (UUID)、messaging_profile_id (文字列 | null)、phone_numbers (オブジェクト配列)、record_type (文字列)、status (列挙型: carrier_rejected、compliance_review_failed、deleted、failed、incomplete_documentation、incorrect_billing_information、ineligible_carrier、loa_file_invalid、loa_file_successful、pending、provisioning、successful)
メッセージング ホステッド番号注文を削除
メッセージング ホステッド番号注文およびすべての関連する電話番号を削除します。
DELETE /messaging_hosted_number_orders/{id}
curl \
-X DELETE \
-H "Authorization: Bearer $TELNYX_API_KEY" \
"https://api.telnyx.com/v2/messaging_hosted_number_orders/550e8400-e29b-41d4-a716-446655440000"
戻り値: id (UUID)、messaging_profile_id (文字列 | null)、phone_numbers (オブジェクト配列)、record_type (文字列)、status (列挙型: carrier_rejected、compliance_review_failed、deleted、failed、incomplete_documentation、incorrect_billing_information、ineligible_carrier、loa_file_invalid、loa_file_successful、pending、provisioning、successful)
ホステッド番号ドキュメントをアップロード
POST /messaging_hosted_number_orders/{id}/actions/file_upload
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-F "loa=@/path/to/file" \
-F "bill=@/path/to/file" \
"https://api.telnyx.com/v2/messaging_hosted_number_orders/550e8400-e29b-41d4-a716-446655440000/actions/file_upload"
戻り値: id (UUID)、messaging_profile_id (文字列 | null)、phone_numbers (オブジェクト配列)、record_type (文字列)、status (列挙型: carrier_rejected、compliance_review_failed、deleted、failed、incomplete_documentation、incorrect_billing_information、ineligible_carrier、loa_file_invalid、loa_file_successful、pending、provisioning、successful)
ホステッド番号コードを検証
ホステッド注文の番号に送信された検証コードを検証します。検証コードは検証コードエンドポイントで作成する必要があります。
POST /messaging_hosted_number_orders/{id}/validation_codes — 必須: verification_codes
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"verification_codes": [
{}
]
}' \
"https://api.telnyx.com/v2/messaging_hosted_number_orders/550e8400-e29b-41d4-a716-446655440000/validation_codes"
戻り値: order_id (UUID)、phone_numbers (オブジェクト配列)
ホステッド番号検証コードを作成
ホステッド注文の番号を検証するための検証コードを作成します。検証コードはホステッド注文の番号に送信されます。
POST /messaging_hosted_number_orders/{id}/verification_codes — 必須: phone_numbers、verification_method
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone_numbers": [
"+13125550001"
],
"verification_method": "sms"
}' \
"https://api.telnyx.com/v2/messaging_hosted_number_orders/550e8400-e29b-41d4-a716-446655440000/verification_codes"
戻り値: error (文字列)、phone_number (文字列)、type (列挙型: sms、call)、verification_code_id (UUID)
メッセージング ホステッド番号を削除
DELETE /messaging_hosted_numbers/{id}
curl \
-X DELETE \
-H "Authorization: Bearer $TELNYX_API_KEY" \
"https://api.telnyx.com/v2/messaging_hosted_numbers/550e8400-e29b-41d4-a716-446655440000"
戻り値: id (UUID)、messaging_profile_id (文字列 | null)、phone_numbers (オブジェクト配列)、record_type (文字列)、status (列挙型: carrier_rejected、compliance_review_failed、deleted、failed、incomplete_documentation、incorrect_billing_information、ineligible_carrier、loa_file_invalid、loa_file_successful、pending、provisioning、successful)
検証リクエストをリスト表示
以前に送信されたトールフリー検証リクエストのリストを取得します
GET /messaging_tollfree/verification/requests
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_tollfree/verification/requests"
戻り値: records (オブジェクト配列)、total_records (整数)
検証リクエストを送信
新しいトールフリー検証リクエストを送信します
POST /messaging_tollfree/verification/requests — 必須: businessName、corporateWebsite、businessAddr1、businessCity、businessState、businessZip、businessContactFirstName、businessContactLastName、businessContactEmail、businessContactPhone、messageVolume、phoneNumbers、useCase、useCaseSummary、productionMessageContent、optInWorkflow、optInWorkflowImageURLs、additionalInformation
オプション: ageGatedContent (ブール値)、businessAddr2 (文字列)、businessRegistrationCountry (文字列 | null)、businessRegistrationNumber (文字列 | null)、businessRegistrationType (文字列 | null)、campaignVerifyAuthorizationToken (文字列 | null)、doingBusinessAs (文字列 | null)、entityType (オブジェクト)、helpMessageResponse (文字列 | null)、isvReseller (文字列 | null)、optInConfirmationResponse (文字列 | null)、optInKeywords (文字列 | null)、privacyPolicyURL (文字列 | null)、termsAndConditionURL (文字列 | null)、webhookUrl (文字列)
curl \
-X POST \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"businessName": "Telnyx LLC",
"corporateWebsite": "http://example.com",
"businessAddr1": "600 Congress Avenue",
"businessCity": "Austin",
"businessState": "Texas",
"businessZip": "78701",
"businessContactFirstName": "John",
"businessContactLastName": "Doe",
"businessContactEmail": "email@example.com",
"businessContactPhone": "+18005550100",
"messageVolume": "100,000",
"phoneNumbers": [
{
"phoneNumber": "+18773554398"
},
{
"phoneNumber": "+18773554399"
}
],
"useCase": "2FA",
"useCaseSummary": "This is a use case where Telnyx sends out 2FA codes to portal users to verify their identity in order to sign into the portal",
"productionMessageContent": "Your Telnyx OTP is XXXX",
"optInWorkflow": "User signs into the Telnyx portal, enters a number and is prompted to select whether they want to use 2FA verification for security purposes. If they'\''ve opted in a confirmation message is sent out to the handset",
"optInWorkflowImageURLs": [
{
"url": "https://telnyx.com/sign-up"
},
{
"url": "https://telnyx.com/company/data-privacy"
}
],
"additionalInformation": "Additional context for this request."
}' \
"https://api.telnyx.com/v2/messaging_tollfree/verification/requests"
戻り値: additionalInformation (文字列)、ageGatedContent (ブール値)、businessAddr1 (文字列)、businessAddr2 (文字列)、businessCity (文字列)、businessContactEmail (文字列)、businessContactFirstName (文字列)、businessContactLastName (文字列)、businessContactPhone (文字列)、businessName (文字列)、businessRegistrationCountry (文字列)、businessRegistrationNumber (文字列)、businessRegistrationType (文字列)、businessState (文字列)、businessZip (文字列)、campaignVerifyAuthorizationToken (文字列 | null)、corporateWebsite (文字列)、doingBusinessAs (文字列)、entityType (オブジェクト)、helpMessageResponse (文字列)、id (UUID)、isvReseller (文字列)、messageVolume (オブジェクト)、optInConfirmationResponse (文字列)、optInKeywords (文字列)、optInWorkflow (文字列)、optInWorkflowImageURLs (オブジェクト配列)、phoneNumbers (オブジェクト配列)、privacyPolicyURL (文字列)、productionMessageContent (文字列)、termsAndConditionURL (文字列)、useCase (オブジェクト)、useCaseSummary (文字列)、verificationRequestId (文字列)、verificationStatus (オブジェクト)、webhookUrl (文字列)
検証リクエストを取得
ID 別に単一の検証リクエストを取得します。
GET /messaging_tollfree/verification/requests/{id}
curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_tollfree/verification/requests/550e8400-e29b-41d4-a716-446655440000"
戻り値: additionalInformation (文字列)、ageGatedContent (ブール値)、businessAddr1 (文字列)、businessAddr2 (文字列)、businessCity (文字列)、businessContactEmail (文字列)、businessContactFirstName (文字列)、businessContactLastName (文字列)、businessContactPhone (文字列)、businessName (文字列)、businessRegistrationCountry (文字列)、businessRegistrationNumber (文字列)、businessRegistrationType (文字列)、businessState (文字列)、businessZip (文字列)、campaignVerifyAuthorizationToken (文字列 | null)、corporateWebsite (文字列)、createdAt (日時)、doingBusinessAs (文字列)、entityType (オブジェクト)、helpMessageResponse (文字列)、id (UUID)、isvReseller (文字列)、messageVolume (オブジェクト)、optInConfirmationResponse (文字列)、optInKeywords (文字列)、optInWorkflow (文字列)、optInWorkflowImageURLs (オブジェクト配列)、phoneNumbers (オブジェクト配列)、privacyPolicyURL (文字列)、productionMessageContent (文字列)、reason (文字列)、termsAndConditionURL (文字列)、updatedAt (日時)、useCase (オブジェクト)、useCaseSummary (文字列)、verificationStatus (オブジェクト)、webhookUrl (文字列)
検証リクエストを更新
既存のトールフリー検証リクエストを更新します。これは、顧客が実行すべき保留中のアクションがある場合に特に便利です。
PATCH /messaging_tollfree/verification/requests/{id} — 必須: businessName、corporateWebsite、businessAddr1、businessCity、businessState、businessZip、businessContactFirstName、businessContactLastName、businessContactEmail、businessContactPhone、messageVolume、phoneNumbers、useCase、useCaseSummary、productionMessageContent、optInWorkflow、optInWorkflowImageURLs、additionalInformation
オプション: ageGatedContent (ブール値)、businessAddr2 (文字列)、businessRegistrationCountry (文字列 | null)、businessRegistrationNumber (文字列 | null)、businessRegistrationType (文字列 | null)、campaignVerifyAuthorizationToken (文字列 | null)、doingBusinessAs (文字列 | null)、entityType (オブジェクト)、helpMessageResponse (文字列 | null)、isvReseller (文字列 | null)、optInConfirmationResponse (文字列 | null)、optInKeywords (文字列 | null)、privacyPolicyURL (文字列 | null)、termsAndConditionURL (文字列 | null)、webhookUrl (文字列)
curl \
-X PATCH \
-H "Authorization: Bearer $TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"businessName": "Telnyx LLC",
"corporateWebsite": "http://example.com",
"businessAddr1": "600 Congress Avenue",
"businessCity": "Austin",
"businessState": "Texas",
"businessZip": "78701",
"businessContactFirstName": "John",
"businessContactLastName": "Doe",
"businessContactEmail": "email@example.com",
"businessContactPhone": "+18005550100",
"messageVolume": "100,000",
"phoneNumbers": [
{
"phoneNumber": "+18773554398"
},
{
"phoneNumber": "+18773554399"
}
],
"useCase": "2FA",
"useCaseSummary": "This is a use case where Telnyx sends out 2FA codes to portal users to verify their identity in order to sign into the portal",
"productionMessageContent": "Your Telnyx OTP is XXXX",
"optInWorkflow": "User signs into the Telnyx portal, enters a number and is prompted to select whether they want to use 2FA verification for security purposes. If they'\''ve opted in a confirmation message is sent out to the handset",
"optInWorkflowImageURLs": [
{
"url": "https://telnyx.com/sign-up"
},
{
"url": "https://telnyx.com/company/data-privacy"
}
],
"additionalInformation": "Additional context for this request."
}' \
"https://api.telnyx.com/v2/messaging_tollfree/verification/requests/550e8400-e29b-41d4-a716-446655440000"
戻り値: additionalInformation (文字列)、ageGatedContent (ブール値)、businessAddr1 (文字列)、businessAddr2 (文字列)、businessCity (文字列)、businessContactEmail (文字列)、businessContactFirstName (文字列)、businessContactLastName (文字列)、businessContactPhone (文字列)、businessName (文字列)、businessRegistrationCountry (文字列)、businessRegistrationNumber (文字列)、businessRegistrationType (文字列)、businessState (文字列)、businessZip (文字列)、campaignVerifyAuthorizationToken (文字列 | null)、corporateWebsite (文字列)、doingBusinessAs (文字列)、entityType (オブジェクト)、helpMessageResponse (文字列)、id (UUID)、isvReseller (文字列)、messageVolume (オブジェクト)、optInConfirmationResponse (文字列)、optInKeywords (文字列)、optInWorkflow (文字列)、optInWorkflowImageURLs (オブジェクト配列)、phoneNumbers (オブジェクト配列)、privacyPolicyURL (文字列)、productionMessageContent (文字列)、termsAndConditionURL (文字列)、`useCase
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- team-telnyx
- リポジトリ
- team-telnyx/ai
- ライセンス
- MIT
- 最終更新
- 2026/5/11
Source: https://github.com/team-telnyx/ai / ライセンス: MIT