Particeep

documentation.user_create.title

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.

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.

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 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.