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

NameDescription
integration_idUsed by resellers to identify users in their own CRM systems
companyPrimarily used by resellers to identify company names
integrationUsed by resellers to identify the customers integration type
defaultsenderDefault sender value on the receiving device
balance???
use_currency???
max_forbrugMaximum number of messages a user can send
forbrugAmount of messages a user has sent
deactivatedIf the user is disabled, then this indicates when the user was closed
createdIndicates the date the user was created
parentID of the parent user
apikeyThe users apikey
materialized_pathUsed to identify where the user is in the hierarchy related to it's parents
prefixesA list of prefixes the user is allowed to send to
iprangeA list of IPs the user is allowed to use the api from
aclBillingAllows the user to send premium messages
aclBillingHighAllows the user to send premium messages at higher values than DKK 12
aclCharityAllows the user to send premium messages for charity
aclIncomingAllows the user to receive messages
aclSmsinboxAllows the user to user smsinbox.dk
aclHlrAllows the user to make HLR lookups
aclAdminAllows the user to create/edit/delete users
enabledIndicates 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

NameDescriptionRequired
usernameDetermines which username the new user will haveyes
passwordDetermines 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
Multiple IPs: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4
Single IP range: 192.168.0.1-192.168.0.15
Multiple IP ranges: 192.168.0.1-192.168.0.15, 192.168.0.30-192.168.0.45
Entire IP subnet + single IP: 192.168.0.*, 192.168.10.15

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.

NameDescription
usernameUpdates the username
passwordUpdates the password. Must be sent in clear text
creditsIndication 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
Multiple IPs: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4
Single IP range: 192.168.0.1-192.168.0.15
Multiple IP ranges: 192.168.0.1-192.168.0.15, 192.168.0.30-192.168.0.45
Entire IP subnet + single IP: 192.168.0.*, 192.168.10.15

newapikeyIf set to 1, then the user will get a new apikey. Only use this, if you are sure you know what you are doing.
enabledSet 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