Skip to content

Znuny REST API – Setup, Endpoints & Examples

In this guide: Activate and use the Znuny REST API (Generic Interface) for automation, monitoring, self-service, and AI platforms like OpenTicketAI.

Related: Web Services · Znuny Docker · Add-ons & plugins · OpenTicketAI for Znuny

The Znuny REST API is part of the Generic Interface — the main integration layer for automation, monitoring hooks, portals, and on-premise AI such as OpenTicketAI. Traffic uses HTTP(S) and JSON.

:::tip AI automation instead of manual REST coding? To classify and route tickets automatically, use the OpenTicketAI Runtime — Docker on-premise, connected via the same REST API. See section 7 below. :::

Znuny exposes the Generic Interface via REST and SOAP. The REST API supports:

  • Ticket operations — create, read, update, delete
  • Articles — posts and attachments
  • History & search — ticket history and filtered search

Note: A fresh install has no pre-configured web services. Create them under Processes & Automation → Web Services in the admin area.

  1. SysConfigGenericInterface.Transport → select REST (HTTP).
  2. Under AdminGenericInterfaceTransportHTTPREST, set timeouts, host header, and debug level.
  3. In GenericInterface.Operation, define operations (e.g. TicketCreate, TicketSearch, TicketGet, TicketUpdate, TicketDelete, TicketHistoryGet) and activate them.
  • Base URL (adjust path for your install):

    https://YOUR-SERVER/znuny/nph-genericinterface.pl/Webservice/<YourServiceName>/

    Some installs use /otrs/ instead of /znuny/ — verify in the web service configuration.

  • Authentication

    • Znuny session (SessionID) or UserLogin + Password
    • API keys / tokens (via SysConfig and requester setup)
    • Always use HTTPS in production
  1. Admin → Web ServicesAdd Web Service
  2. Define REST provider with the operations you need
  3. Optionally configure a requester for outbound calls
  4. Save and use the debugger when troubleshooting

More on the Generic Interface: Web Services.

URLs follow /Webservice/<ServiceName>/<OperationName>. Parameters and responses are typically under a JSON Data object.

URL: /Webservice/<ServiceName>/TicketCreate · Method: POST

Creates a ticket and the first article.

ParameterTypeRequiredDescription
SessionIDIntegerYes¹Session ID or UserLogin+Password
UserLoginStringYes²Agent login
PasswordStringYes²Password
Ticket.TitleStringYesSubject
Ticket.QueueStringYesQueue name or ID
Ticket.StateStringYese.g. new
Ticket.PriorityStringYese.g. 3 normal
Ticket.CustomerUserStringYesCustomer email or login
Article.SubjectStringYesFirst article subject
Article.BodyStringYesBody text
Article.MimeTypeStringYestext/plain or text/html

¹ SessionID or UserLogin+Password. ² When no SessionID.

Example request:

POST /znuny/nph-genericinterface.pl/Webservice/MyConnectorREST/TicketCreate HTTP/1.1
Host: znuny.example.com
Content-Type: application/json
{
"UserLogin": "agent",
"Password": "secret",
"Ticket": {
"Title": "Server unreachable",
"Queue": "Support",
"State": "new",
"Priority": "3 normal",
"CustomerUser": "customer@example.com"
},
"Article": {
"Subject": "Initial report",
"Body": "The server has not responded since 08:00.",
"MimeType": "text/plain"
}
}

Example response:

{
"TicketID": "12345",
"ArticleID": "67890",
"Error": {
"ErrorCode": "",
"ErrorMessage": ""
}
}

URL: /Webservice/<ServiceName>/TicketSearch · Method: GET or POST (depends on mapping)

ParameterTypeRequiredDescription
UserLoginStringYes¹With Password or SessionID
PasswordStringYes¹
SessionIDIntegerYes¹
TitleStringNoWildcard, e.g. %Server%
QueueIDsInteger[]NoQueue IDs
StatesString[]Nonew, open, …
LimitIntegerNoMax results

