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:
- Do the basic auth to recieve JWT tokens
- 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:
- “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:
When sending the authenticated request, use THE ACCESS TOKEN in the auth header:
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.
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:
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
- 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.