Description
This endpoint must be used for creating a new user
This endpoint must be consumed in POST request
Security
This endpoint is secured, you must send a Bearer Token, to be able to invoke the endpoint, for getting the token, you should first invoke the /oauth/token service of the security microservice, if you don't know what service is, please talk with your sysadmin for further information
Request
As part of the request headers, a Basic Auth must be sent:
This must be sended in the Http headers of the request, look at the next curl example for a better understanding
Copy codecurl --location 'host:port/zynchro.api.system-config/v1/users' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ••••••' \ --data-raw '{ "header": { "transactionId": "123455566677788" }, "data": { "user": { "id": 0, "name": "Test User", "email": "user@test.com", "password": "12345678", "telephone": "5544667799", "isControlTower": true }, "clientsProfile": [ { "clientId": 33, "profileId": 2 }, { "clientId": 38, "profileId": 1 } ] } }'
In java it would be something like this (depending on the dependency you use)
Copy codeOkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\r\n \"header\": {\r\n \"transactionId\": \"123455566677788\"\r\n },\r\n \"data\": {\r\n \"user\": {\r\n \"id\": 0,\r\n \"name\": \"Test user\",\r\n \"email\": \"user@test.com\",\r\n \"password\": \"12345678\",\r\n \"telephone\": \"5544667799\",\r\n \"isControlTower\": true\r\n }, \r\n \"clientsProfile\": [\r\n {\r\n \"clientId\": 33,\r\n \"profileId\": 2\r\n },\r\n {\r\n \"clientId\": 38,\r\n \"profileId\": 1\r\n }\r\n ]\r\n }\r\n}"); Request request = new Request.Builder() .url("host:port/zynchro.api.system-config/v1/users") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Authorization", "Bearer ••••••") .build(); Response response = client.newCall(request).execute();
Next are listed the params required in the request body
Field | SubField | Type | Description | IsRequired |
---|---|---|---|---|
header | object | Y | ||
transactionId | text | A custom value to identify the data related to the request in the response (you can see the transactionId in the response header). Example:
Note: This field is not related to the creation of a new campaign, must be used by the client app in order to identify the request/response (if that is useful), the same value can be sended in multiple request (it’s not validated that the same value was sended before) | N | |
Data | | Object | The specific body data related to the request | Y |
user | Object | The new user Look for the description of user Object below | Y | |
clientsProfile | Array | The list of profiles and clients that the user will have access to Look for the description of clientsProfile Object below | Y |
user object
Field | SubField | Type | Description | IsRequired |
---|---|---|---|---|
user | ||||
id | int | The identifier of the user (must be 0) | N | |
name | text | The name of the user | Y | |
email | text | The email of the user | Y | |
telephone | text | The telephone of the user | Y | |
lastLogin | text | The last login date of the user | Y | |
isControlTower | boolean | Indicates if the user has access to the control tower module | Y |
Field | SubField | Type | Description | IsRequired |
---|---|---|---|---|
clientsProfile | ||||
clientId | int | The client id to aplly | Y | |
profileId | text | The profile id to apply | Y |
Consuming Service
Example Request
Consuming service
(POST) URL:HOST:PORT/zynchro.api.system-config/v1/users?transaction_id=12233445666
Request Body (JSON RAW):
Copy code{ "header": { "transactionId": "123455566677788" }, "data": { "user": { "id": 0, "name": "Usuario prueba", "email": "user_test_3@test.com", "password": "12345678", "telephone": "5544667799", "isControlTower": true }, "clientsProfile": [ { "clientId": 33, "profileId": 2 }, { "clientId": 38, "profileId": 1 } ] } }
Response
Response 200 OK
If the params present in the request are valid, then you will receive a response 200 "ok" message code look at the next example:
Copy code{ "header": { "resultCode": "ok", "messageCode": "ok", "messageDescription": "request ok", "transactionId": "123455566677788" }, "data": { "success": true, "message": "", "user": { "id": 920, "name": "Usuario prueba", "email": "user_test_3@test.com", "telephone": "5544667799", "lastLogin": "", "isControlTower": false } } }
Description of the response data
Field | SubField | Type | Description |
---|---|---|---|
header | | Object | Specific data related to the response |
| resultCode | text | The result code of the response, can be: · error -> if errors were found · ok -> if NO errors were found |
| messageCode | text | The message code related to the result code of the response, can be: Example: |
| messageDescription | text | The description of the message code Example: · request ok · Please check your params fields |
| transactionId | text | The transactionId specified in the request, if no transactionId was sended in the request then the transacionId in the response will be null |
errors | | Array | This field is present if there are errors in the request |
| fieldName | text | The field with errors |
| fieldDesc | text | The description of the error |
Data | | Array | The specific response data related to the request |
success | boolean | Indicates if the request was successfully processed | |
message | text | When success equals to false this field is used to describe the "error" | |
user | Object | The user created (review below for futher info) |
user object
Field | SubField | Type | Description |
---|---|---|---|
user | |||
id | int | The identifier of the user | |
name | text | The name of the user | |
email | text | The email of the user | |
telephone | text | The telephone of the user | |
lastLogin | text | The last login date of the user | |
isControlTower | boolean | Indicates if the user has access to the control tower module |
Response 400
If there are errors with the request, then you will receive a 400 message response BAD_REQUEST with the errors field present, like the following example:
Copy code{ "header": { "resultCode": "error", "messageCode": "BAD_REQUEST", "messageDescription": "Please check your params fields", "transactionId": "123455566677788" }, "errors": [ { "fieldName": "name", "fieldDesc": "Field is required, and must be of type String " }, { "fieldName": "password", "fieldDesc": "Field is required, and must be of type String " }, { "fieldName": "telephone", "fieldDesc": "Field is required, and must be of type String " }, { "fieldName": "clientsProfile", "fieldDesc": "Field is required, and must be of type Array " }, { "fieldName": "email", "fieldDesc": "Field is required, and must be of type String " } ] }
Response 401
If you dont send any token, then you will receive a error message of "unauthorized", look at the next example:
Copy code{ "error": "unauthorized", "error_description": "Full authentication is required to access this resource" }
If you send a Token, but the Token you are sending is expired, then you will receive a response message with an "invalid_token" error, look at the next example:
Copy code{ "error": "invalid_token", "error_description": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDM2MTk5NzMsInVzZXJfbmFtZSI6ImFsZWphbmRyby56YW5hYnJpYUBkaWdpd29ya3MuY29tLm14IiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9TWVNURU1BRE1JTiJdLCJqdGkiOiJHTGtQb3hQbVRTZUs2RFhmc1NfNkUxRkMxZmsiLCJjbGllbnRfaWQiOiJ6eW5jaHJvIiwic2NvcGUiOlsicmVhZCIsIndyaXRlIl19.yAFbdU18wMtQXSGUY3_noQn4BQv0RqYjDbw0sr1x6Yk" }
This is the data retrieved when the 401 Unauthorized is retrieved:
Field | SubField | Type | Description |
---|---|---|---|
error | | text | The type of the error, can be:
|
error_description | text | The description of the error, for the "invalid_token", this field retrieves the bearer token you're sending |