# API overview

The UrbeStack API provides 374 operations across 286 paths in 23 groups, with 310 named data types. It accepts and returns JSON.

The web interface uses this same API, making every panel operation available programmatically. An OpenAPI 3 specification is available on every UrbeStack server at `/usr/local/urbestack/openapi.json`.

## Base URL

On a new server, the API is reachable only from the server itself. Once an administrator opens the API to external requests, it is also reachable on the web interface’s port. The URLs below use the default ports, 8442 for `panel.api_local_port` and 8443 for `panel.port`. Run `urbestack-setting-get --key panel.port` to see which port your server uses for the web interface. [Opening the API](https://urbestack.com/docs/index.md#opening)

```
On the server   http://127.0.0.1:8442/api
Once opened     https://your-server:8443/api
```

The example requests in this documentation use $API for the base URL and $TOKEN for the token. Set both once in your shell to run any example as copied.

```
API=https://your-server:8443/api
TOKEN=ub_9f3c2a7e1b5d4082a6c1e7f0
```

## Tokens and scopes

API requests are authenticated using a token in the Authorization: Bearer TOKEN header. You can create a token using [urbestack-token-create](https://urbestack.com/docs/commands/urbestack-token-create.md) at the shell or obtain one through [POST /auth/login](https://urbestack.com/docs/api/post-auth-login.md).

A token’s permissions are limited by both the user’s permissions and the scopes assigned to the token. Each documented operation specifies its required scope. The read scope is sufficient for GET requests.

```
curl "$API/domains" \
  -H "Authorization: Bearer $TOKEN"
```

The 14 scopes: `read`, `domains`, `dns`, `certificates`, `mail`, `databases`, `files`, `users`, `backups`, `settings`, `security`, `export`, `license`, `all`

## Errors

Errors are returned with an HTTP status code and a descriptive message. Each operation documents its possible errors. You can also search for an error message to find the operations that return it.

```
HTTP/1.1 409 Conflict
Content-Type: application/json

{"error": "Domain 'example.com' already exists", "status": 409}
```

## Groups

- [auth](https://urbestack.com/docs/api/group/auth.md): 14 operations
- [users](https://urbestack.com/docs/api/group/users.md): 23 operations
- [domains](https://urbestack.com/docs/api/group/domains.md): 20 operations
- [dns](https://urbestack.com/docs/api/group/dns.md): 51 operations
- [settings](https://urbestack.com/docs/api/group/settings.md): 3 operations
- [php](https://urbestack.com/docs/api/group/php.md): 9 operations
- [jobs](https://urbestack.com/docs/api/group/jobs.md): 4 operations
- [export](https://urbestack.com/docs/api/group/export.md): 8 operations
- [certificates](https://urbestack.com/docs/api/group/certificates.md): 7 operations
- [mail](https://urbestack.com/docs/api/group/mail.md): 81 operations
- [security](https://urbestack.com/docs/api/group/security.md): 36 operations
- [license](https://urbestack.com/docs/api/group/license.md): 3 operations
- [updates](https://urbestack.com/docs/api/group/updates.md): 6 operations
- [databases](https://urbestack.com/docs/api/group/databases.md): 14 operations
- [files](https://urbestack.com/docs/api/group/files.md): 30 operations
- [cron](https://urbestack.com/docs/api/group/cron.md): 5 operations
- [backups](https://urbestack.com/docs/api/group/backups.md): 17 operations
- [foreign](https://urbestack.com/docs/api/group/foreign.md): 8 operations
- [move](https://urbestack.com/docs/api/group/move.md): 9 operations
- [services](https://urbestack.com/docs/api/group/services.md): 9 operations
- [web-server](https://urbestack.com/docs/api/group/web-server.md): 2 operations
- [load](https://urbestack.com/docs/api/group/load.md): 8 operations
- [plugins](https://urbestack.com/docs/api/group/plugins.md): 7 operations
