skills/team-telnyx/telnyx-skills/telnyx-messaging-profiles-curl

telnyx-messaging-profiles-curl

SKILL.md

Telnyx Messaging Profiles - curl

Installation

# curl is pre-installed on macOS, Linux, and Windows 10+

Setup

export TELNYX_API_KEY="YOUR_API_KEY_HERE"

All examples below use $TELNYX_API_KEY for authentication.

Error Handling

All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:

# Check HTTP status code in response
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

Common error codes: 401 invalid API key, 403 insufficient permissions, 404 resource not found, 422 validation error (check field formats), 429 rate limited (retry with exponential backoff).

Important Notes

  • Pagination: List endpoints return paginated results. Use page[number] and page[size] query parameters to navigate pages. Check meta.total_pages in the response.

List messaging profiles

GET /messaging_profiles

curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_profiles"

Returns: ai_assistant_id (string | null), alpha_sender (string | null), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings (object | null), organization_id (string), record_type (enum: messaging_profile), redaction_enabled (boolean), redaction_level (integer), resource_group_id (string | null), smart_encoding (boolean), updated_at (date-time), url_shortener_settings (object | null), v1_secret (string), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

Create a messaging profile

POST /messaging_profiles — Required: name, whitelisted_destinations

Optional: ai_assistant_id (string | null), alpha_sender (string | null), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), number_pool_settings (object | null), resource_group_id (string | null), smart_encoding (boolean), url_shortener_settings (object | null), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url)

curl \
  -X POST \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "whitelisted_destinations": [
    "string"
  ],
  "number_pool_settings": {
    "toll_free_weight": 10,
    "long_code_weight": 1,
    "skip_unhealthy": true,
    "sticky_sender": false,
    "geomatch": false
  },
  "url_shortener_settings": {
    "domain": "example.ex",
    "prefix": "",
    "replace_blacklist_only": true,
    "send_webhooks": false
  }
}' \
  "https://api.telnyx.com/v2/messaging_profiles"

Returns: ai_assistant_id (string | null), alpha_sender (string | null), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings (object | null), organization_id (string), record_type (enum: messaging_profile), redaction_enabled (boolean), redaction_level (integer), resource_group_id (string | null), smart_encoding (boolean), updated_at (date-time), url_shortener_settings (object | null), v1_secret (string), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

Retrieve a messaging profile

GET /messaging_profiles/{id}

curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_profiles/{id}"

Returns: ai_assistant_id (string | null), alpha_sender (string | null), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings (object | null), organization_id (string), record_type (enum: messaging_profile), redaction_enabled (boolean), redaction_level (integer), resource_group_id (string | null), smart_encoding (boolean), updated_at (date-time), url_shortener_settings (object | null), v1_secret (string), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

Update a messaging profile

PATCH /messaging_profiles/{id}

Optional: alpha_sender (string | null), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings (object | null), record_type (enum: messaging_profile), smart_encoding (boolean), updated_at (date-time), url_shortener_settings (object | null), v1_secret (string), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

curl \
  -X PATCH \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "number_pool_settings": {
    "toll_free_weight": 10,
    "long_code_weight": 1,
    "skip_unhealthy": true,
    "sticky_sender": false,
    "geomatch": false
  },
  "url_shortener_settings": {
    "domain": "example.ex",
    "prefix": "",
    "replace_blacklist_only": true,
    "send_webhooks": false
  }
}' \
  "https://api.telnyx.com/v2/messaging_profiles/{id}"

Returns: ai_assistant_id (string | null), alpha_sender (string | null), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings (object | null), organization_id (string), record_type (enum: messaging_profile), redaction_enabled (boolean), redaction_level (integer), resource_group_id (string | null), smart_encoding (boolean), updated_at (date-time), url_shortener_settings (object | null), v1_secret (string), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

Delete a messaging profile

DELETE /messaging_profiles/{id}

curl \
  -X DELETE \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  "https://api.telnyx.com/v2/messaging_profiles/{id}"

Returns: ai_assistant_id (string | null), alpha_sender (string | null), created_at (date-time), daily_spend_limit (string), daily_spend_limit_enabled (boolean), enabled (boolean), health_webhook_url (url), id (uuid), mms_fall_back_to_sms (boolean), mms_transcoding (boolean), mobile_only (boolean), name (string), number_pool_settings (object | null), organization_id (string), record_type (enum: messaging_profile), redaction_enabled (boolean), redaction_level (integer), resource_group_id (string | null), smart_encoding (boolean), updated_at (date-time), url_shortener_settings (object | null), v1_secret (string), webhook_api_version (enum: 1, 2, 2010-04-01), webhook_failover_url (url), webhook_url (url), whitelisted_destinations (array[string])

List phone numbers associated with a messaging profile

GET /messaging_profiles/{id}/phone_numbers

curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_profiles/{id}/phone_numbers"

Returns: country_code (string), created_at (date-time), eligible_messaging_products (array[string]), features (object), health (object), id (string), messaging_product (string), messaging_profile_id (string | null), organization_id (string), phone_number (string), record_type (enum: messaging_phone_number, messaging_settings), tags (array[string]), traffic_type (string), type (enum: long-code, toll-free, short-code, longcode, tollfree, shortcode), updated_at (date-time)

List short codes associated with a messaging profile

GET /messaging_profiles/{id}/short_codes

curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_profiles/{id}/short_codes"

Returns: country_code (string), created_at (date-time), id (uuid), messaging_profile_id (string | null), record_type (enum: short_code), short_code (string), tags (array), updated_at (date-time)

List short codes

GET /short_codes

curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/short_codes"

Returns: country_code (string), created_at (date-time), id (uuid), messaging_profile_id (string | null), record_type (enum: short_code), short_code (string), tags (array), updated_at (date-time)

Retrieve a short code

GET /short_codes/{id}

curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/short_codes/{id}"

Returns: country_code (string), created_at (date-time), id (uuid), messaging_profile_id (string | null), record_type (enum: short_code), short_code (string), tags (array), updated_at (date-time)

Update short code

Update the settings for a specific short code. To unbind a short code from a profile, set the messaging_profile_id to null or an empty string. To add or update tags, include the tags field as an array of strings.

PATCH /short_codes/{id} — Required: messaging_profile_id

Optional: tags (array)

curl \
  -X PATCH \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "messaging_profile_id": "string"
}' \
  "https://api.telnyx.com/v2/short_codes/{id}"

Returns: country_code (string), created_at (date-time), id (uuid), messaging_profile_id (string | null), record_type (enum: short_code), short_code (string), tags (array), updated_at (date-time)

Weekly Installs
4
GitHub Stars
141
First Seen
10 days ago
Installed on
opencode4
gemini-cli4
antigravity4
github-copilot4
amp4
cline4