Telnyx Logo

Fitness International Auto Attendant APIs

Real-time club status and management system

Overview

The Fitness International Auto Attendant APIs provide real-time information about club locations, including open/closed status, hours of operation, and special closures. The API is optimized for auto-attendant phone systems and returns instant status calculations based on timezone-aware logic.

Key Features:
  • Real-time open/closed status with timezone awareness
  • Dynamic message generation for closed clubs
  • Special closures (holidays, emergencies, maintenance)
  • Support for US and Canadian locations
  • Full CRUD operations for club management

Base URL

https://inbound-fitness-international.telnyx-worker.dev

All API requests should be made to this base URL. All endpoints return JSON responses.

Database Structure

Understanding the data model helps you make effective API calls. The system uses three main tables:

clubs
id INTEGER
dept_id TEXT
club_id TEXT
phone TEXT (10 digits)
location_name TEXT
address TEXT
region TEXT (US/CA)
brand TEXT
status TEXT
default_message TEXT
forwarding_number TEXT
amenities TEXT
club_hours
id INTEGER
club_id INTEGER (FK)
day_of_week INTEGER (0-6)
open_time TEXT (HH:MM)
close_time TEXT (HH:MM)
is_closed INTEGER (0/1)
special_closures
id INTEGER
club_id INTEGER (FK)
closure_date DATE
closure_type TEXT
reason TEXT
open_time TEXT (HH:MM)
close_time TEXT (HH:MM)
custom_message TEXT
Key Points:
  • phone: 10-digit number without formatting (e.g., "3055551234")
  • region: US state code (FL, CA, TX) or Canadian province (ON, BC, QC)
  • day_of_week: 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday
  • default_message: Set to "default" for automatic message generation, or provide custom text
  • forwarding_number: Microsoft Teams or destination number for call forwarding (e.g., "+18005551234")

Getting Started

Primary Use Case: Auto-Attendant Lookup

The most common use case is looking up a club by phone number to determine if it's open and what message to play:

GET /api/phone?phone={phone_number}

Returns complete club information including real-time open/closed status and the appropriate message for your auto-attendant system.

Example Request:

curl "https://inbound-fitness-international.telnyx-worker.dev/api/phone?phone=3055551234"

Example Response:

{
  "success": true,
  "data": {
    "id": 1,
    "phone": "3055551234",
    "location_name": "Miami Downtown",
    "brand": "LA Fitness",
    "region": "FL",
    "is_open": false,
    "current_status": "Closed",
    "status_message": "Thank you for calling LA Fitness located at Miami Downtown. Our hours are 6AM to 10PM and we are currently closed. Please call back during open hours, thank you!",
    "hours": {
      "monday": { "open": "06:00", "close": "22:00" },
      "tuesday": { "open": "06:00", "close": "22:00" },
      ...
    },
    "sun_open": "0800",
    "sun_close": "2000",
    "mon_open": "0600",
    "mon_close": "2200",
    "tue_open": "0600",
    "tue_close": "2200",
    "wed_open": "0600",
    "wed_close": "2200",
    "thu_open": "0600",
    "thu_close": "2200",
    "fri_open": "0600",
    "fri_close": "2200",
    "sat_open": "0800",
    "sat_close": "2000"
  }
}
📝 Time Format Notes:
  • Flattened hours (sun_open, mon_open, etc.): 4-digit format without colon (e.g., "0600" for 6:00 AM)
  • Structured hours (hours.monday.open, etc.): HH:MM format with colon (e.g., "06:00")
  • Status messages: Human-readable 12-hour format (e.g., "6AM to 10PM")

API Endpoints

Read Operations

GET /api/phone?phone={phone}

Purpose: Get club by phone number (primary auto-attendant endpoint)

Parameters:

  • phone REQUIRED - 10-digit phone number

Returns: Complete club info with real-time status and message

Example Request:

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/phone?phone=3055551234' \
  -H 'Accept: application/json'
