Spam call rejection
Screen inbound calls and reject known spam using your Server URL
Use your Server URL to filter inbound calls before they reach your assistant. When an inbound call arrives, Vapi can ask your server which assistant to use via an assistant-request
. In that moment, you can check the caller’s phone number against your spam list:
- If the number is flagged as spam: return an error message to be spoken to the caller and end the call.
- If the number is allowed: return a transient assistant configuration to proceed with the conversation.
Learn more about the request/response shapes on the Server events page.
How it works
- Configure a Server URL on the phone number, assistant, or organization.
- On inbound calls without a fixed
assistantId
(or if you prefer to decide dynamically), Vapi sends your server anassistant-request
webhook. - Your server validates the calling number and responds with either an
error
or anassistant
object.
Your server must respond within ~7.5 seconds or the call may fail.
Example implementation
Below is a simple example using Node.js/Express. It checks the inbound caller (E.164) against a local spam list, then either rejects with an error
or returns a transient assistant:
Response examples
- Reject with a spoken error message:
- Proceed with a transient assistant configuration:
Tips
- Keep your spam list in a database or use a reputation API for accuracy.
- If you prefer to use a saved assistant, return
{ "assistantId": "asst_..." }
instead of an inlineassistant
. - For local testing, see Developing locally.