When an external application receives a provisioning event, it connects to PortaBilling via the API to retrieve additional information about the modified entity and monitor provisioning statuses.
First, the application should call the session/login method of the PortaBilling API. The login request must contain a pair: a user login and password or a user login and API token (specified on the admin web interface).
Example
POST /rest/Session/login HTTP/1.1
Host: demo.portaone.com
Content-Type: application/json
Content-Length: 57 {
"params": {
"login": "demo",
"password": "exAmple"
}
}
In response to the session/login method, the API user (an external application) receives the following fields: "access_token", "expires_at", "refresh_token", and "session_id".
Example
{
"session_id": "fb48b180539529497f3475c71e0bdc66",
"refresh_token": "836466a06bef49c38305afc14e13e487",
"expires_at": "2022-08-28 13:07:30",
"access_token": "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2NjE2OTIwNTAsImlfdXNlciI6NDQwLCJpX2VudiI6NDEsImxvZ2luIjoiZGVtbyIsInNjb3BlcyI6ImVzcGYuYXBpOndyaXRlIGVzcGYuaGFuZGxlcnM6d3JpdGUiLCJpYXQiOjE2NjE1MTkyNTAsImp0aSI6ImZiNDhiMTgwNTM5NTI5NDk3ZjM0NzVjNzFlMGJkYzY2IiwicmVhbG0iOiJhZG1pbiIsImF1ZCI6WyJwb3J0YWJpbGxpbmctYXBpIiwicG9ydGFzaXAtYXBpIiwiZXNwZi1hcGkiXSwiaXNfc3VwZXJfdXNlciI6MH0.Qou3zbdFvF5bGup0tGrAvPAjoaeoeTMZQN3awMVOJAIKZGSLWL7kmhm3Xzjr05xZPQp3vrwtv4y4SygnXkzrcbYiIzzV-dcrANhRbOTnTPUMMU_t2rgNCG9Qo2eVzUv-4u_g1mVuBqx_8pIZs93g7C8-6O7XP_hg9Oo0BilB4W0jp0zjTxdp46sQ2aP2q7HZNLO6USL5vchxPGWPQp2VPL9cW4RRO71Ok2a4eGRir60ytvUz98fAlHtf-AUDFd3BkEltRN4BYyGGuWCeihengU0Z8DBucCmcQdAeUBbzo65D6V5ubSWOwUNvnjfHmmsqfS50G_7-GMKYaBqMfBRPmw"
}
We recommend performing authorization using an access token in the requests to the ESPF API.
For a detailed description of request and response parameters, refer to the PortaBilling API documentation.
Let’s say an existing subscriber has changed their SIM card. PortaBilling updates its profile and sends a request that a new SIM card has been assigned. In the background, the following happens:
- PortaBilling sends the POST request with the Account/SIMcardAssignment event type and the i_account to the application.
Date: Fri, 21 May 2018 13:28:08 GMT Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2NjE2OTIwNTAsImlfdXNlciI6NDQwLCJpX2VudiI6NDEsImxvZ2luIjoiZGVtbyIsInNjb3BlcyI6ImVzcGYuYXBpOndyaXRlIGVzcGYuaGFuZGxlcnM6d3JpdGUiLCJpYXQiOjE2NjE1MTkyNTAsImp0aSI6ImZiNDhiMTgwNTM5NTI5NDk3ZjM0NzVjNzFlMGJkYzY2IiwicmVhbG0iOiJhZG1pbiIsImF1ZCI6WyJwb3J0YWJpbGxpbmctYXBpIiwicG9ydGFzaXAtYXBpIiwiZXNwZi1hcGkiXSwiaXNfc3VwZXJfdXNlciI6MH0.Qou3zbdFvF5bGup0tGrAvPAjoaeoeTMZQN3awMVOJAIKZGSLWL7kmhm3Xzjr05xZPQp3vrwtv4y4SygnXkzrcbYiIzzV-dcrANhRbOTnTPUMMU_t2rgNCG9Qo2eVzUv-4u_g1mVuBqx_8pIZs93g7C8-6O7XP_hg9Oo0BilB4W0jp0zjTxdp46sQ2aP2q7HZNLO6USL5vchxPGWPQp2VPL9cW4RRO71Ok2a4eGRir60ytvUz98fAlHtf-AUDFd3BkEltRN4BYyGGuWCeihengU0Z8DBucCmcQdAeUBbzo65D6V5ubSWOwUNvnjfHmmsqfS50G_7-GMKYaBqMfBRPmw Host: 192.168.243.244:5000 Referrer: http://192.168.243.244:5000/ TE: trailers Content-Length: 83 Content-Type: application/json { "event_type": "Account/SIMcardAssignment", "variables": { "i_account": "1000889", "i_event": "6" } } - The application receives the request, verifies that the API session is active, and reuses the session ID for the request. Otherwise, the application establishes a new API session.
- The application uses the i_account and the session_id to call the following PortaBilling API methods:
- Account/get_account_info – to get the list of included services, account status, and account balance.
Used parameters:
auth_info={"session_id":"527865ee75368ff2d2c4f4881"} params={"i_account":1000889,"get_included_services":1}POST /rest/Account/get_account_info HTTP/1.1 Host: demo.portaone.com Content-Type: application/x-www-form-urlencoded Content-Length: 139 auth_info=%7B%22session_id%22%3A%22527865ee75368ff2d2c4f4881%22%7D¶ms=%7B%22i_account%22%3A1000889%2C%22get_included_services%22%3A1%7D
- SIMCard/get_card_list to get the MSISDN and IMSI.
Used parameters: auth_info={"session_id":"527865ee75368ff2d2c4f4881"} params={"i_account":1000889}
POST /rest/SIMCard/get_card_list HTTP/1.1 Host: demo.portaone.com Content-Type: application/x-www-form-urlencoded Content-Length: 105 auth_info=%7B%22session_id%22%3A%22527865ee75368ff2d2c4f4881%22%7D¶ms=%7B%22i_account%22%3A1000889%7D
- Account/get_account_info – to get the list of included services, account status, and account balance.
- Upon the response from PortaBilling, the application requests the SIM card details from HSS via its API.
- The application compares the SIM card parameters received from PortaBilling (MSISDN: 12065551122, IMSI: 310685901111133) with the ones received from the HSS (MSISDN: 12065551122, IMSI: 310685900000045).
- The application detects that the IMSI has changed from 310685900000045 to 310685901111133 and notifies the HSS to delete a subscriber with the IMSI 310685900000045.
- The application then instructs the HSS to add a new subscriber with the following parameters:
- MSISDN: 12065551122
- IMSI: 310685901111133
- Profile name: LTE
- If the application detects that the account’s status has changed to blocked or suspended, it notifies the HSS to block a SIM card. If the application detects that the account has no available funds or has reached the credit limit, it notifies the HSS to act respectively. Note that the actions here depend on the requirements of the HSS.
- Once the HSS is updated, the application responds to PortaBilling with 200 OK status code.
- The ESPF removes the event from the event queue.
Refer to the PortaBilling API for a more detailed description of API methods and their structures.
Commonly used PortaBilling API methods
Here is the list of the most commonly used API methods that will help you receive the necessary information from PortaBilling:
- Account/get_account_info – use this method to receive subscriber information, such as account ID (e.g., DID, MSISDN, IPv4 address, login), service password, the unique ID of the product (e.g., i_product) and name, activation and expiration dates, available funds, status (e.g., active/blocked/terminated), service policy (e.g., the unique ID of the access policy) and service features that are enabled for this subscriber, etcc.
- Account/get_custom_fields_values – use this method to receive custom information assigned to an account (e.g., db_value).
- Account/get_service_features_list – use this method to retrieve the list of service features that are available for an account.
- Product/get_product_info – use this method to receive product information such as unique IDs of included services (e.g., i_service), subscription (i_subscription) and volume discount plan (e.g., i_vd_plan), etc.
- Service/get_service_info – use this method to receive service details such as service name, rating base, etc.
- SIMCard/get_card_list – use this method to receive SIM card details such as MSISDN, IMSI and the unique ID of the SIM card (i_sim_card), etc.
- AccessPolicy/get_access_policy_info – use this method to receive Internet access policy details such as the unique ID of a service policy (i_service_policy), hotlining parameters, etc.
- ServicePolicy/get_service_policy_info – use this method to receive service policy details such as specific service attributes.
- DID/get_number_info – use this method to receive DID details such as cost and revenue, owner, batch, etc.
- Invoice/get_invoice_info – use this method to receive invoice details such as the status of the invoice (e.g., paid/partially paid/unpaid), the amount already paid by the customer, the amount that must be paid by the customer and the date when the invoice was generated, etc.
- Customer/get_customer_info – use this method to receive customer record details such as balance, billing status (e.g., active/blocked/suspended), billing period, personal information (e.g., salutation, name, address, etc.), cloud PBX configuration, etc.
Refer to the PortaBilling API guide for a more detailed description of API methods and their structures.