GET /api/search

Purpose: Consolidated search endpoint - search clubs by any field

Search Parameters (at least one required):

  • id OPTIONAL - Club database ID
  • dept_id OPTIONAL - Department ID
  • club_id OPTIONAL - Club ID
  • phone OPTIONAL - 10-digit phone number
  • forwarding_number OPTIONAL - Microsoft Teams forwarding number
  • location_name OPTIONAL - Location name (partial match supported)

Returns: Array of clubs matching search criteria

Example Requests:

# Search by club_id
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/search?club_id=0001' \
  -H 'Accept: application/json'

# Search by location name (partial match)
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/search?location_name=Miami' \
  -H 'Accept: application/json'

# Search by forwarding number
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/search?forwarding_number=%2B18005551234' \
  -H 'Accept: application/json'

# Multiple criteria (AND logic)
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/search?dept_id=101&region=FL' \
  -H 'Accept: application/json'
GET /api/locations

Purpose: List all clubs (optionally filtered by region or brand)

Optional Parameters:

  • region OPTIONAL - Filter by US state or Canadian province (e.g., FL, CA, ON)
  • brand OPTIONAL - Filter by brand name (e.g., "LA Fitness")

Returns: Array of all clubs (without real-time status calculation for performance)

Example Requests:

# Get all clubs
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/locations' \
  -H 'Accept: application/json'

# Get all clubs in Florida
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/locations?region=FL' \
  -H 'Accept: application/json'

# Get all LA Fitness clubs
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/locations?brand=LA%20Fitness' \
  -H 'Accept: application/json'

# Get all LA Fitness clubs in California
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/locations?region=CA&brand=LA%20Fitness' \
  -H 'Accept: application/json'

Write Operations - Clubs

POST /api/club

Purpose: Create a new club

Required Fields:

  • dept_id, club_id, phone, location_name, address, region

Optional Fields:

  • brand, status, default_message, forwarding_number, amenities, hours (array of 7 days)

Example Request:

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/club' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg=' \
  --data-raw '{
    "dept_id": "101",
    "club_id": "0025",
    "phone": "3055559876",
    "location_name": "Miami Beach",
    "address": "500 Ocean Drive, Miami Beach, FL 33139",
    "region": "FL",
    "brand": "LA Fitness",
    "status": "active",
    "default_message": "default",
    "forwarding_number": "+18005551234",
    "amenities": "Swimming Pool, Basketball Court, Sauna, Free Weights",
    "hours": [
      {"day": 0, "open": "08:00", "close": "20:00"},
      {"day": 1, "open": "05:00", "close": "23:00"},
      {"day": 2, "open": "05:00", "close": "23:00"},
      {"day": 3, "open": "05:00", "close": "23:00"},
      {"day": 4, "open": "05:00", "close": "23:00"},
      {"day": 5, "open": "05:00", "close": "23:00"},
      {"day": 6, "open": "08:00", "close": "20:00"}
    ]
  }'
📅 Day of Week Mapping:
  • 0 = Sunday
  • 1 = Monday
  • 2 = Tuesday
  • 3 = Wednesday
  • 4 = Thursday
  • 5 = Friday
  • 6 = Saturday
⏰ Time Format Flexibility:
  • Both formats accepted: "06:00" (with colon) or "0600" (without colon)
  • Stored as: "HH:MM" format in database (e.g., "06:00")
  • Examples:
    • {"day": 1, "open": "0600", "close": "2200"}
    • {"day": 1, "open": "06:00", "close": "22:00"}
📞 Phone Number Format Flexibility:

For phone field (club's main number):

  • "3055551234" (10 digits) ✅
  • "305-555-1234" (with dashes) ✅
  • "(305) 555-1234" (with parentheses) ✅
  • "1-305-555-1234" (11 digits with country code) ✅
  • Stored as: 10-digit number (e.g., "3055551234")

For forwarding_number field (Microsoft Teams destination):

  • "+18005551234" (+E.164 format) ✅
  • "18005551234" (E.164 without +) ✅
  • "8005551234" (10 digits, auto-adds +1) ✅
  • "800-555-1234" (with dashes, auto-adds +1) ✅
  • "+442071838750" (international E.164) ✅
  • "442071838750" (international without +) ✅
  • Stored as: Full E.164 format (e.g., "+18005551234")
PUT /api/club

Purpose: Update an existing club

Identifier: Must provide phone, club_id, or dept_id to identify the club

Updatable Fields: Any club field including hours

Example Requests:

# Update by phone
curl -L -X PUT 'https://inbound-fitness-international.telnyx-worker.dev/api/club' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg=' \
  --data-raw '{
    "phone": "3055559876",
    "brand": "Esporta Fitness",
    "forwarding_number": "+18005556789"
  }'

# Update by dept_id
curl -L -X PUT 'https://inbound-fitness-international.telnyx-worker.dev/api/club' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg=' \
  --data-raw '{
    "dept_id": "101",
    "default_message": "Thank you for calling!",
    "amenities": "Swimming Pool, Sauna, Basketball Court"
  }'
DELETE /api/club

Purpose: Delete a club

Parameters (at least one required):

  • phone OPTIONAL - 10-digit phone number
  • club_id OPTIONAL - Club ID
  • dept_id OPTIONAL - Department ID

Example Requests:

# Delete by phone
curl -L -X DELETE 'https://inbound-fitness-international.telnyx-worker.dev/api/club?phone=3055559876' \
  -H 'Accept: application/json'

# Delete by dept_id
curl -L -X DELETE 'https://inbound-fitness-international.telnyx-worker.dev/api/club?dept_id=101' \
  -H 'Accept: application/json'

Special Closures

GET /api/closures

Purpose: Get special closures for a specific club

Required Parameters (at least one):

  • phone REQUIRED* - Club phone number (10 digits)
  • club_id REQUIRED* - Club ID
  • dept_id REQUIRED* - Department ID

*At least one club identifier (phone, club_id, or dept_id) is required

Optional Filter Parameters:

  • closure_type OPTIONAL - Filter by type (emergency, weather, holiday, maintenance, event)
  • closure_date OPTIONAL - Filter by specific date (YYYY-MM-DD)
  • start_date OPTIONAL - Filter by date range start (YYYY-MM-DD)
  • end_date OPTIONAL - Filter by date range end (YYYY-MM-DD)

Returns: Array of closures for the specified club (ordered by date descending)

Example Requests:

# Get all closures for a club by phone
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closures?phone=3055551234' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg='

# Get emergency closures for a club
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closures?dept_id=123&closure_type=emergency' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg='

# Get closures for a club in date range
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closures?club_id=456&start_date=2025-12-01&end_date=2025-12-31' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg='

# Get holiday closures for December for a club
curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closures?phone=3055551234&closure_type=holiday&start_date=2025-12-01&end_date=2025-12-31' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer KbHHX+XEBbAKcya3GayPKFyiNMOsVxIHxqQ4F+gvNDg='
POST /api/closure

Purpose: Add a special closure (holiday, emergency, etc.)

Required Fields:

  • phone, club_id, or dept_id - Club identifier (at least one required)
  • closure_date - Format: YYYY-MM-DD
  • closure_type - One of: emergency, weather, holiday, maintenance, event

Optional Fields:

  • reason - Description of closure
  • open_time, close_time - For special hours (leave null for closed all day)
  • closure_allday - Set to true for all-day closure (automatically sets open_time and close_time to null)
  • custom_message - Message to play to callers

Example Request (Closed All Day - Using closure_allday):

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closure' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data-raw '{
    "phone": "3055551234",
    "closure_date": "2025-12-25",
    "closure_type": "holiday",
    "reason": "Christmas Day",
    "closure_allday": true,
    "custom_message": "Merry Christmas! We are closed today and will reopen December 26th."
  }'

Example Request (Closed All Day - Traditional Method):

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closure' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data-raw '{
    "phone": "3055551234",
    "closure_date": "2025-12-25",
    "closure_type": "holiday",
    "reason": "Christmas Day",
    "custom_message": "Merry Christmas! We are closed today and will reopen December 26th."
  }'

Example Request (Special Hours):

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closure' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data-raw '{
    "phone": "3055551234",
    "closure_date": "2025-12-24",
    "closure_type": "holiday",
    "reason": "Christmas Eve",
    "open_time": "08:00",
    "close_time": "14:00",
    "custom_message": "Happy Holidays! We close early today at 2 PM for Christmas Eve."
  }'
⏰ Time Format Flexibility:

Both open_time and close_time accept either format:

  • "08:00" (with colon) or "0800" (without colon) ✅
  • "14:00" (with colon) or "1400" (without colon) ✅
POST /api/closures/bulk

Purpose: Add closures for multiple dates and/or multiple clubs in a single API call

Required Fields:

  • dates - Array of dates (YYYY-MM-DD format)
  • closure_type - One of: emergency, weather, holiday, maintenance, event
  • club_ids (array of club IDs) OR apply_to_all: true (affects all active clubs)

Optional Fields:

  • reason - Description for all closures
  • custom_message - Message for all closures
  • open_time, close_time - For special hours (applies to all dates)
  • closure_allday - Set to true for all-day closures (automatically sets open_time and close_time to null for all dates)
Use Cases:
  • Close all clubs for consecutive holidays (Christmas Eve, Christmas, Boxing Day)
  • Close specific clubs for regional emergencies (hurricane, blizzard)
  • Apply maintenance closures to multiple locations at once

Example Request (All Clubs - All Day Closure):

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data-raw '{
    "dates": ["2025-12-24", "2025-12-25", "2025-12-26"],
    "closure_type": "holiday",
    "reason": "Christmas Holiday",
    "closure_allday": true,
    "custom_message": "Happy Holidays! We are closed for Christmas and will reopen on December 27th.",
    "apply_to_all": true
  }'

