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.
You will need to:
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. |
______________
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:
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.
___________
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:
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.
Or use it on the web, the choice is yours!
Where:
Open it in Postman and DO/SEND the first API called "AUTH", marked red ↓:
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.
|