Routing for Numbers

Call Routing

Call routing decides where an inbound call to a tracking number is forwarded. Set it on call_routes when you create or update a number.

POST https://edgeapi.marchex.io/marketingedge/v5/api/groups/{group_id}/numbers


Routing options

Routing optionroute_type
BasicBasic
Time of DayTimeOfDay
Follow MeFollowMe
Caller SegmentationKeyPress
GeographicGeo
Zip CodeZipCode

Business Hours is turned on for the organization by Marchex. If a request is rejected because Business Hours is not enabled, contact Customer Success.

Where call features go

Two objects hold call features:

  • features on the number. These run on every inbound call before a route is chosen.
  • features on a route (call_routes.route.features for Basic, call_routes.routes[].features for an advanced route). These apply to calls handled by that route.
FeatureWhere to set it
stop_callfeatures on the number
call_verifyfeatures on the number
call_tag_rulesfeatures on the number
scheduled_call_verifyfeatures on the number, and only when route_type is Basic
call_record and whisperDepends on the route type. See each section.

call_record and whisper accept either notification_text or notification_file. notification_file is a Data Store id. When call_record.record is true, supply one of those so the caller hears the recording notice.

For Caller Segmentation, Geographic, and Zip Code, set call_record and whisper on each route that should use them. A route with no features block does not record or whisper. For Caller Segmentation, a route that omits call_record or whisper inherits that feature from features on the number.

For Follow Me and Time of Day, set call_record and whisper on features of the number. Per-route features on those route types are ignored.


Business Hours

Business Hours sends a call to one destination while the business is open and a different destination after it closes. You keep the same route_type and mark each route with business_hours_routing:

ValueWhen the route is eligible
DuringInside the open window
AfterOutside the open window
AlwaysEither window

Use Business Hours on Caller Segmentation, Follow Me, Geographic, and Zip Code. During and After are a pair for the same key, area code, zip code, or Follow Me step. Always stands alone for that key. Always cannot be combined with During or After on the same Caller Segmentation key, geographic key, or zip code.

Supply the weekly schedule on call_routes.business_hours. On create, include all seven days. Each day needs open_time and close_time (HH:mm, open before close) or all_day set to Open or Closed. If you omit business_hours and a route uses During or After, the API uses the Advertiser's business hours. The request fails when neither the number nor the Advertiser has a schedule.

Time of Day uses its own windows. See Time of Day.

Call recording and whisper follow the underlying route type. On Caller Segmentation, Geographic, and Zip Code you can give the During route and the After route different call_record and whisper settings.

This example is Caller Segmentation: press 1 reaches the office during business hours and an answering service after hours. The same business_hours block and business_hours_routing values work on Follow Me, Geographic, and Zip Code.

{
  "name": "Main line - business hours",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "call_routes": {
    "route_type": "KeyPress",
    "notification_text": "Press 1 to speak with our team.",
    "business_hours": {
      "days": [
        { "day_of_week": "Monday", "open_time": "09:00", "close_time": "17:00" },
        { "day_of_week": "Tuesday", "open_time": "09:00", "close_time": "17:00" },
        { "day_of_week": "Wednesday", "open_time": "09:00", "close_time": "17:00" },
        { "day_of_week": "Thursday", "open_time": "09:00", "close_time": "17:00" },
        { "day_of_week": "Friday", "open_time": "09:00", "close_time": "17:00" },
        { "day_of_week": "Saturday", "open_time": "10:00", "close_time": "14:00" },
        { "day_of_week": "Sunday", "all_day": "Closed" }
      ]
    },
    "routes": [
      {
        "key_press": "1",
        "name": "Office",
        "business_hours_routing": "During",
        "termination_number": "4045550100",
        "features": {
          "call_record": {
            "enabled": true,
            "record": true,
            "notification_text": "This call may be recorded."
          }
        }
      },
      {
        "key_press": "1",
        "name": "After hours",
        "business_hours_routing": "After",
        "termination_number": "4045550199",
        "features": {
          "whisper": {
            "enabled": true,
            "notification_text": "After hours call."
          }
        }
      },
      {
        "key_press": "default",
        "name": "Default",
        "default": true,
        "business_hours_routing": "Always",
        "termination_number": "4045550100"
      }
    ]
  }
}

Time of Day

Time of Day forwards the call based on the day and time it arrives. Each window is its own route. Calls that match no window use the default route.

