Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »



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

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 library for these 2 API calls. Download the library here, or read on how to use it down below.


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=12

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


(a) Download and install the Postman or use it on the web, it is your choice

(b) Download our collection into Postman

(c) Copy and paste your partner account's credentials into first Postman call:



(d) Do the first call to get authenticated


(e)  Copy and paste your parter account's credentials into the second Postman call:


(f) Do the second call and receive the new sub-account. 




  • No labels