Example request (GET, URL-encoded):

GET /znuny/nph-genericinterface.pl/Webservice/MyConnectorREST/TicketSearch?UserLogin=agent&Password=secret&Title=%Server% HTTP/1.1
Host: znuny.example.com

Example response:

{
"TicketID": ["12345", "12346"],
"Error": {
"ErrorCode": "",
"ErrorMessage": ""
}
}

URL: /Webservice/<ServiceName>/TicketGet

Returns ticket details including articles and optional dynamic fields. Key parameters: TicketID, AllArticles, Attachments, DynamicFields.

URL: /Webservice/<ServiceName>/TicketUpdate

Updates ticket fields and can add a new article. Parameters: TicketID, Ticket.State, Ticket.Queue, Article.Body, dynamic fields.

URL: /Webservice/<ServiceName>/TicketDelete

Permanently deletes ticket(s). Parameter: TicketID (string or array).

URL: /Webservice/<ServiceName>/TicketHistoryGet

History for one or more TicketID values.

  • Responses often include Error.ErrorCode and Error.ErrorMessage
  • Set Debug-Level to Debug in the web service debugger for database log entries
  • On 401/403: check credentials, requester mapping, and HTTPS
ScenarioDescription
MonitoringTickets from Nagios, Zabbix, Prometheus
CRM syncFields and state from external CRM
Self-serviceCustomer portal creates tickets via REST
AI routingOpenTicketAI reads and writes via REST

Typed client znuny for TicketCreate, Search, Update. Full guide: OpenTicketAI Znuny Python SDK.

Terminal window
pip install znuny
from znuny import BasicAuth, ClientConfig, TicketOperation, ZnunyClient
from znuny import Article, Ticket, TicketCreate
client = ZnunyClient(
ClientConfig(
base_url="https://znuny.example.com",
webservice_name="MyWebservice",
operation_url_map={
TicketOperation.CREATE: "ticket-create",
TicketOperation.GET: "ticket-get",
TicketOperation.SEARCH: "ticket-search",
TicketOperation.UPDATE: "ticket-update",
},
)
)
client.login(BasicAuth(user_login="agent", password="secret"))
response = client.create_ticket(
TicketCreate(
Ticket=Ticket(
Title="Server unreachable",
Queue="Support",
State="new",
Priority="3 normal",
CustomerUser="customer@example.com",
),
Article=Article(
Subject="Initial report",
Body="The server has not responded since 08:00.",
MimeType="text/plain",
),
)
)
print(response.TicketID)

More packages on OpenITSMHub: Python REST API Client, pyznuny.

To automate the Znuny REST API with AI, use the OpenTicketAI Runtime — on-premise classification, prioritization, and routing.

Incoming mail / REST ──► Znuny (Generic Interface)
OpenTicketAI Runtime (Docker)
TicketUpdate / routing via REST

Install:

Terminal window
pip install open-ticket-ai otai-hf-local otai-znuny-znuny
PackageRole
open-ticket-aiOrchestration, pipelines
otai-hf-localLocal AI models
otai-znuny-znunyZnuny REST connector

Example config.yaml:

connector:
type: znuny
url: https://znuny.example.com
username: otai-bot
password: "${ZNUNY_PASSWORD}"
model:
provider: hf-local
model_name: softoft/ticket-classifier-de
routing:
default_queue: "Unclassified"
rules:
- category: "Network"
queue: "IT-Infrastructure"
priority: "4 high"
FeatureManual RESTOpenTicketAI + connector
ClassificationManualFully automatic (AI)
Data protectionLocal100% on-premise
Setup effortHighYAML config

Learn more: openticketai.com/solutions/znuny/ · OpenTicketAI docs · Softoft demo

The Znuny REST API is flexible and extensible via the Generic Interface. With proper web services, HTTPS, and optionally OpenTicketAI or the Python SDK, you integrate Znuny cleanly into your stack and AI strategy.