Register User

Creates a new user and sends a confirmation message to a user’s email.

To create a new user, you need to Generate CAPTCHA first and then pass a token and a solved CAPTCHA in the request body.

You also have to set the field server.user.auth_enabled of a configuration file to true.

Request

HTTP Request

POST /node/api/users/signup

Permissions

manage-users

Path parameters

No parameters required.

Body parameters

Parameter Type Description

token

String
required

A token associated with the generated CAPTCHA. Returned by the Generate CAPTCHA request.

captcha

String
required

A solution to the CAPTCHA generated by the Generate CAPTCHA request.

email

String
required

User’s email.

login

String
required

User’s login.

password

String
required

User’s password.

Request body

Password must match the default Password Policy
{
    "token": "5c2ef019-cca8-40de-b306-050dd976c743",
    "captcha": "1qTY",
    "login": "user_login",
    "email": "user_email@example.com",
    "password": "1111"
}

Response

See the User model.

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/users/signup

curl -X POST $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
{
    "token": "5c2ef019-cca8-40de-b306-050dd976c743",
    "captcha": "1qTY",
    "login": "user_login",
    "email": "user_email@example.com",
    "password": "1111"
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/users/signup";
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify({
    "token": "5c2ef019-cca8-40de-b306-050dd976c743",
    "captcha": "1qTY",
    "login": "user_login",
    "email": "user_email@example.com",
    "password": "1111"
});

let requestOptions = {
    method: "POST",
    headers: headers,
    body: data
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log("error", error));
const http = require("http");

let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/users/signup";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "POST",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth,
        "Content-Type": "application/json"
    },
    "path": path
};

let req = http.request(options, function (res) {
    let chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        let body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

let data = JSON.stringify({
    "token": "5c2ef019-cca8-40de-b306-050dd976c743",
    "captcha": "1qTY",
    "login": "user_login",
    "email": "user_email@example.com",
    "password": "1111"
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/users/signup"

body = {
    "token": "5c2ef019-cca8-40de-b306-050dd976c743",
    "captcha": "1qTY",
    "login": "user_login",
    "email": "user_email@example.com",
    "password": "1111"
}

response = requests.request("POST", url, json=body, auth=(login, password))
print(response.text)

Response

{
    "login": "user_login",
    "email": "user_email@example.com",
    "status": 0,
    "eventFilter": [],
    "objectPermissions": {
        "include": [
            "817",
            "5e84d165866ec23538892f7d"
        ],
        "exclude": [
            "5e84d212866ec23538893061"
        ]
    },
    "permissions": [
        "manage-objects",
        "manage-links",
        "manage-service-properties",
        "view-section-stat",
        "view-section-monitoring",
        "view-section-history-graph"
    ],
    "contacts": [],
    "id": "5ec7ebe421ca22645150af09"
}