Example Request (Specific Clubs):

curl -L 'https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data-raw '{
    "club_ids": [1, 2, 5, 8],
    "dates": ["2025-09-15"],
    "closure_type": "weather",
    "reason": "Hurricane Warning",
    "custom_message": "Due to severe weather, our clubs are temporarily closed for your safety."
  }'
DELETE /api/closure?id={id}

Purpose: Remove a single special closure

Parameters:

  • id REQUIRED - Closure ID from specialClosures array

Example Request:

curl -L -X DELETE 'https://inbound-fitness-international.telnyx-worker.dev/api/closure?id=123' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'
DELETE /api/closures/holidays

Purpose: Delete all holiday closures for a specific club

Parameters (at least one required):

  • phone - Club phone number
  • club_id - Club ID
  • dept_id - Department ID
⚠️ Warning: This endpoint deletes ALL holiday closures for the specified club. Other closure types (emergency, weather, maintenance, event) are not affected.

Use Cases:

  • Clear out all holidays for a club at the end of the year before importing next year's schedule
  • Remove incorrect holiday imports for a specific location
  • Reset holiday schedules during system maintenance for a club

Returns: Count of deleted holiday closures and club information

Example Request (By Phone):

curl -L -X DELETE 'https://inbound-fitness-international.telnyx-worker.dev/api/closures/holidays?phone=3055551234' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Example Request (By Club ID):

curl -L -X DELETE 'https://inbound-fitness-international.telnyx-worker.dev/api/closures/holidays?club_id=0001' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Example Response:

