# Handle Incoming Calls Based on Caller ID

You can give an individual extension its own set of rules that decide what happens to a call based on who is calling. Each rule matches an incoming Caller ID (from a colleague or an external contact) and applies an action such as sending the call to voicemail, playing a greeting, or hanging up. This is a practical way to silence spam numbers while still letting trusted callers through.

## Add a call handling rule

1. In the management portal, go to **Extension and Trunk > Extension** and open the extension you want to configure for editing.
2. Select the **Features** tab.
3. Find the **Call Handling Based on Caller ID** section and build one or more rules:

   a. Click **Add**.

   b. In the **Caller ID** field, type the number or number pattern the rule should match.
      - For a single caller, enter the exact number. For example, `10086` matches only calls that arrive with the Caller ID 10086.
      - For a group of callers, enter a wildcard pattern. For example, `9011.` matches any Caller ID that begins with 9011. See [Caller ID Pattern](/pbx/administrator-guide/did-pattern-and-caller-id-pattern/#reference_llf_541_2mb__section_ibp_2q1_2mb) for the full syntax.

   c. From the **Action** drop-down list, choose what the system does with a matching call:
      - **Hang Up**: end the call immediately, without ringing the extension.
      - **Extension**: route the call to an extension.
      - **Voicemail**: send the caller straight to voicemail.
      - **IVR**: hand the caller to an IVR (Interactive Voice Response) menu, the automated attendant that plays options such as "press 1 for sales".
      - **Play Greeting then Hang up**: play a recorded message to the caller, then end the call.
      - **Accept Call**: let the call through, even when a broader rule would otherwise block it.

   d. Click **Save**.

   e. Optional: To create additional rules, repeat steps a through d.

   f. Optional: Use the **Move** column to reorder the rules. They are evaluated from the top down.

4. Click **Save**, then **Apply**.

:::note
Every incoming call is allowed to reach the extension by default. **Accept Call** is useful when a broad blocking rule would otherwise catch a number you trust. For instance, if one rule rejects spam calls from `728373XX`, you can add a separate rule that accepts calls from `72837300`.
:::

:::tip
Because rules run top to bottom, order matters. Place the "Accept calls from `72837300`" rule above the "Reject calls from numbers starting with `728373`" rule. Calls from 72837300 then ring the extension, while every other number that starts with 728373 is hung up.
:::

## Result

From now on, the system inspects the Caller ID of each incoming call and handles it according to the rules you defined for the extension.
