> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/6.15/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.15/api-reference/subscriber_api.md).

# Subscriber API

TPOSS Subscriber API allows you to provision subscribers and manage them using these RPC methods:

- [Subscriber.Create](#subscribercreate) - to provision a new subscriber
- [Subscriber.Read](#subscriberread) - to fetch a subscriber by the given identifier
- [Subscriber.Delete](#subscriberdelete) - to delete a subscriber by the given identifier
- [Subscriber.Update](#subscriberupdate) - to update a subscriber by the given identifier
- [Subscriber.List](#subscriberlist) - to fetch a list of the subscribers filtered by the given criteria

## Data model

A subscriber is represented by an object with the following properties:

| Attribute | Type | Description
|---|---|---
| SubscriberId | string | Subscriber name.
| IbsId | string | Global Customer Platform ID (GCPID) that uniquely identifies a customer from the third party system IBS.
| UserId | string | Private user name.
| Username | string | Public user name.
| IMSI | string | Unique identifier of a SIM card.
| IMEI | string | Unique identifier of a user device (15 digits).
| ChargingAccountId | string | Unique identifier for the charging account.
| Carname | string | Alphanumeric name of the car. This name is an additional attribute for the user account.
| Homecountry | string | User home country code in the ISO 3166-1 Alpha-2 format.
| CustomerProfile | string | Allows you to group subscribers for selection.
| PortalVersion | uint64 | Integer value that allows you to specify a portal version per subscriber.
| PrimaryDNS | string | DNS server used for the given subscriber. It overwrites the `PrimaryDNS` from the service profile.
| SecondaryDNS | string | Secondary (fallback) DNS server used for the given subscriber. It overwrites the `SecondaryDNS` from the service profile.

## API methods

### Subscriber.Create

The method allows you to register a new subscriber with the given subscriber information. While `SubscriberId` and `UserId` must always be unique, a subscriber may be registered for multiple `UserId`. This means that the unique identification of a subscriber object is based on `SubscriberId` and `UserId`.

You can pass the following parameters in the request:

| Name | Type | Required / Optional | Description |
|---|---|---|---|
| AuthKey | string | required | Pre-shared authentication key. |
| FeId | string | required | Static frontend identifier which must be unique to the system. |
| FeSId | string | optional | Dynamic frontend session identifier which must be reset upon system startup. |
| IbsId | string | optional | Unique IBS identifier. |
| UserId | string | required | Private user name. |
| Username | string | required | Public user name. |
| IMSI | string | required | Unique IMSI of a SIM card. |
| IMEI | string | optional | Unique identifier of a user device (15 digits). |
| ChargingAccountId | string | required | Unique identifier of the charging account name. |
| Carname | string | optional | Name of a user car. |
| Homecountry | string | optional | User home country code in the ISO 3166-1 Alpha-2 format. |
| CustomerProfile | string | optional | Grouping criteria for subscribers usable for subscriber-specific selection. |
| PortalVersion | uint64 | optional | Determine the version of the portal instance used for this subscriber. |
| PrimaryDNS | string | optional | DNS server used for the given subscriber. It overwrites the `PrimaryDNS` from the service profile. |
| SecondaryDNS | string | optional | Secondary (fallback) DNS server used for the given subscriber. It overwrites the `SecondaryDNS` from the service profile. |

Example of the request:

```bash
curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://127.0.0.1:12000 --data-binary @- <<EOF
{
  "id": "1",
  "jsonrpc": "2.0",
  "method": "Subscriber.Create",
  "params": {
  "AuthKey": "secret",
  "FeId": "TPUIBrowser",
  "FeSId": "TPUIBrowser",
  "SubscriberId": "700030010@subscriber.<tenant>",
  "IbsId": "700030010@subscriber.<tenant>",
  "UserId": "701976710@user.<tenant>",
  "IMSI": "262019876543210",
  "IMEI": "354311050022709",
  "Username": "262019876543210",
  "ChargingAccountId": "700032310@account.charging.<tenant>",
  "Carname": "my car",
  "Homecountry": "DE",
  "CustomerProfile": "OEM Customer",
  "PortalVersion": 2,
  "PrimaryDNS": "8.8.8.8",
  "SecondaryDNS": "16.16.16.16"
  }
}
EOF
```

Example of the successful response:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "result": "true"
}
```

In the case of an error, the response contains the `error` object with an error code and message:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "error": {
    "code": "-33333",
    "message": "Not authenticated"
  }
}
```

The following error codes may be returned:

- `-30000` - Required field is missing.
- `-31404` - Duplicated subscriber.
- `-31405` - Duplicated user.
- `-31406` - Duplicated username.
- `-31409` - Duplicated IMSI.
- `-31804` - Charging account not found.
- `-32700` - Can't decode JSON request body.
- `-33333` - Not authenticated.

### Subscriber.Read

This method allows you to fetch the subscriber information based on the `UserId`. If the subscriber is not found, TPOSS returns an error.

You can pass the following parameters in the request:

| Name | Type | Required / Optional | Description |
|---|---|---|---|
| AuthKey | string | required | Pre-shared authentication key. |
| FeId | string | required | Static frontend identifier which must be unique to the system. |
| FeSId | string | optional | Dynamic frontend session identifier which must be reset upon system startup. |
| UserId | string | required | Private user name. |

Example of the request:

```bash
curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://127.0.0.1:12000 --data-binary @- <<EOF
{
  "id": "1",
  "jsonrpc": "2.0",
  "method":"Subscriber.Read",
  "params": {
    "AuthKey": "secret",
    "FeId": "TPUIBrowser",
    "FeSId": "TPUIBrowser",
    "UserId": "701976710@user.<tenant>"
  }
}
EOF
```

Example of the successful response:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "SubscriberId": "700030010@subscriber.<tenant>",
    "IbsId": "700030010@subscriber.<tenant>",
    "UserId": "701976710@user.<tenant>",
    "IMSI": "262019876543210",
    "IMEI": "354311050022709",
    "Username": "262019876543210",
    "ChargingAccountId": "700032310@account.charging.<tenant>",
    "Carname": "Emma’s car",
    "Homecountry": "DE",
    "CustomerProfile": "OEM Customer",
    "PortalVersion": 2,
    "PrimaryDNS": "8.8.8.8"
  }
}
```

In the case of an error, the response contains the `error` object with an error code and message:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "error": {
    "code": "-33333",
    "message": "Not authenticated"
  }
}
```

The following error codes may be returned:

- `-30000` - Required field is missing.
- `-31401` - Private user not found.
- `-32700` - Can't decode JSON request body.
- `-33333` - Not authenticated.

### Subscriber.Delete

The method allows you to delete all the information associated with the given subscriber and user identifiers. If the given subscriber is not found, TPOSS returns an error.

You can pass the following parameters in the request:

| Name | Type | Required / Optional | Description |
|---|---|---|---|
| AuthKey | string | required | Pre-shared authentication key. |
| FeId | string | required | Static frontend identifier which must be unique to the system. |
| FeSId | string | optional | Dynamic frontend session identifier which must be reset upon system startup. |
| SubscriberId | string | required | Subscriber name. |
| UserId | string | required | Private user name. |

Example of the request:

```bash
curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://127.0.0.1:12000 --data-binary @- <<EOF
{
  "id": "1",
  "jsonrpc": "2.0",
  "method":"Subscriber.Delete",
  "params": {
    "AuthKey": "secret",
    "FeId": "TPUIBrowser",
    "FeSId": "TPUIBrowser",
    "SubscriberId": "700030010@subscriber.<tenant>",
    "UserId": "701976710@user.<tenant>"
  }
}
EOF
```

Example of the successful response:

```json
{
  "id": "101",
  "jsonrpc": "2.0",
  "result": "true"
}
```

In the case of an error, the response contains the `error` object with an error code and message:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "error": {
    "code": "-33333",
    "message": "Not authenticated"
  }
}
```

The following error codes may be returned:

- `-30000` - Required field is missing.
- `-32700` - Can't decode JSON request body.
- `-31401` - Subscriber not found.
- `-33333` - Not authenticated.

### Subscriber.Update

The method allows you to update a subscriber using `SubscriberId` and `UserId`. If a subscriber is not found in the system, TPOSS returns an error.

You can pass the following parameters in the request:

| Name | Type | Required / Optional | Description |
|---|---|---|---|
| AuthKey | string | required | Pre-shared authentication key. |
| FeId | string | required | Static frontend identifier which must be unique to the system. |
| FeSId | string | optional | Dynamic frontend session identifier which must be reset upon system startup. |
| IbsId | string | optional | Unique IBS identifier. |
| IMSI | string | required | Unique IMSI of a SIM card. |
| IMEI | string | optional | Unique identifier of a user device (15 digits). |
| UserId | string | required | Private user name. |
| Username | string | required | Public user name. |
| ChargingAccountId | string | required | Unique identifier of a charging account. |
| Carname | string | optional | Name of a user car. |
| Homecountry | string | optional | User home country code in the ISO 3166-1 Alpha-2 format. |
| CustomerProfile | string | optional | Grouping criteria for subscribers usable for subscriber-specific selection. |
| PortalVersion | uint64 | optional | Determine the version of the portal instance used for this subscriber. |
| PrimaryDNS | string | optional | DNS server used for the given subscriber. It overwrites the `PrimaryDNS` from the service profile. |
| SecondaryDNS | string | optional | Secondary (fallback) DNS server used for the given subscriber. It overwrites the `SecondaryDNS` from the service profile. |

Example of the request:

```bash
curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://127.0.0.1:12000 --data-binary @- <<EOF
{
  "id": "1",
  "jsonrpc": "2.0",
  "method": "Subscriber.Update",
  "params": {
    "AuthKey": "secret",
    "FeId": "TPUIBrowser",
    "FeSId": "TPUIBrowser",
    "SubscriberId": "700030010@subscriber.<tenant>",
    "IbsId": "700030010@subscriber.<tenant>",
    "UserId": "701976710@user.<tenant>",
    "IMSI": "262019876543210",
    "IMEI": "354311050022709",
    "Username": "262019876543210",
    "ChargingAccountId": "700032310@account.charging.<tenant>",
    "Carname": "my car",
    "Homecountry": "DE",
    "CustomerProfile": "OEM Customer",
    "PortalVersion": 2,
    "PrimaryDNS": "8.8.8.8"
  }
}
EOF
```

Example of the successful response:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "result": "true"
}
```

In the case of an error, the response contains the `error` object with an error code and message:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "error": {
    "code": "-33333",
    "message": "Not authenticated"
  }
}
```

The following error codes may be returned:

- `-30000` - Required field is missing.
- `-31401` - Subscriber not found.
- `-31409` - Duplicated IMSI.
- `-32700` - Can't decode JSON request body.
- `-33333` - Not authenticated.

### Subscriber.List

The method allows you to fetch the list of subscribers based on the given criteria. If the number of results exceeds the internal query limit, only the initial subset is returned.

You can pass the following parameters in the request:

| Name | Type | Required / Optional | Description |
|---|---|---|---|
| AuthKey | string | required | Pre-shared authentication key. |
| FeId | string | required | Static frontend identifier which must be unique to the system. |
| FeSId | string | optional | Dynamic frontend session identifier which must be reset upon system startup. |
| Limit | uint16 | optional | Limits the size of the result. |
| Offset | uint16 | optional | Number of results skipped in the response. |
| Sort | string | optional | Defines the sorting order of the results based on a specific attribute. |
| Filter | string | optional | Defines a filter applied to the query results. |
| Fields | string | optional | Defines a list of fields which should be returned. |

The `Sort` field defines the order of sorting by the given field value. For example, to sort the subscribers by the `SubscriberId`, pass the `"Sort": "SubscriberId:asc"` parameter in the body request. The format is `FieldName:SortOrder`, where the `FieldName` represents the field name of a subscriber and the `SortOrder` value is `asc` or `desc`. The possible fields are listed in the [data model](#data-model) section.

The `Filter` field allows you to filter the subscribers. The filter format is: `FilterKey:FilterOperator:FilterValue`. The `FilterKey` represents the field name of a subscriber. The possible fields are listed in the [data model](#data-model) section. The `FilterOperator` could be one of the following values:

- `is` - equal to
- `neq` - not equal to
- `lte` - lower than or equal to
- `gt` - greater than
- `lt` - lower than
- `gte` - greater than or equal to
- `starts_with` - match objects which start with the given pattern
- `ends_with` - match objects which end with the given pattern
- `contains` - match objects which contain the given pattern

The value of the `FilterValue` parameter specifies what to filter from the results.

Example of the request:

```bash
curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://127.0.0.1:12000 --data-binary @- <<EOF
{
  "id": "1",
  "jsonrpc": "2.0",
  "method":"Subscriber.List",
  "params": {
    "AuthKey": "secret",
    "FeId": "TPUIBrowser",
    "FeSId": "TPUIBrowser",
    "Filter": "SubscriberId:is:700030010@subscriber.<tenant>"
  }
}
EOF
```

Example of the successful response:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "TotalResults": 1,
    "Subscribers": [
      {
        "SubscriberId": "700030010@subscriber.<tenant>",
        "IbsId": "700030010@subscriber.<tenant>",
        "UserId": "701976710@user.<tenant>",
        "IMSI": "262019876543210",
        "IMEI": "354311050022709",
        "Username": "262019876543210",
        "ChargingAccountId": "700032310@account.charging.<tenant>",
        "Carname": "Emma’s car",
        "Homecountry": "DE",
        "CustomerProfile": "OEM Customer",
        "PortalVersion": 2,
        "PrimaryDNS": "8.8.8.8"
      }
    ]
  }
}
```

In a case of an error, the response contains the `error` object with an error code and message:

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "error": {
    "code": "-33333",
    "message": "Not authenticated"
  }
}
```

The following error codes may be returned:

- `-30000` - Required field is missing.
- `-31411` - Invalid parameters in the request query. This error may occur under different circumstances, such as the wrong format of the `Filter` parameter or an unknown field passed to the `Fields`, `Sort`, or `Filter` parameters.
- `-32700` - Can't decode JSON request body.
- `-33333` - Not authenticated.