{
  "success": true,
  "message": "Deleted all holiday closures for club: Miami Downtown",
  "club_id": 1,
  "club_name": "Miami Downtown",
  "deleted_count": 12
}
Note: This only deletes closures with closure_type = 'holiday' for the specified club. Emergency, weather, maintenance, and event closures are not affected.

Auto-Attendant Message Logic

The API automatically generates appropriate messages for your auto-attendant system based on the club's status and configuration.

Dynamic Message Generation

Set default_message = "default" in your club configuration to enable automatic message generation:

Message Template (when closed):

"Thank you for calling {brand} located at {location}. Our hours are {open_time} to {close_time} and we are currently closed. Please call back during open hours, thank you!"

Message Behavior

Club Status Scenario Returned status_message
OPEN Regular hours Empty string (call transfers immediately)
OPEN Special hours (holiday) Message before transfer (e.g., "We are open today with special hours until 14:00. Please hold while we connect you.")
CLOSED default_message = "default" Generated message with club details
CLOSED Custom default_message Uses your custom message
CLOSED default_message empty/null Generic fallback message
Important:
  • When a club is open during regular hours, status_message is empty (immediate transfer)
  • When a club is open during special hours (holidays, events), status_message contains a brief message to inform the caller before transferring
  • This ensures callers know about limited hours before being connected

Special Closures & Priority System

When you add special closures (holidays, emergencies, etc.), the system automatically prioritizes them to ensure the most important information is communicated first.

Closure Types & Priority

1
emergency - Highest priority (power outages, safety issues)
Overrides all other closures
2
weather - Weather-related closures (hurricanes, storms)
Important for safety communications
3
holiday - Scheduled holidays
Regular holiday closures
4
maintenance - Planned maintenance work
Can include special hours
5
event - Lowest priority (special events)
Non-critical closures

Special Hours vs. Closed All Day

Special closures can be configured two ways:

Configuration Result Example
open_time: null
close_time: null
Closed all day Christmas Day closure
open_time: "10:00"
close_time: "14:00"
Special hours (10am-2pm) Christmas Eve limited hours

Bulk Closures for Consecutive Holidays

The bulk closure endpoint allows you to efficiently manage multiple closures across multiple dates and/or multiple clubs in a single API call. This is especially useful for consecutive holidays or company-wide closures.

Example 1: Christmas Holiday Week (All Clubs)

Close all clubs for Christmas Eve, Christmas Day, and Boxing Day:

curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "dates": ["2025-12-24", "2025-12-25", "2025-12-26"],
    "closure_type": "holiday",
    "reason": "Christmas Holiday",
    "custom_message": "Happy Holidays! We are closed for Christmas and will reopen on December 27th.",
    "apply_to_all": true
  }'

Result: All active clubs will be closed on all three dates with the same message.

Example 2: Christmas Eve Special Hours (All Clubs)

Keep clubs open with reduced hours on Christmas Eve:

curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "dates": ["2025-12-24"],
    "closure_type": "holiday",
    "reason": "Christmas Eve",
    "open_time": "08:00",
    "close_time": "14:00",
    "custom_message": "Happy Holidays! We close early today at 2 PM for Christmas Eve.",
    "apply_to_all": true
  }'

Result: All clubs open 8am-2pm on Christmas Eve with special hours message.

Example 3: Regional Holiday (Specific Clubs)

Close only Canadian clubs for Canada Day:

curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "club_ids": [45, 67, 89, 102, 156],
    "dates": ["2025-07-01"],
    "closure_type": "holiday",
    "reason": "Canada Day",
    "custom_message": "Happy Canada Day! We are closed today and will reopen July 2nd.",
  }'

Result: Only specified clubs are closed on July 1st.

Example 4: Multiple Consecutive Holidays with Different Messages

For holidays that need different messages on different days, make separate bulk calls:

# Christmas Eve - Special hours
curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "dates": ["2025-12-24"],
    "closure_type": "holiday",
    "reason": "Christmas Eve",
    "open_time": "08:00",
    "close_time": "14:00",
    "custom_message": "Happy Holidays! We close early today at 2 PM.",
    "apply_to_all": true
  }'

