How to create a user with Particeep API
For all platform types, you will need to create users to represent your customer and partner accounts.
In this tutorial, we will create users programmatically by sending their information to the corresponding API endpoint directly.
- Our object model provides 20 elementary fields of information related to the user.
- Additionnaly, we allow 2 free fields for any tags and free json information you may want to add.
- In our back-end, the creation will add the user in the DB tables and link it to your platform.
- The creation will also be recorded as an event in your platform history.
You can also create users visually via the web interface in the admin platform.
1 - Basic information
To create a user, we send its information as a json payload.
Minimal json payload example
There's 2 mandatory fields: the email
and the password
All the other fields are optional and will allow you to manage various user types in your company's use cases.
{
"email": "jp.test@domain.com",
"password": "12345678-Abcd#"
}
Let's send it
We send the information as a PUT
HTTP request with the addition of this simple json payload.
The request will also need correct credentials built from your API key, API secret and the current timestamp (see Getting started page, under the section authorization headers).
To send the PUT request, you can use the following example snippets from your favourite language:
String userCrudUrl = "https://test-api.particeep.com/user";
String email = "jp.test@domain.com";
String password = "12345678-Abcd#";
JsonNode user = Json.newObject()@
.put("email", "string")
.put("password", "string");
// see the "getting started" example to fill the headers
// Map<String, String> yourHeaders = new HashMap(...)
HttpResponse result = WS.url(url).headers(yourHeaders).put(user);
String result = result.getString();
System.out.println(result);
var request = require("request");
var userCrudUrl = "https://test-api.particeep.com/user";
// see the "getting started" example to fill the headers
// var yourHeaders = {...};
request.put({
url: userCrudUrl,
body: {"email": "jp.test@domain.com", "password": "12345678-Abcd#"},
headers: yourHeaders,
json: true
}, function(error, response, body){
console.log(body);
});
#! /usr/bin/env python3
import requests
user_crud_url = "https://test-api.particeep.com/user"
# see the "getting started" example to fill the headers
# your_headers = {...}
resp = requests.put(
url,
json = {"email": "jp.test@domain.com", "password": "12345678-Abcd#"},
headers = your_headers
)
$ch = curl_init();
$data_json = json_encode(array('email'=>'jp.test@domain.com','password'=>'12345678-Abcd#'));
$user_crud_url = 'https://test-api.particeep.com/user';
// see the "getting started" example to fill the headers
// $your_headers = [...];
curl_setopt($ch, CURLOPT_URL, $user_crud_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $your_headers);
$server_output = curl_exec($ch);
curl_close($ch);
echo $server_output;
NB: The created user is automatically associated with your platform because of the API key that was used.
The password is encrypted by the SSL layer because the url we send to is HTTPS.
HTTP Response, mail notification and user ID
If your request was correct, the user will receive a notification email with a link to validate the account and you will receive the following response:
{
"id": "5faabb1b-329d-419b-aa6f-7bb46c99e029",
"created_at": "2018-01-01T12:00:00Z",
"email": "jp.test@domain.com",
"has_been_claimed": false,
"address": {}
}
The first line is the UUID of the user in DB, created_at
records the timestamp of your action, and has_been_claimed
is a boolean indicating whether the user validated her/his new account.
2 - Extension possibilities
Let's try a more complete user.
- Our object model provides 20 elementary fields of information related to the user.
-
The mandatory credentials from step 1:
email and password -
Civil status information
first_name, last_name, birthday, birth_place, gender, nationality -
Address information
number, street, zip, city, region, country -
Links to a profile picture link and social media accounts
avatar_url, linkedin_url, viadeo_url -
Additional information for the user.
phone, bio, sector
-
The mandatory credentials from step 1:
-
Additionally, we allow 2 free fields for any tags and custom json information you or your developper team may want to add.
- tags
- custom
Full user json payload example
{
"email": "jp.test@domain.com",
"first_name": "Jean-Pierre",
"last_name": "Test",
"gender": "MAN",
"nationality": "France",
"birthday": "1980-01-01T12:00:00Z",
"birth_place": "Paris",
"avatar_url": "http://blog.particeep.com/wp-content/uploads/2017/04/Particeep-digital-tour-teap.png",
"phone": "+33612345678",
"bio": "Here is a free text field.",
"sector": "Fintech",
"linkedin_url": "https://www.linkedin.com/company/particeep/",
"viadeo_url": "http://fr.viadeo.com/fr/company/particeep",
"address": {
"number": "100",
"street": "rue Petit",
"zip": "75019",
"city": "Paris",
"country": "France",
"region": "Île-de-France"
},
"tag": "your;tags;here",
"custom": {
"your_custom_json": "here"
}
}
The code to send this information is exactly the same as the previous minimal example.
And like before, the API replies with a brand new UUID for the new user.
3 - Other related endpoints
Most of the other endpoints provided by the API can interconnect with the user endpoint.
- The user account is a starting point that can be connected to:
- A user's investment wallet and transaction stats
- User group membership (for restricted club deals, partners...)
- User roles (admin, manager, partner, customer)
- Customer risk profiles via our KYC solutions
The standard way to connect another entity (like wallet, transaction, etc) to a user is by their target_id
field, or owner_id
field.
Finally, any user creation also triggers a recorded event (with the name: user_created
). These events can be searched or connected to any actions in a third-party API via the webhook endpoint.