Set call_record and whisper on features of the number. Per-route feature blocks are ignored. stop_call, call_verify, and call_tag_rules also go on the number.

Rules for call_routes.routes:

  • Include one default route: "default": true and "route_key": "default". Leave type, days, start_day, end_day, start_time, and end_time off that route.
  • Every other route needs route_key from 2 through 9, type, and a window.
  • type is Daily or Range.
  • Daily uses days: any of Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
  • Range uses start_day and end_day with the same day names.
  • start_time and end_time are HHMM in 24-hour time. Minutes are 00 or 30. end_time is later than start_time. Use 0000 as end_time when the window runs until midnight.
  • Windows cannot overlap.
  • Send at least two routes (one window plus the default) and no more than 10.

Daily covers the same clock time on the listed days. Range covers one span from start_day at start_time through end_day at end_time.

{
  "name": "Main line - time of day",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "features": {
    "call_record": {
      "enabled": true,
      "record": true,
      "notification_text": "This call may be recorded."
    },
    "whisper": {
      "enabled": true,
      "notification_text": "Call from the campaign."
    }
  },
  "call_routes": {
    "route_type": "TimeOfDay",
    "routes": [
      {
        "route_key": "2",
        "name": "Weekday office",
        "type": "Daily",
        "days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
        "start_time": "0900",
        "end_time": "1700",
        "termination_number": "4045550100"
      },
      {
        "route_key": "default",
        "name": "After hours",
        "default": true,
        "termination_number": "4045550199"
      }
    ]
  }
}

A weekend range uses type Range on its own route:

{
  "route_key": "3",
  "name": "Weekend",
  "type": "Range",
  "start_day": "Saturday",
  "end_day": "Sunday",
  "start_time": "1000",
  "end_time": "1600",
  "termination_number": "4045550188"
}

Follow Me

Follow Me tries destinations in order. Each route rings for ring_count rings (2 through 8). If nobody answers, the next ordinal is tried. Routes that share an ordinal ring at the same time, and they must use the same ring_count.

ordinal starts at 1 and increases by 1 with no gaps, up to 10. Send at least two routes and no more than 10.

Set call_record and whisper on features of the number. Per-route feature blocks are ignored. The same recording and whisper apply to every step.

business_hours_routing (During, After, or Always) is optional. See Business Hours for the schedule.

{
  "name": "Main line - follow me",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "features": {
    "call_record": {
      "enabled": true,
      "record": true,
      "notification_text": "This call may be recorded."
    },
    "whisper": {
      "enabled": true,
      "notification_text": "Call from the website."
    }
  },
  "call_routes": {
    "route_type": "FollowMe",
    "routes": [
      {
        "name": "Front desk",
        "ordinal": 1,
        "ring_count": 4,
        "business_hours_routing": "Always",
        "termination_number": "4045550100"
      },
      {
        "name": "On call",
        "ordinal": 2,
        "ring_count": 4,
        "business_hours_routing": "Always",
        "termination_number": "4045550199"
      }
    ]
  }
}

To ring two phones together before falling through, give both the same ordinal and the same ring_count, then use the next ordinal for the fallback.


Caller Segmentation

Caller Segmentation plays a prompt and forwards the call based on the key the caller presses. In the API this route type is KeyPress.

Put the prompt on call_routes.notification_text or call_routes.notification_file. When Business Hours is in use, after_business_hours_notification_text or after_business_hours_notification_file is the prompt played outside the open window.

Each route sets key_press:

  • A digit the caller presses, such as "1" or "2".
  • "default" for callers who do not press a key. Set "default": true on that route. A menu can have one default route.
  • "other" for any other key.

Send at least two routes and no more than 25. The same key_press cannot appear twice for the same business_hours_routing value.

Set call_record and whisper on call_routes.routes[].features for the keys that need them. Omit the block on a key that should not record or whisper. If a route omits one of those features, it inherits the value from features on the number. stop_call, call_verify, and call_tag_rules stay on the number.

