Create User

Creating a user

Use the createUser mutation to create a new account for an end-user on your organization's account.

Anonymization: Kindly be aware that the essential fields for creating a user profile include the name and email. If you prefer a completely anonymous format, you are welcome to provide a generic user name, like "<ORGANIZATION_NAME> User," and a distinct email address, such as "<USER_ID>@<ORGANIZATION_DOMAIN>".

Arguments

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.

Available Fields

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

Examples

GraphQL

mutation {
  createUser(
    name: "Ernesto"
    email: "ernesto@suggestic.com"
  ) {
    success
    message
    user {
      id
      databaseId
    }
  }
}

Include the databaseId information along with the token id in the HTTP HEADERS within the GraphQL playground:

Note: Use the databaseIdin the sg-userheader to start using mutations and queries

cURL Example

curl -X POST "https://api.suggestic.com/users" \
    -H "Authorization: Token {partner-token}" \
    -d 'email=pedro@corp.com' \
    -d 'name=Pedro'

Python Example

import requests

user = {
  "name": "Pedro",
  "email": "pedro@corp.com"
}
response = requests.post(
    "https://api.suggestic.com/users",
    headers={"Authorization": "Token {partner-token}"},
    data=user
)
print(response.json())

PHP Example

<?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' => 'ernesto+00012@suggestic.com'
);

$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;

Setup a user's password

The following example creates a user and sets up the password without sending an email notification.

mutation {
  createUser(
    name: "userCTest"
    email: "userCTest@gmail.com"
    password: "F7YTu_ER#$" 
    program: "01bbd541-939b-4b85-8d90-48ff0b02d0ee"
    restrictions: [
      "UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1",
      "UmVzdHJpY3Rpb246ODU1ZjkzZjYtODQzOC00MTIzLTk3YzktM2U2YzU2MzllZjli"
    ] 
  ) {
    success
    message
    user {
      id
      databaseId
      profileId
    }
  }
}

Send an email to set up a password

The following example creates a user and sends a password notification to the user's email to set up a password.

mutation {
   createUser(
    name: "Liliana"
    email: "liliana@suggestic.com" emailPasswordNotification: true
  ) {
    success
    message
    user {
      id
      databaseId
    }
  }
}

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:

Assign a subscription to the user

mutation {
  createUser(
    name: "userCTest"
    email: "userCTest@gmail.com"
    program: "01bbd541-939b-4b85-8d90-48ff0b02d0ee"
    subscription: "NjI2NzEwNDEtOTI5Yi00MzJlLWJhN2ItMDNjZjFmZWYzZGQ0"
  ) {
    success
    message
    user {
      id
      databaseId
      profileId
    }
  }
}

The following message is displayed in case the subscription does not exist:

{
  "data": {
    "createUser": {
      "success": false,
      "message": "Subscription doesn't exist",
      "user": null
    }
  }
}

Last updated