# Christmas & Boxing Day - Fully closed
curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "dates": ["2025-12-25", "2025-12-26"],
    "closure_type": "holiday",
    "reason": "Christmas Holiday",
    "custom_message": "Merry Christmas! We are closed and will reopen December 27th.",
    "apply_to_all": true
  }'

Example 5: New Year's Week Closure

Close clubs for an entire week:

curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closures/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "dates": [
      "2025-12-29",
      "2025-12-30",
      "2025-12-31",
      "2026-01-01",
      "2026-01-02",
      "2026-01-03",
      "2026-01-04"
    ],
    "closure_type": "holiday",
    "reason": "Year-End Holiday Break",
    "custom_message": "Happy Holidays! We are closed for our year-end break and will reopen January 5th.",
    "apply_to_all": true
  }'
Efficiency Benefits:

Instead of making 698 individual API calls to close all clubs for 3 days (2,094 total calls), you make 1 bulk API call that creates all 2,094 closure entries automatically.
Important Notes:
  • Bulk closures use the same closure_type, reason, and custom_message for all dates
  • If you need different messages for different dates, make separate bulk API calls
  • Special hours (open_time/close_time) apply to all dates in the array
  • You cannot mix closed all day and special hours in a single bulk call

Example Scenarios

Scenario 1: Club is Open

API Response:

{
  "is_open": true,
  "current_status": "Open",
  "status_message": ""  // Empty - transfer call immediately
}

Auto-Attendant Action: Transfer call to club location

Scenario 2: Club is Closed (Dynamic Message)

Club Configuration: default_message = "default"

API Response:

{
  "is_open": false,
  "current_status": "Closed",
  "status_message": "Thank you for calling LA Fitness located at Downtown Miami. Our hours are 06:00 to 22:00 and we are currently closed. Please call back during open hours, thank you!"
}

Auto-Attendant Action: Play generated message, offer voicemail

Scenario 3: Emergency Closure

Situation: Power outage at location

API Response:

{
  "is_open": false,
  "current_status": "emergency",
  "status_message": "EMERGENCY: The club is closed due to a power outage. Please check back for updates.",
  "specialClosures": [
    {
      "closure_type": "emergency",
      "reason": "Power Outage",
      "custom_message": "EMERGENCY: The club is closed due to a power outage. Please check back for updates."
    }
  ]
}

Auto-Attendant Action: Play emergency message

Scenario 4: Holiday with Special Hours (Currently Open)

Situation: Christmas Eve - open 10am-2pm, caller calls at 11am

API Response:

{
  "is_open": true,
  "current_status": "Open - Special Hours",
  "status_message": "We are open today with special hours until 14:00. Please hold while we connect you.",
  "specialClosures": [
    {
      "closure_type": "holiday",
      "open_time": "10:00",
      "close_time": "14:00",
      "custom_message": null
    }
  ]
}

Auto-Attendant Action: Play special hours message, then transfer call

Note: If the closure has a custom_message, that message is used instead of the default template.

Scenario 5: Multiple Closures (Priority in Action)

Situation: Emergency + Holiday + Maintenance all on same day

API Response:

{
  "is_open": false,
  "current_status": "emergency",  // Emergency wins (highest priority)
  "status_message": "EMERGENCY: The club is closed due to a power outage...",
  "specialClosures": [
    { "closure_type": "emergency", "reason": "Power Outage" },
    { "closure_type": "holiday", "reason": "Christmas" },
    { "closure_type": "maintenance", "reason": "HVAC Repair" }
  ]
}

Note: All closures are returned, but only the highest priority (emergency) is used for status determination.

Testing

Test Club

A test club is available for development and testing purposes:

Test Club Details:

