Skip to end of metadata
Go to start of metadata


This article explains how to use APIs to create sub-account from a Master account available to partners.


After you create the sub-account you can login and create as many apps as needed in each sub-account.

Overall steps

You will need to:

  1. Do the basic auth to recieve JWT tokens
  2. Use 1 API call to create a sub-account for each 


To make you life easier-  we created a ready made Postman environment & library for these 2 API calls. Read on how to use it at the bottom of the article.


NOTE - PLEASE DO NOT DELETE OR MODIFY THE APP WITH ID = 1 in your Master account - as your partner account will not function without it.

______________

(1) Basic auth


To receive JWT tokens, use the following API method with the login and password from your Master account, an example:

GET https://ppp-admin.mbst.xyz/api/v8/[email protected]&password=123456

GET https://ppp-admin.mobsted.com/api/v8/[email protected]&password=123456


Where:

  • PPP-admin.mobsted.com” = is the address of your server and your account at our server, provided by our team
  • "login" is the email you use to login into partner account
  • "password" is the password you use to login into partner account 


In response you get access_token & refresh_tokens:

{
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwcHAtYWRtaW4ubWJzdC54eXoiLCJuYmxxxxxxxxxxxxxxxxxxxU5OTA0OTIwMywidWlkIjoiMmIzZTRiN2ItODVjOC00MzEwLWE4MTctM2FlMGJiYzQyMWJmIiwic3ViIjoiYXBpIiwib2JqdXVpZCI6IiIsInVzZXJ1dWlkIjoiMTdmZWU2YTUtZDk4My00OWZkLTg4OWMtMWI1NjlkMTg3YWNmIn0.eVOoDwJ7yh_TVb2j7FW7_jsTKT_SMJ8CFL10NX6RyXQ",

    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwcHAtYWRtaW4ubWJzdC54eXoiLCJuYmYiOjE1OTg0NDQ0MDMsImV4cCI6MTYwMDg2MzYwMywidWlkIjoiMmIzZTRiN2ItODVjOC00MzEwLWE4MTctM2FlMGJiYzQyMWJmIiwic3ViIjoiYXBpIiwib2JqdXVpZCI6IiIsInVzZXJ1dWlkIjoiMTdmZWU2YTUtZDk4My0xxxxxxxxxxxxxxxxjlkMTg3YWNmIn0.MDLMOEAE1ATYPBtMLsYCf2T8wzaYqNkB_1NSDsmLx_4",

    "expires_in": 1599049203
}



When sending the authenticated request, use THE ACCESS TOKEN in the auth header:

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwcHAtYWRtaW4ubWJzdC54eXoiLCJuYmYiOjE1OTg0xxxxxxxxxxxxxxxxxxxxxywidWlkIjoiMmIzZTRiN2ItODVjOC00MzEwLWE4MTctM2FlMGJiYzQyMWJmIiwic3ViIjoiYXBpIiwib2JqdXVpZCI6IiIsInVzZXJ1dWlkIjoiMTdmZWU2YTUtZDk4My00OWZkLTg4OWMtMWI1NjlkMTg3YWNmIn0.eVOoDwJ7yh_TVb2j7FW7_jsTKT_SMJ8CFL10NX6RyXQ


You can perform this auth action, starting with account’s login and password before every “client account/app” creation, but we advise to set up automatic JWT tokens refresh on your backend. 

___________


(2) API call - create a Client sub-account (i.e. server tenant)


This method is called in contexts of your Master account/tenant, meaning using API address and tokens from your Master. This method only works if our team marked your account as Master/Partner.


POST https://ppp-admin.mobsted.com/api/v8/partners

Type of parameters: raw (json)

An example:

{
    "email": "[email protected]"
}


Where, email is the email of who will access this new Client Account. It has to be a new unique email for every new sub-account/tenant.


Get the API response with auth data for that account. An example:

“url”: “https://a23r56k8-admin.mobsted.com”,

"authentication": {

     "email": "[email protected]",

     "phone": "",

     "password": "10ce7d73ae5fcc39g7064adc1ad03a03"


Where, URL contains the end point for the sub-account; authentication - logins/email and passwords for it.


This new Client Account/Tenant is recorded into Object’s table of your Master App ID=1, with the following fields:

  • ServerName (i.e. mobsted.com), TenantName (i.e a23r56k8), UserLogin = email, UserPassword.


This is done so you may not create any additional storage in your backend, but have access to all you sub-accounts visually or by API.

To use all other API methods, including to create an app in THAT NEW ACCOUNT, you need to receive JWT tokens for each of those accounts using the PRE-STEP above with address and login-password pair for that sub account.



(3) Using the Postman Library


(3.1) Download and install the Postman application

Or use it on the web, the choice is yours!

(3.2) Download the Postman environment and open it in Postman

Where:

  • fill in INITIAL VALUE column with your partner account URL + login + password - marked 1 above
  • set the current environment as active to perform all other API calls - marked 2 above


(3.3) Download the Postman library for partner API calls

Open it in Postman and DO/SEND the first API called "AUTH", marked red ↓:


(3.4) Then to create sub-account DO/SEND the second API called "partners"


Make sure to add a unique email for the new sub-account, marked red ↓

You will see in response, marked purple ↑ - a new URL for the sub-account and email/login and password. Save this info, as the only was to get it will be to do a password reset using the email.



Thats it. Now you can login using the URL and login/pass and create as many different applications as needed for your clients.