SaaS API: creating, copying and getting API keys programmatically

SaaS API available on SaaS plan helps you to automate creation and configuring your users to have isolated environments: configuration, list of custom blocks, etc..

Create default configuration

Please integrate N1ED on some of your test account and configure N1ED as you wish. Save this configuration - it will be a template for any other API key you will create. You can always change it and this will affect to all new users you create API keys by this SaaS API.

Do not set your default (ends with DFLT) API key to your users, due to you will use it as template for them only.

Create API key for a new user

When you register somebody into your service, you expect it will have new API key. So you call a POST request to our server and save in your DB data our server returns.

Create new API key

URL (POST method): https://o.n1ed.com/saas-api/v1/conf/create

POST parameters:

  • saasToken - a secret token we gave to you, like "1234567890abcdef1234567890abcdef"

  • domain - a domain of a website you need to create API key for (without protocol or paths), for example: "user-website.com" or "user.your-saas.com" (if you create a subdomain for user). If you specify a domain which already exist, N1ED cloud will return existing API key.

  • copyFrom - optional parameter which specifies an API key to copy all the settings and custom blocks from. Specify here the API key you use as a configuration template, for example: XXXXDFLT. If you do not specify any key, API key will be created without copying settings from other configuration.

JSON response format:

{
   error: string, // will contain error description if something was wrong (you can also receive HTTP code 400 in case omit some required parameter)
   data: { // will be null in case of error is not null
       isNew: boolean, // was new API key created or existing one returned
       apiKey: string, // created or existing API key
       token: string   // write-access token for created configuration  
   }
}

When you receive such response, save data.apiKey and data.token from it into DB in the row with a user you create API key for. Then use them when you initialize N1ED for this user as parameters:

apiKey: "XXXXXXX", token: "xxxxxx-xxxxxx"

Setting the apiKey parameter will apply according configuration to a current user, token will grant him write access to configuration to avoid asking your account password when user wants to edit options or add own custom block.