11. Users
GET /users.{format}
Get all users associated with the user making the request. The request return both active and inactive users.
curl 'http://api.linkmobility.dk/v2/users.{format}?apikey=[apikey]' -X GET
Response
On success the request returns all the users associated with the requesting user
{ "users": [ { "integration_id": null, "company": null, "integration": null, "defaultsender": null, "balance": "1.2400000", "use_currency": 0, "max_forbrug": "999999", "forbrug": "131", "deactivated": null, "created": "07-12-2015 08:23:57", "parent": 0, "id": 10281, "username": "here_be_username", "apikey": "---", "materialized_path": "7xl", "prefixes": "", "iprange": "", "aclBilling": true, "aclBillingHigh": true, "aclCharity": true, "aclIncoming": true, "aclSmsinbox": true, "aclHlr": true, "aclAdmin": true, "enabled": true, "credits": 999868 } ], "status": 200 }
On failure the request will return a status 400 or 401 (depending on the error), with a message explaining the problem:
{ "status": 401, "message": "Access denied [abcd] authentication failed" }
Fields returned by a successfull request
Name | Description |
---|---|
integration_id | Used by resellers to identify users in their own CRM systems |
company | Primarily used by resellers to identify company names |
integration | Used by resellers to identify the customers integration type |
defaultsender | Default sender value on the receiving device |
balance | ??? |
use_currency | ??? |
max_forbrug | Maximum number of messages a user can send |
forbrug | Amount of messages a user has sent |
deactivated | If the user is disabled, then this indicates when the user was closed |
created | Indicates the date the user was created |
parent | ID of the parent user |
apikey | The users apikey |
materialized_path | Used to identify where the user is in the hierarchy related to it's parents |
prefixes | A list of prefixes the user is allowed to send to |
iprange | A list of IPs the user is allowed to use the api from |
aclBilling | Allows the user to send premium messages |
aclBillingHigh | Allows the user to send premium messages at higher values than DKK 12 |
aclCharity | Allows the user to send premium messages for charity |
aclIncoming | Allows the user to receive messages |
aclSmsinbox | Allows the user to user smsinbox.dk |
aclHlr | Allows the user to make HLR lookups |
aclAdmin | Allows the user to create/edit/delete users |
enabled | Indicates wether the user is enabled or disabled |
GET /user/{id}.{format}
Get a specific user, identified by id
curl 'http://api.linkmobility.dk/v2/user/{id}.json?apikey=[apikey]' -X GET
Response
On success the request will return the requested user
{ "user": { "integration_id": null, "company": null, "integration": "EC", "defaultsender": null, "balance": "1.2400000", "use_currency": 0, "max_forbrug": "999999", "forbrug": "131", "deactivated": null, "created": "07-12-2015 08:23:57", "parent": 0, "id": 10281, "username": "here_be_username", "apikey": "---", "materialized_path": "7xl", "prefixes": "", "iprange": "", "aclBilling": true, "aclBillingHigh": true, "aclCharity": true, "aclIncoming": true, "aclSmsinbox": true, "aclHlr": true, "aclAdmin": true, "enabled": true, "credits": 999868 }, "status": 200 }
On failure the request will return an error and a message describing what went wrong:
{ "status": 404, "message": "User id [9999999] not found" }
POST /user.{format}
Creates a new user
curl 'http://api.linkmobility.dk/v2/user.json?apikey=[apikey]' -H "Content-Type: application/json" -X POST -d @file.json
Payload file.json
{ "user": { "username": "test", "password": "test", "credits":0 } }
Fields
Name | Description | Required |
---|---|---|
username | Determines which username the new user will have | yes |
password | Determines the new users password. Must be sent in plain text. | yes |
credits | Determines how many credits the will be able to send. 1 credit = 1 message. If set to 0 (zero), the user will have infinite messages. | yes |
iprange | Used if the user should only be allowed to send from certain IPs. Must be formatted as follows: Single IP: 192.168.0.1 If not specified, it will be possible to send from any IP. | no |
Response
On success, the request will return a status 201 with the new user object
{ "user": { "integration_id": null, "company": null, "integration": "", "defaultsender": null, "balance": null, "use_currency": 0, "max_forbrug": "0", "forbrug": "0", "deactivated": null, "created": "27-05-2016 10:08:06", "parent": 10281, "id": 12273, "username": "api-example-test", "apikey": "here_be_apikey", "materialized_path": "7xl/9gx", "prefixes": "", "iprange": null, "aclBilling": true, "aclBillingHigh": true, "aclCharity": true, "aclIncoming": true, "aclSmsinbox": true, "aclHlr": true, "aclAdmin": false, "enabled": true, "credits": 0 }, "status": 201 }
If the status is anything but 201, then something has failed and a message describing the problem will be present
E.g. If the username is empty:
{ "message": "User not created, [username] empty", "status": 400 }
If the user is trying to create a user, but does not have persmission to do so:
{ "message": "User not created, [acl] access is denied for user", "status": 403 }
PUT /user/{id}.{format}
Updates a given user by id. When updating a user, a field will only be updated if it is set. If you leave out e.g. "IP range", then the IP range will not be updated.
curl PUT -d "http://api.linkmobility.dk/v2/user/{id}.json?apikey=[apikey]" -H "Content-Type: application/json" -X PUT -f @file.json
Payload file.json
{ "user": { "username":"new_username", "password":"new_password", "credits":100, "iprange":"", "newapikey":true, "enabled":1 } }
Fields
No fields are required and a field will only be updated if set.
Name | Description |
---|---|
username | Updates the username |
password | Updates the password. Must be sent in clear text |
credits | Indication how many credits should be added to the users balance |
iprange | If set, then the user will only be able to use the api from a specific set of IPs. Must be formatted as follows: Single IP: 192.168.0.1 |
newapikey | If set to 1, then the user will get a new apikey. Only use this, if you are sure you know what you are doing. |
enabled | Set to 1 to enable the user and set to 0 to disable the user. |
Response
On success a status 200 and the user object will be returned.
{ "user": { "integration_id": "101", "company": null, "integration": "", "defaultsender": null, "balance": null, "use_currency": 0, "max_forbrug": 100, "forbrug": "0", "deactivated": null, "created": "27-05-2016 09:25:26", "parent": 10281, "id": 12273, "username": "new_username", "apikey": "here_be_apikey", "materialized_path": "7xl/9gx", "prefixes": "", "iprange": "", "aclBilling": true, "aclBillingHigh": true, "aclCharity": true, "aclIncoming": true, "aclSmsinbox": true, "aclHlr": true, "aclAdmin": false, "enabled": true, "credits": 100 }, "status": 200 }
DEL /user/{id}.{format}
Used to delete a user
curl 'http://api.linkmobility.dk/v2/user/{id}.json?apikey=[apikey]' -X DELETE
Feeling lost? Click on this link! Portal page