# 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.

URL: https://trustane.com/guides/vicidial-non-agent-api
By Trustane. Published 2026-11-29.

> **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:
>
> 1. **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.
> 2. **Test** with `function=version`, then with a function that needs the login, such as `campaigns_list`.
> 3. **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:

- `user` and `pass`: a VICIdial user's login.
- `source`: a short name for whatever is calling, 2 characters or more.
- `function`: what to do, such as `add_lead`, `update_lead` or `campaigns_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.

1. 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.
2. Set **User Level** to 8 or more. Many functions refuse a lower level: `add_lead` asks for more than 7 and **Modify Leads** set to 1, 2, 3 or 4, and `campaigns_list` asks for more than 7 and **View Reports** on.
3. 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.
4. 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.
5. Set **API List Restrict** to 1 if the tool should only touch lists in the campaigns its user group is allowed.
6. Set **API Only User** to 1. The login then cannot open the admin screen or the agent screen, so a leaked password opens less.
7. On a server with two-factor authentication on, set the user's **Two Factor Auth Override** to DISABLED, or every call gets "Login incorrect".
8. 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

![The replies VICIdial's non-agent API gives, from a working request to each refusal](https://trustane.com/media/caa72f5b9236a7a5-1600x750.webp "Each reply names the check that failed")

| 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 `|2FA|`). |
| `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.

1. Open **Leads API** in the console and pick the server and the list.
2. 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.
3. 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](https://trustane.com/blog/vicidial-add-lead-api) has the details. Loading a file instead? [Load a CSV file into a list](https://trustane.com/guides/vicidial-load-leads-csv). Numbers in bulk use the same API: [adding DIDs through the API](https://trustane.com/guides/vicidial-bulk-add-dids-api).

- [Start free for 7 days](https://trustane.com/signup) and send your first request to your own server.

VICIdial is a trademark of its owner. Trustane is an independent hosting provider.
