# Install the OTOBO API

> Install the REST-API package in Package Manager or with otobo.Console.pl, switch it on, and copy the bearer token.

- HTML: https://otobo-docs.softoft.de/en/otobo-api/installation/
- Markdown: https://otobo-docs.softoft.de/en/otobo-api/installation.md

The **OTOBO API** is the **REST-API** package. After install, Admin has **API**, **API reference**, and **Webhooks**. Calls go to `otai-api.pl/v1` and carry a bearer token.


  The manifest `REST-API-OTOBO.sopm` targets OTOBO 11.0.x and 11.1.x.


Source and the GPL-3.0 license: [openticketai/otobo_znuny_rest_api](https://github.com/openticketai/otobo_znuny_rest_api). Tokens and the admin route list are in the [REST API](https://otobo-docs.softoft.de/en/administration/automation/rest-api/) guide. After the token, continue with [authentication](https://otobo-docs.softoft.de/en/otobo-api/authentication/).

## Package file

The OTOBO manifest is `REST-API-OTOBO.sopm`. The build writes `REST-API-<version>.opm`. The version is the one in the manifest. Install that file.

From the cloned repository directory, on the OTOBO host. `otobo-web-1` is the web container of a Docker Compose install. Replace the name when your container is named differently.

```bash
docker cp . otobo-web-1:/tmp/otai-opm
docker exec otobo-web-1 /opt/otobo/bin/otobo.Console.pl \
  Dev::Package::Build --module-directory /tmp/otai-opm \
  /tmp/otai-opm/REST-API-OTOBO.sopm /tmp/otai-out
```

The file is then under `/tmp/otai-out/` inside the container. Copy it out when you want to upload it in Package Manager.

## Package Manager

1. Sign in as an administrator.
2. Open **Admin → Package Manager**.
3. Upload `REST-API-<version>.opm` as a local package and install it.

Package Manager checks the framework. If this OTOBO version is not 11.0.x or 11.1.x, install stops.

## Console

On a host that does not use that Docker name, the console is `/opt/otobo/bin/otobo.Console.pl`. The path is the `.opm` from the build.

```bash
/opt/otobo/bin/otobo.Console.pl Admin::Package::Install /path/REST-API-VERSION.opm
```

Replace `REST-API-VERSION.opm` with the file name `Dev::Package::Build` wrote.

## What install creates

Install creates the user `otai-webservice` when that login is missing. The account is in the **ai-agent** group, not in **users**, and cannot sign in to the agent interface. The password is random and is not shown. You do not supply a password before install.

**Admin → API** removes the **users** group again if someone adds it later. Grant FAQ categories to **ai-agent** when that user should read FAQ.

An upgrade removes the old Generic Interface webservices `OpenTicketAI`, `OpenTicketAI-RuntimeEvents`, and `OpenTicketAI-SearchEvents` when they are still installed. The API itself is not a webservice in that builder.

## Turn the API on

1. Open **Admin → API**.
2. Switch the API on. The switch is on after install.
3. Generate a token and copy it immediately. The screen does not show it again.
4. The package binds that token to a system user. What a call may do is that person's groups, roles, and queues. Change those on the user. The two token kinds are on [authentication](https://otobo-docs.softoft.de/en/otobo-api/authentication/).

Then send `Authorization: Bearer` and `Accept: application/json`.

## Check

Open **Admin → API reference**, or the same page in the browser:

```text
https://helpdesk.example.com/otobo/otai-api.pl/v1/docs
```

`helpdesk.example.com` is your helpdesk host. A first call:

```bash
curl -sS \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json" \
  "https://helpdesk.example.com/otobo/otai-api.pl/v1/tickets?state=new&limit=1"
```

`200` and JSON mean the package, the switch, and the token agree. `401` means a wrong, revoked, or expired token. One language per page: [Python](https://otobo-docs.softoft.de/en/otobo-api/python/), [TypeScript](https://otobo-docs.softoft.de/en/otobo-api/typescript/), [Java](https://otobo-docs.softoft.de/en/otobo-api/java/), and [PHP](https://otobo-docs.softoft.de/en/otobo-api/php/).

## Before the process starts

These variables are optional. SysConfig is the admin fallback when they are empty.

| Variable                     | Default           | Purpose                                 |
| ---------------------------- | ----------------- | --------------------------------------- |
| `OTAI_TICKETSYSTEM_USERNAME` | `otai-webservice` | API user login                          |
| `OTAI_WEBHOOK_URL`           | empty             | Where ticket and FAQ events are sent    |
| `OTAI_API_TOKEN`             | empty             | Webhook send token, if set before start |

## Frequently asked questions

### How do I install the OTOBO API?

Build the package file from the manifest REST-API-OTOBO.sopm. The result is named REST-API-, the version from the manifest, and .opm. Upload that file under Admin, Package Manager, or install it with otobo.Console.pl Admin::Package::Install.

Install creates the user otai-webservice when that login is missing. The account is in the ai-agent group, not in users, and cannot sign in to the agent interface. You do not type a password. Then open Admin, API, switch the API on, and copy the token. The screen shows it once.

- [Install the OTOBO API](https://otobo-docs.softoft.de/en/otobo-api/installation/)
- [openticketai/otobo_znuny_rest_api](https://github.com/openticketai/otobo_znuny_rest_api)
- [Package Manager](https://otobo-docs.softoft.de/en/administration/plugins/package-manager/)

### Which OTOBO version does the REST-API package support?

The manifest REST-API-OTOBO.sopm lists frameworks 11.0.x and 11.1.x. Install that manifest on OTOBO. The second manifest in the same repository is for a different ticket system and does not belong on this instance.

After install, open Admin, API reference, or otai-api.pl/v1/docs on the helpdesk. A call with Authorization Bearer and Accept application/json returns tickets once the token is valid.

- [Install the OTOBO API](https://otobo-docs.softoft.de/en/otobo-api/installation/)
- [openticketai/otobo_znuny_rest_api](https://github.com/openticketai/otobo_znuny_rest_api)
- [OTOBO Admin Manual](https://doc.otobo.org/manual/admin/11.0/en/content/index.html)
