# Authorization

Before we use any of the API methods, we will have to authenticate with our username and password and to receive Auth-token. This token will be used for all other requests to the API.

API_URL/auth

Request (CURL):

curl -X POST  -F "username=USERNAME" -F "password=PASSWORD" "API_URL/auth"

Input parameters:

username - string 
password - string

Success-Reponse (JSON):

{
	"result": true,
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODYxMTY0MDYsInVzZXJuYW1lIjoieXVrc2VsIn0.ZWXvA"
}

Error (JSON):

{
	"msg": "Username/password is not correct",
	"result": false
}

# Get domains

It's will give list of all availible domains used for the email accounts.

API_URL/domains

Request (CURL):

curl -X GET -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" "API_URL/domains"

Success-Reponse (JSON):

{
   "domains":[
		{
			"id":1,
			"name":"example.com",
			"users_count":5
		},
		{
			"id":2,
			"name":"anotherexample.com",
			"users_count":3
		},
		...
   ]
}

# Export domain

Export the data corresponding to a domain name in archived file.

API_URL/export/domain

Request (CURL):

curl -X GET -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "domain=example.com" "API_URL/export/domain"

# Get users

Return all users for a domain with specific id.

API_URL/users/:domain_id

Request (CURL):

curl -X GET -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" "API_URL/users/DOMAIN_ID"

Input parameters:

domain_id - id of domain

Success-Reponse (JSON):

{
   "users":[
		{
			"id":1,
			"domain_id":1,
			"email":"admin@example.com"
		}
   ]
}

# Add DKIM

Generate DKIM based on a passed domain name.

API_URL/dkim/add-new-domain

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "domain=example.com" "API_URL/dkim/add-new-domain"

Input parameters:

domain - string

# Create domain and add email account

This method will create a new domain and it will add a new email account to it.

API_URL/domains

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "domain=alsoanotherexample.com" -F "username=USERNAME" -F "password=PASSWORD" "API_URL/domains"

Input parameters:

domain - string
username - string (email)
password - string

# Create user

Create a new email account.

API_URL/user/:domain_id

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "email=EMAIL" -F "password=UNENCRYPTED_PASS" "API_URL/user/DOMAIN_ID"

Input parameters:

domain_id - id of the domain name
email - email address of the new user
password - unencrypted password

# Change user's password

Change the user's password.

API_URL/user-change-password

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "id=USER_ID" -F "password=NEW_UNENCRYPTED_PASS" -F "domain_id=DOMAIN_ID" "API_URL/user-change-password"

Input parameters:

id - Id of the user
password - New unencrypted password
domain_id - id of domain

# Generate Letsencrypt certificate

Generate a new Let's Encrypt certificate for a chosen hostname.

API_URL/ssl/letsencrypt/install

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "hostname=example.com" "API_URL/ssl/letsencrypt/install"

Input parameters:

hostname - domain name for which we will generate a Let's encrypt certificate

# Get left days for Letsencrypt certificate

Get the days left before the expiration of the Letsencrypt certificate.

API_URL/ssl/get-left-days

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "hostname=example.com" "API_URL/ssl/get-left-days"

Input parameters:

hostname - domain name for which we will make the check

# Upload SSL

Upload your own SSL certificate.

API_URL/ssl/upload

Request (CURL):

curl -X POST -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" "API_URL/ssl/upload"

Input parameters:

ssl_certificate - SSL certificate
ssl_certificate_key - SSL certificate key

# Delete domain

Delete a chosen domain.

API_URL/domain

Request (CURL):

curl -X DELETE -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "domain=example.com" "API_URL/domain"

Input parameters:

domain - domain name which will be deleted

# Delete user

Delete a chosen user.

API_URL/users

Request (CURL):

curl -X DELETE -H "Auth-token: TOKEN" -H "Cache-Control: no-cache" -F "email=someemail@example.com" "API_URL/users"

Input parameters:

email - email address corresponding to the user who will be deleted



If you have any issues and questions during the Installation, we would like to hear them and to help.

Slack