Listing/adding/editing users - /users API

https://api.digitalmbridge.com/v2/users/ API responds to the following request methods:

API endpoint HTTP Method API description
/users/ GET show all users
/users/ POST create a new user
/users/ PUT edit an existing user
/users/id/<user_id> GET show user matching path variable <user_id>
/users/username/<username> GET show user matching path variable <username>


Every unsuccessful request made to /users API will return a HTTP status 400 and a json response as follows:

{
  "status": "error",
  "message": "<error-message>"
}


GET
 request to https://api.digitalmbridge.com/v2/users/ will return all users created by authenticated user (and the user itself).

In the event of a successful request, Digital Media Bridge will return a json response as follows:

{
  "status": "success",
  "users": [
    <user_1>,
    <user_2>,
    ...
  ]
}


GET request to https://api.digitalmbridge.com/v2/users/id/<user_id> will return the user matching <user_id> path variable.

GET request to https://api.digitalmbridge.com/v2/users/username/<username> will return the user matching <username> path variable.
In the event of a successful request, Digital Media Bridge will return a json response as follows:

{
  "status": "success",
  "user": <user>
}


POST
request to https://api.digitalmbridge.com/v2/users/ will create a new user on Digital Media Bridge platform, according to the json body present in the request,
containing the following elements:

Name Type Format Required Default value if omitted
username text string YES  
password text string YES  
sender text string NO 'SMS'
can_send boolean boolean NO false
rate number int unsigned NO 10
rate_duration number int unsigned NO 1
max_children number int unsigned NO 10
can_manage_users boolean boolean NO false
delivery_report_url text string NO  
mo_url text string NO  
countries array number YES  


username length between 3 and 100 characters, must match \w regexp.
password length between 8 and 40 character.
sender specifies the default alias used for all high quality sms sent by this user account; max length is 11 characters for alphanumeric aliases, 16 characters for numeric aliases.
can_send specifies if this user account will be able to send sms using mediariver platform (true/false).

rate and rate_duration together specifies the rate (num of messages / timeframe)  at which this user account can send sms.
can_manage_users specifies if this user account will be able to create and manage other users 
(true/false).
max_children specifies the maximum number of children users (subaccounts) that user account can create. Maximum allowed value is 50.
delivery_report_url and mo_url if specified will be used by mediariver respectively to send sms delivery statuses and sms-mo.
countries specifies the countries in which this user account will be allowed to send messages.

Request example:

{
"user": {
"username": "user-test",
"password": "supersecret",
"sender": "def alias",
"can_send": true,
"default_gateway": 6,
"rate": 100,
"rate_duration": 1,
"delivery_report_url": "https://customer-site.com/dlr/api",
"can_manage_users": false,
"countries": [
10,
11
]
}
}


In the event of a successful request, Digital Media Bridge will return a json response as follows:

{
  "status": "success",
  "user_id": <user_id>
}

 

PUT request to https://api.digitalmbridge.com/v2/users/ will edit an existing user properties on Digital Media Bridge platform, according to the json body present in the request, containing the following elements:

Name Type Format Required
username text string YES
password text string NO
sender text string NO
can_send boolean boolean NO
rate number int unsigned NO
rate_duration number int unsigned NO
max_children number int unsigned NO
can_manage_users boolean boolean NO
delivery_report_url text string NO
mo_url text string NO
countries array number NO


username must match an existing user present on Digital Media Bridge platform.
Any user's property that is not included in request will not be changed, and the user will mantain the previous property value present on Digital Media Bridge platform.
If countries element is present in request, Digital Media Bridge will discard any previous country associated to the user account, and update them accordingly to the countries array present in request. For example:
user's countries before update: [10,11]
request is submitted with countries [13], user's countries after update will be: [13] (countries 10 and 11 will be removed).

In the event of a successful request, Digital Media Bridge will return a json response as follows:

{
  "status": "success",
  "user_id": <user_id>
}