> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/6.14/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/6.14/api-reference/api.md).

# TPOSS API gateway API

The TPOSS APIs follow a uniform design. This design is meant to ease adoption
and consumption of the different APIs a TPOSS service exposes. The APIs are
based on open protocols and common concepts to lower the barrier for developers.
If not stated otherwise, an API will follow the concepts laid out in this
chapter. This chapter describes first how standard Request-Response RPCs works
followed by a short introduction of JSONRPC 2.0, the messaging protocol used by
all TPOSS APIs. Then the APIs naming rules and versioning are defined and the
request authentication mechanism is presented. Finally common parameters of all
API methods are described and the different transports are described.

The TPOSS APIs define RPC methods for clients to use. All methods follow a
requestresponse pattern. Thus, whenever a client sends a request to the TPOSS
server it can expect a response for that request. How a response can be matched
to a particular request is defined by the underlying messaging protocol
described in the next section.

All APIs adhere to the JSON-RPC 2.0 protocol. The protocol itself is implemented
by client libraries in various programming languages. The JSON-RPC 2.0 protocol
specification defines the message flow between client and server. The TPOSS API
RPCs use the request-response flow as defined by the protocol. The notification
messages defined in JSON-RPC 2.0 aren’t used. Whenever APIs require
notification-like message behaviour, the normal request-response pattern is used
to support endpoint acknowledgement. Since JSON-RPC 2.0 defines a message
identification which can be used to match request-response pairs, it is possible
to multiplex RPCs calls between a single client and TPOSS server.

## Naming rules

Parameter and attribute names are written in camel case. For example:
`UserPublicId`, `ChargingAccountId`, `Sort`...

Method names are prefixed with the API namespace they are part of. For example:
`Subscriber.Read`, `Cdr.List`...

## Frontend identifiers

All API requests require clients to provide some information to identify
themselves against the API. These identifiers may be chosen by the clients and
are handled as opaque data by TPOSS. These identifiers are used by TPOSS for
request authorization, load balancing and logging. Two frontend identifiers need
to be passed by clients in any request.

- The `FeId` (Frontend Identifier) should be a static value associated with
  the client application. E.g. CFP12.
- The `FeSId` (Frontend Session Identifier) should be a dynamic value
  generated at startup of the client. It allows TPOSS to reason about
  malfunctional client behaviour and allows easier auditing of request logs.

## Authentication

TPOSS APIs are authenticated based on API-keys.

Before a client may authenticate with a TPOSS API, it needs to be given an
authentication key. Such a key needs to be provisioned by an operator. Then
the key needs to be shared with the client such that it can be used for
follow-up API request. This procedure is out-of-band and not handled by the
authentication API itself.

Once an authentication key has been obtained, a client can use it to perform

authenticated API requests. Most API methods will require an authentication
key to be passed along with other parameters. If a key is invalid, the server
will respond with a respective error message identifying the authentication
problem.

Each request should contain `AuthKey` field which will be used in combination
of `FeId` to authenticate user of the API.

## API parameters

All API methods have a set of defined input parameters that are describes in the
corresponding method section of this documentation. The parameters that marked
as `required` have to be passed to the method (and vice versa for `optional`
parameters). Input parameters that are not defined for the API method will be
ignored. These unknown values will be discarded, without any impact to the
result of the method execution. All values that are not valid for an API method
create log messages with the parameter and the value of the parameter at least
at logging level `debug`.

Most API methods support a set of common parameters to enable clients to narrow
down request result sets as needed. Refer to the individual API specifications
to find out which API methods support these parameters.

### Limit

The `Limit` allows the client to specify a upper limit to the size of the
result set. Obviously the order of results influences which objects are
delivered in the result set.

### Offset

The `Offset` allows the client to specify a number of objects which should be
skipped before collecting the result set entries. The offset will be taken into
account after any sorting is done.

### Sort

The `Sort` parameter allows to sort the result set according to an attribute
in the directions `asc` (ascending) or `desc` (descending). For example:

```
"Sort": "IMSI:asc"
```

This will sort the result set of an API request according to `IMSI` from
smaller values to higher values.

### Filter

The `Filter` parameter allows to apply specific filtering to session
attributes.

The following operations are supported for now:

- `is` - equal to
- `lte` - lower than or equal to
- `lt` - lower than
- `gte` - greater than or equal to
- `gt` - greater than
- `ends_with` - ends with given pattern
- `starts_with` - starts with given pattern
- `contains` - contains given pattern

The `ends_with`, `starts_with` and `contains` filter operators allows to
specify a pattern to match. For example:

.. code-block:: none

   "Filter": "IMSI:ends_with:5"
   "Filter": "Username:is:262019876543210"

And all of these three filter operators works only with string-like data but
not with dates, timestamps, IP addresses.

It's possible to specify more than one filter. The common separated filters
will be evaluated like logical ``and``.

For example:

```
"Filter": "NatIp:is:10.10.10.100,NatPortStart:lte:25140,NatPortEnd:gte:25140"
```

This filter may be used when having a need to get session by given NAT IP address
and one known NAT Port.

### Fields

The ``Fields`` parameter allows the client to specify a list of object attributes
(separated by colons) which should be returned by a query. This enables the
execution of efficient queries by removing attributes from the result set which
the client isn’t interested in.

For example:

```
"Fields": "Username"
"Fields": "Username:ChargingAccountId"
"Fields": "Username:ChargingAccountId:SubscriberId"
```

## Common Error Scenarios

- `Authentication key not valid` - If the authentication key can’t be verified
   for the calling client as identified through its frontend identifier, the
   server won’t allow a client to access the requested API method. In this case
   `-33333` error code will be returned.
- `Required field missed` - If a request should contain mandatory input
   parameters and at least one of them is missed, the server won't allow a
   client to access the requested API method. In this case `-30000` error
   code will be returned.
- `Type mismatch error` - If a request has input parameters and at least one
   of their values have wrong data type, the `-31810` error code will be
   returned with the related error message.