{
  "name": "Main line - caller segmentation",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "call_routes": {
    "route_type": "KeyPress",
    "notification_text": "Press 1 for sales. Press 2 for support.",
    "routes": [
      {
        "key_press": "1",
        "name": "Sales",
        "termination_number": "4045550101",
        "features": {
          "call_record": {
            "enabled": true,
            "record": true,
            "notification_text": "This call may be recorded."
          },
          "whisper": {
            "enabled": true,
            "notification_text": "Sales call."
          }
        }
      },
      {
        "key_press": "2",
        "name": "Support",
        "termination_number": "4045550102",
        "features": {
          "whisper": {
            "enabled": true,
            "notification_text": "Support call."
          }
        }
      },
      {
        "key_press": "default",
        "name": "Default",
        "default": true,
        "termination_number": "4045550100"
      }
    ]
  }
}

Geographic

Geographic routing forwards the call based on the caller's area code, or area code and exchange. In the API this route type is Geo.

Each route sets geo_route:

  • A 3-digit area code, such as "404".
  • A 6-digit area code plus exchange, such as "404555".
  • "DEFAULT" for callers whose area code matches no other route. One DEFAULT route is required.
  • "NOCLID" for calls with no caller ID. One NOCLID route is required.

The same geo_route cannot appear twice for the same business_hours_routing value. Send at least two routes and no more than 10, including DEFAULT and NOCLID.

Set call_record and whisper on call_routes.routes[].features for the area codes that need them. stop_call, call_verify, and call_tag_rules stay on the number. Leave call_record and whisper off the number-level features object so they do not replace the per-route settings.

business_hours_routing is optional. See Business Hours.

{
  "name": "Main line - geographic",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "call_routes": {
    "route_type": "Geo",
    "routes": [
      {
        "name": "Atlanta",
        "geo_route": "404",
        "business_hours_routing": "Always",
        "termination_number": "4045550100",
        "features": {
          "call_record": {
            "enabled": true,
            "record": true,
            "notification_text": "This call may be recorded."
          }
        }
      },
      {
        "name": "New York",
        "geo_route": "212",
        "business_hours_routing": "Always",
        "termination_number": "2125550100"
      },
      {
        "name": "Default",
        "geo_route": "DEFAULT",
        "business_hours_routing": "Always",
        "termination_number": "4045550199"
      },
      {
        "name": "No caller ID",
        "geo_route": "NOCLID",
        "business_hours_routing": "Always",
        "termination_number": "4045550199"
      }
    ]
  }
}

Zip Code

Zip Code routing prompts the caller to enter a ZIP code, then forwards the call using that ZIP. In the API this route type is ZipCode.

Put the prompt on call_routes.notification_text or call_routes.notification_file. One of those is required.

Each route sets zip_code to a 5-digit ZIP, or "DEFAULT" for any ZIP that has no route of its own. One DEFAULT route is required. The same ZIP, termination number, extension, and business_hours_routing combination cannot be repeated.

Set call_record and whisper on call_routes.routes[].features for the ZIP codes that need them. stop_call, call_verify, and call_tag_rules stay on the number.

business_hours_routing is optional. See Business Hours.

{
  "name": "Main line - zip code",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "call_routes": {
    "route_type": "ZipCode",
    "notification_text": "Please enter your five digit zip code.",
    "routes": [
      {
        "name": "Midtown",
        "zip_code": "30309",
        "business_hours_routing": "Always",
        "termination_number": "4045550100",
        "features": {
          "call_record": {
            "enabled": true,
            "record": true,
            "notification_text": "This call may be recorded."
          },
          "whisper": {
            "enabled": true,
            "notification_text": "Caller in 30309."
          }
        }
      },
      {
        "name": "Default",
        "zip_code": "DEFAULT",
        "business_hours_routing": "Always",
        "termination_number": "4045550199"
      }
    ]
  }
}

Basic

Basic routing forwards every call to one termination number. Use call_routes.route (singular). There is no routes array.

Set call_record and whisper on call_routes.route.features. Set stop_call, call_verify, scheduled_call_verify, and call_tag_rules on features of the number. scheduled_call_verify is only accepted for Basic.

{
  "name": "Main line",
  "phone_number_request": {
    "match_type": "TollFree"
  },
  "features": {
    "call_verify": {
      "enabled": true,
      "notification_text": "Press 1 to connect your call.",
      "key_press": 1
    }
  },
  "call_routes": {
    "route_type": "Basic",
    "route": {
      "termination_number": "4045550100",
      "features": {
        "call_record": {
          "enabled": true,
          "record": true,
          "notification_text": "This call may be recorded."
        },
        "whisper": {
          "enabled": true,
          "notification_text": "Call from the website."
        }
      }
    }
  }
}