User Creation
Quick guide on how to create a user and everything it entails
Steps
- Create a Group β sets the organization or company (this will contain users, assets and vehicles info)
- Create a User β assigns the user to the group and generates login credentials.
- Enable Application Access β grants the user access to the Pegasus web application.
1. Create a Group
curl -X POST https://api.pegasusgateway.com/groups \
-H "Content-Type: application/json" \
-H "Authenticate: VALID_AUTH_TOKEN" \
-d '{
"address_1": "123 Something",
"city": "Merida",
"company_name": "COMPANY NAME OR NAME OF INSURED",
"contact_email": "[email protected]",
"contact_name": "COMPANY NAME OR NAME OF INSURED",
"country": "Mexico",
"logo": null,
"name": "COMPANY NAME OR NAME OF INSURED"
}'{
"id": 3705,
"name": "COMPANY NAME OR NAME OF INSURED",
"company_name": "COMPANY NAME OR NAME OF INSURED",
"contact_name": "COMPANY NAME OR NAME OF INSURED",
"contact_email": "[email protected]",
"address_1": "123 Something",
"address_2": null,
"city": "Merida",
"country": "Mexico",
"logo": false,
"users": [],
"vehicles": [],
"assets": [],
"__created": 1772685361.558171,
"__updated": 1772685361.558171,
"__version": "7.99.0-dev53"
}Take note of the id from the response. This is the Group ID and it is required when assigning users to the group in the next request.
2. Create a User
Creates a platform user account and assigns the user to the group created above.
You may either:
- Send the user a login email
- Provide a custom password (as shown below)
curl -X POST https://api.pegasusgateway.com/users \
-H "Content-Type: application/json" \
-H "Authenticate: VALID_AUTH_TOKEN" \
-d '{
"access": "basic",
"app_url": "https://pegasus-site.yourdomain.com/v2/#!",
"email": "[email protected]",
"send_email": false,
"username": "[email protected]",
"password": "SecretPass1!",
"first_name": "CONTACT NAME OR FIRST NAME",
"last_name": "LAST NAME",
"groups": [
3705
],
"id": null,
"id_user": "new",
"is_active": true,
"is_staff": false,
"is_superuser": false,
"logo_url": "https://i.imgur.com/qtqojDT.png",
"phone": null,
"prefs": {
"coords": "WGS84",
"date_format": "YYYY-MM-DD",
"distance": "km",
"distanceunits": "km",
"fuelunits": "liter",
"hour_format": 12,
"language": "es",
"system_notifications": {},
"temperature": "C",
"volume": "liter"
},
"roles": [],
"scopes": {"assets":"r","vehicles":"w","geofences":"w","vehicles:device":"r"}
}'{
"id": 5288,
"username": "[email protected]",
"email": "[email protected]",
"first_name": "COMPANY NAME OR FIRST NAME",
"last_name": "LAST NAME",
"groups": [3705],
"is_active": true,
"is_staff": false,
"is_superuser": false,
"phone": null,
"roles": [],
"prefs": {
"coords": "WGS84",
"date_format": "YYYY-MM-DD",
"distance": "km",
"distanceunits": "km",
"fuelunits": "liter",
"hour_format": 12,
"language": "es",
"system_notifications": {},
"temperature": "C",
"volume": "liter"
},
"scopes": {
"...": "..."
},
"date_joined": 1772685578,
"last_login": 1772685578,
"__created": 1772685578.546495,
"__updated": 1772685578.579646,
"__version": "7.99.0-dev53"
}Don't forget to assign the group ID under the groups array. Also refer to scopes for a list of available scopes.
3. Enable Application Access
curl -X PUT "https://api.pegasusgateway.com/apps/pegasus2.0?user=5288" \
-H "Authenticate: VALID_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"staff": {
"apps": {
"tracking": true,
"alerts": true,
"reports": true,
"automation": true,
"applications": true,
"geofences": true,
"organization": true,
"trips": true,
"documentation": true
}
}
}'{
"id": 4891,
"app": "pegasus2.0",
"user": 5288,
"disabled": false,
"data": {},
"staff": {
"apps": {
"tracking": true,
"alerts": true,
"reports": true,
"automation": true,
"applications": true,
"geofences": true,
"organization": true,
"trips": true,
"documentation": true
}
}
}Be sure to specify the user ID created from step 2 on the URL Param in this request
Updated about 2 hours ago