Phone: 5555555555
Name: TEST CLUB - Always Closed
Hours: 02:00 - 02:01 (effectively always closed)
Purpose: Test closed status and message generation

Test Endpoint:
GET /api/phone?phone=5555555555

Testing Special Closures

You can add test closures to verify priority logic:

Add a Test Holiday:

curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closure" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "5555555555",
    "closure_date": "2025-12-25",
    "closure_type": "holiday",
    "reason": "Christmas Day",
    "custom_message": "Merry Christmas! We are closed today."
  }'

Add a Test Emergency (Higher Priority):

curl -X POST "https://inbound-fitness-international.telnyx-worker.dev/api/closure" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "5555555555",
    "closure_date": "2025-12-25",
    "closure_type": "emergency",
    "reason": "Power Outage",
    "custom_message": "EMERGENCY: Club closed due to power outage."
  }'

When you query the test club on 12/25, the emergency message will be returned (higher priority than holiday).

Testing Dynamic Messages

To test dynamic message generation, ensure the test club has default_message = "default" and query during closed hours.

Testing with cURL

# Get club status
curl "https://inbound-fitness-international.telnyx-worker.dev/api/phone?phone=3055551234"

# List all locations
curl "https://inbound-fitness-international.telnyx-worker.dev/api/locations"

# Get club by ID
curl "https://inbound-fitness-international.telnyx-worker.dev/api/club?club_id=0001"

# Filter by region (US state or Canadian province)
curl "https://inbound-fitness-international.telnyx-worker.dev/api/region?region=FL"
curl "https://inbound-fitness-international.telnyx-worker.dev/api/region?region=ON"

Auto Attendant TeXML Step-by-Step Guide

Overview:

This document provides instructions for configuring an auto attendant system using Telnyx's TeXML applications, which routes calls based on business hours status.

Step 1: Access TeXML Applications

Navigate to the Telnyx portal and go to Real-Time Communications > Voice > Programmable Voice > TeXML Applications to locate the "after_hours" profile.

TeXML Applications page showing after_hours profile

Step 2: Edit Profile Settings

Click the pencil/edit button to access the configuration options for your TeXML profile.

Edit TeXML application details page

Step 3: Initial TeXML Configuration

The starter file includes an HTTP request that:

The configuration makes an HTTP request to https://inbound-fitness-international.telnyx-worker.dev/api/phone?phone={{To}} and extracts JSON response fields.

Code Example:

<Response>
<HttpRequest action="https://api.telnyx.com/v2/media/hours_handler.xml">
      <Request url="https://inbound-fitness-international.telnyx-worker.dev/api/phone?phone={{To}}" method="GET">
      </Request>
 <Header>
                <Key>Content-Type</Key>
                <Value>application/json</Value>
            </Header>
      <Response>
        <Type>JSON</Type>
        <StatusCode>200</StatusCode>
        <Content>
          <Field>
            <Name>data.current_status</Name>
            <Value>current_status</Value>
          </Field>
          <Field>
            <Name>data.status_message</Name>
            <Value>status_message</Value>
          </Field>
           <Field>
            <Name>data.forwarding_number</Name>
            <Value>forwarding_number</Value>
          </Field>
        </Content>
      </Response>
    </HttpRequest>
</Response>

Step 4: Hours Handler Implementation

The hours handler TeXML script (found in TeXML Bins) includes conditional logic:

The voice setting uses Azure.en-US-Ava:DragonHDLatestNeural but can be customized using any supported Telnyx voice from their text-to-speech documentation.

Code Example:

<Response>
{{#if {{current_status}}!=Open}}
<Say voice="Azure.en-US-Ava:DragonHDLatestNeural">{{status_message}}</Say>
  {{#else}}
    <Dial>{{forwarding_number}}</Dial>
   {{/if}}
</Response>

Fitness International Auto Attendant APIs v3.0 - Powered by Cloudflare Workers + D1

Documentation last updated: October 2025