Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This document outlines the process for creating a user in the OZmap API. Follow the steps below to successfully create a user with the appropriate access and role.

Here are the steps to create an user:

  1. Identify the Projectsprojects: Determine which projects the user will have access to.

  2. Identify the Rolerole: Determine the role that the user will be assigned.

  3. Create the Useruser: Create the user with access to the specified projects and assigned role.

...

In this response, you can see the ID and name of each role available in OZmap. For this example, we will assign the user the "Manager" role, which has the ID 5accf8f60ff2c819a4ffd38f.

Creating the

...

user:

With the project ID and role ID determined, you can now create the user. In this example the user will have access to all resources, which include OZmap, OZmob, Loki, and API. Here is the request to create the user:

Code Block
languagejs
curl --location 'https://sandbox.ozmap.com.br:9994/api/v2/users' \
--header 'Content-Type: application/json' \
--header 'authorization: AUTHORIZATION_TOKEN'
--data-raw '{
    "resources": [
        "OZmap",
        "OZmob",
        "Loki",
        "API"
    ],
    "username": "example",
    "password": "example123",
    "email": "example@email.com",
    "name": "Example",
    "phone": "19 914454-4444",
    "role": "5accf8f60ff2c819a4ffd38f",
    "observation": "testetest",
    "projects": [
        {
        "project": "5d9f3ff9200141000647f814",
        "role": "5accf8f60ff2c819a4ffd38f"
        }
    ],
    "projectGroups": [],
    "locale": "en_US"
}'

If the user is successfully created, the API will return a 201 Created status and the following response:

Code Block
languagejs
{
    "username": "example",
    "allProjects": false,
    "email": "example@email.com",
    "resources": [
        "OZmap",
        "OZmob",
        "Loki",
        "API"
    ],
    "name": "Example",
    "phone": "19 914454-4444",
    "observation": "testetest",
    "role": "5accf8f60ff2c819a4ffd38f",
    "projectGroups": [],
    "projects": [
        {
            "role": "5accf8f60ff2c819a4ffd38f",
            "project": "5d9f3ff9200141000647f814",
            "fromGroup": false
        }
    ],
    "email_confirmed": false,
    "creatorData": {
        "id": "63456ff9443ee40013100ed2",
        "name": "example_user",
        "username": "example_user"
    },
    "_id": "67880ddd933efcf4ecc905a9",
    "createdAt": "2025-01-15T19:34:53.754Z",
    "updatedAt": "2025-01-15T19:34:53.754Z",
    "__v": 0,
    "id": "67880ddd933efcf4ecc905a9"
}