Create User
Creating a user
Each Suggestic partner/client has the ability to create their own set of users.
Create and set up a user with the following information:
- Set up user's personal information such as name, email, phone, and birthdate.
- Set up a Password
- Set up a password via email
- Assing a subscription
- Assign a program
- Assign one or more restrictions
createUser
: create users to my organization/application
Argument | Required | Type | Description |
name | True | String | User's name |
email | True | String | User's email |
phone | False | String | User's phone |
password | False | String | Set up a user's password |
program | False | String | Include the database ID of the Program. If this parameter is not sent, the program can be later assgined by using the updateUserProgram mutation |
restrictions | False | String | Restriction Base-64 ID. If this parameter is not sent, restrictions can be later assigned by using the profileRestrictionsUpdate mutation |
emailPasswordNotification | False | Boolean | Notification sent via email to set up a user's password |
subscription | False | ID | Base-64 subscription ID which will be assigned to the created user. |
The following fields will be displayed in the response:
Field | Type | Description |
success | string | True if the user has been created successfully. Otherwise, False |
message | string | Description of the result |
user | A structured version of user information. It contains id and databaseId fields |
post
https://api.suggestic.com
/users
/users
The following examples create a user by using different program languages:
The following example will create a user and the information retrieved will be included later in the headers for an API Authentication token:
Mutation
Response
mutation {
createUser(
name: "Ernesto"
email: "[email protected]"
) {
success
message
user {
id
databaseId
}
}
}
{
"data": {
"createUser": {
"success": true,
"message": "User created",
"user": {
"id": "VXNlcjpWWE5sY2pvMk16QXlORE5oTWkxaVl6Rm1MVFEzWkdNdFlqbGtOaTAyTldOak1qa3lOMkZrWW1NPQ==",
"databaseId": "630243a2-bc1f-47dc-b9d6-65cc2927adbc"
}
}
}
}
Include the
databaseId
information along with the token id in the HTTP HEADERS within the GraphQL playground:
curl -X POST "https://api.suggestic.com/users" \
-H "Authorization: Token {partner-token}" \
-d '[email protected]' \
-d 'name=Pedro'
import requests
user = {
"name": "Pedro",
"email": "[email protected]"
}
response = requests.post(
"https://api.suggestic.com/users",
headers={"Authorization": "Token {partner-token}"},
data=user
)
print(response.json())
<?php
$token = 'TOKEN';
$query = <<<'GQL'
mutation createUser($name: String!, $email: String!) {
createUser(name: $name, email: $email) {
success
message
user {
id
}
}
}
GQL;
$variables = array(
'name' => 'Ernesto',
'email' => '[email protected]'
);
$json = json_encode(['query' => $query, 'variables' => $variables]);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://production.suggestic.com/graphql',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => array(
'Authorization: Token ' . $token,
'Content-Type: application/json',
) ,
));
$response = curl_exec($curl);
$result = curl_close($curl);
echo $result;
The following example creates a user and sets up the password without sending an email notification.
Request
Response
mutation {
createUser(
name: "userCTest"
email: "[email protected]"
password: "F7YTu_ER#$"
program: "01bbd541-939b-4b85-8d90-48ff0b02d0ee"
restrictions: [
"UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1",
"UmVzdHJpY3Rpb246ODU1ZjkzZjYtODQzOC00MTIzLTk3YzktM2U2YzU2MzllZjli"
]
) {
success
message
user {
id
databaseId
profileId
}
}
}
{
"data": {
"createUser": {
"success": true,
"message": "User created",
"user": {
"id": "VXNlcjpWWE5sY2pvNE5USmhNV1ZpTWkwek1EWm1MVFJsWlRFdE9HVmlaUzB4WlROa016WTNNV014TXpFPQ==",
"databaseId": "852a1eb2-306f-4ee1-8ebe-1e3d3671c131",
"profileId": "97e4dd59-46bc-4f50-89b4-cdacbf57f515"
}
}
}
}
The following example creates a user and sends a password notification to the user's email to set up a password.
Mutation
Response
mutation {
createUser(
name: "Liliana"
email: "[email protected]" emailPasswordNotification: true
) {
success
message
user {
id
databaseId
}
}
}
{
"data": {
"createUser": {
"success": true,
"message": "User created",
"user": {
"id": "VXNlcjpWWE5sY2pwa05EYzFaR0ZpT0MwMFpESXpMVFJqTkRndFlXTTBNUzFsWkRJM1lqTXpZekZtWlRVPQ==",
"databaseId": "d475dab8-4d23-4c48-ac41-ed27b33c1fe5"
}
}
}
}
The following notification will arrive in the user's email:

Click on this link to set up the password, users are redirected to the following page where a new password must be introduced:

Request
Response
mutation {
createUser(
name: "userCTest"
email: "[email protected]"
program: "01bbd541-939b-4b85-8d90-48ff0b02d0ee"
subscription: "NjI2NzEwNDEtOTI5Yi00MzJlLWJhN2ItMDNjZjFmZWYzZGQ0"
) {
success
message
user {
id
databaseId
profileId
}
}
}
{
"data": {
"createUser": {
"success": true,
"message": "User created",
"user": {
"id": "VXNlcjpWWE5sY2pvNE5USmhNV1ZpTWkwek1EWm1MVFJsWlRFdE9HVmlaUzB4WlROa016WTNNV014TXpFPQ==",
"databaseId": "852a1eb2-306f-4ee1-8ebe-1e3d3671c131",
"profileId": "97e4dd59-46bc-4f50-89b4-cdacbf57f515"
}
}
}
}
The following message is displayed in case the subscription does not exist:
Response
{
"data": {
"createUser": {
"success": false,
"message": "Subscription doesn't exist",
"user": null
}
}
}
Last modified 5mo ago