VICIdial non-agent API: set up the user and test it
Turn on VICIdial's non-agent API in admin.php: the user settings it checks, a first test request, what each error reply means, and where the password ends up.

To the point
VICIdial's non-agent API is one web script, non_agent_api.php, that answers plain-text requests to add leads, read campaigns and much more. To use it:
- In admin.php, give one user Agent API Access 1, a User Level of 8 or more, and only the API functions your tool needs.
- Test with
function=version, then with a function that needs the login, such ascampaigns_list. - Read the reply. Every refusal starts with
ERROR:and names the check that failed.
What the non-agent API is
The script sits beside admin.php, at /vicidial/non_agent_api.php on your web server. A request carries four things, as URL parameters or as a form POST:
userandpass: a VICIdial user's login.source: a short name for whatever is calling, 2 characters or more.function: what to do, such asadd_lead,update_leadorcampaigns_list.- the parameters that function takes.
A refusal is one line: ERROR:, the reason, then values between | bars. A function that changes one record answers SUCCESS: the same way. A list function such as campaigns_list returns one line per item instead, with the fields between | bars. All of it is easy to read from a script, a form handler or a CRM.
Step 1: set up an API user in admin.php
Use a user of its own for each tool that calls the API, never an agent's or a manager's login.
- Add the user under Users > Add A New User, then open it under Users > Show Users > MODIFY. The API fields are on that page; you see them only if your own login is level 9 with Alter Admin Interface Options set to 1.
- Set User Level to 8 or more. Many functions refuse a lower level:
add_leadasks for more than 7 and Modify Leads set to 1, 2, 3 or 4, andcampaigns_listasks for more than 7 and View Reports on. - Set Agent API Access to 1. Its help text says it lets the account be used with the agent and non-agent API commands. With 0, every function after the login check refuses.
- In API Allowed Functions, pick only the functions the tool calls. The default, ALL_FUNCTIONS, lets this login call every function; each one still checks the user's level and its own permissions.
- Set API List Restrict to 1 if the tool should only touch lists in the campaigns its user group is allowed.
- Set API Only User to 1. The login then cannot open the admin screen or the agent screen, so a leaked password opens less.
- On a server with two-factor authentication on, set the user's Two Factor Auth Override to DISABLED, or every call gets "Login incorrect".
- Keep the user Active: the checks only count active users.
Step 2: send a first request
Start with the one function that needs no login:
https://192.0.2.10/vicidial/non_agent_api.php?function=version
It answers before any login check, with a line that starts VERSION: and carries the build, the date and the server's time zone. So it proves the address and the web server work, and nothing about your user.
Then test the user with a read-only function. Send it as a POST, so the password is not in the address bar or a proxy's log:
curl -s https://192.0.2.10/vicidial/non_agent_api.php \
-d source=crmtest -d user=apiuser -d pass=YOUR_PASSWORD -d function=campaigns_list
A good answer lists your campaigns. An ERROR: line tells you which check stopped it.
What each error reply means

| Reply starts with | What failed |
|---|---|
ERROR: Login incorrect, please try again | Wrong user or password, or the user is inactive, below User Level 7, or waiting for two-factor authentication (the reply ends ` |
ERROR: Too many login attempts, try again in 15 minutes | 10 failed logins lock the user for up to 15 minutes; until then even the right password gets this reply. Fix the password in the tool, then wait. |
ERROR: Your IP Address is not allowed | The login was right, but the address is not on the API IP Whitelist of the user's group, or it is on the System IP Blacklist. The reply shows the address the server saw. |
ERROR: USER DOES NOT HAVE API ACCESS | Agent API Access is 0 on this user. |
ERROR: auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION | The function is not in the user's API Allowed Functions. |
ERROR: campaigns_list USER DOES NOT HAVE PERMISSION... and the like | The function's own check: the user level, or a flag such as Modify Leads or View Reports. |
ERROR: Invalid Source | source was missing or shorter than 2 characters. |
ERROR: user_group DOES NOT EXIST | API List Restrict is on and the user's group is missing. |
Once the login has passed, each reply is also written to the vicidial_api_log table with its function, result and reason; only two list functions, sounds_list and moh_list, skip it when they succeed. A refused login leaves no row there. When a tool fails at night, that table says which reply it got after the login.
The password is written down
The script logs each request that passes the login. Logging is switched on in the script itself, and the request line it keeps is built from every parameter sent, the password included, whether you used GET or POST. That line goes into the vicidial_api_urls table. VICIdial keeps it: nothing in its standard crontab removes it. The log archive script, if you schedule it, moves old rows to vicidial_api_urls_archive in the same database, and only its trim options delete them.
So treat an API password as something your VICIdial database holds in plain text:
- Give each tool its own API user, so one password can be changed without breaking the others.
- Turn on API Only User and narrow API Allowed Functions, so the password opens as little as possible.
- Do not log the API's replies in full: a refused login sends the password back.
- Change the password when someone who had it leaves.
- Limit who can read the database and the API reports.
In the Trustane console: the Leads API
If what you need is leads arriving from web forms and tools, the console's Leads API does the VICIdial side for you. It gives a server a URL of its own, with a token instead of a VICIdial password; the token can travel in an X-Trustane-Key header, and it is shown once.
- Open Leads API in the console and pick the server and the list.
- Choose what happens to a phone already in the list: refuse it (the default), update it, or always add a new lead. The do-not-call check is on by default.
- Send a test request from your form, map its fields, and go live.
Behind the URL, Trustane calls VICIdial's own add_lead or update_lead on your server. The records keep field names, the outcome, the source address and the phone's last four digits, never a value from the form. Our own API calls are cleaned out of vicidial_api_urls right after each one.
For one lead at a time from your own code, the add_lead function and its options has the details. Loading a file instead? Load a CSV file into a list. Numbers in bulk use the same API: adding DIDs through the API.
- Start free for 7 days and send your first request to your own server.
VICIdial is a trademark of its owner. Trustane is an independent hosting provider.
Sources
- VICIdial non_agent_api.php, the login checks (lines 1678-1790) and per-function permissions, SVN r4038
- VICIdial admin.php, the API fields on Modify User (lines 28288-28309), SVN r4031
- VICIdial help text for Agent API Access, API List Restrict, API Only User and API Allowed Functions (lines 102-105), SVN r4038
- VICIdial table definitions, vicidial_api_log (line 2439), SVN r4038
- The Leads API contract and its limits
- How our own API calls are cleaned out of vicidial_api_urls
Every VICIdial guide and article in one place: the complete VICIdial guide.
Managed VICIdial hosting