api.mailbox.org : Examples

auth

Request
{
  "jsonrpc":"2.0",
  "method":"auth",
  "params":{
    "user":"test_account",
    "pass":"123456"
  },
  "id":"1"
}
Response after success
{
  "jsonrpc":"2.0",
  "result":{
    "session":"LV;N%5TD7)64y&JOpK956fbe591dd89b8.38138624",
    "level":"account"
  },
  "id":"1"
}
Response to a request containing invalid access credentials
{
  "jsonrpc":"2.0",
  "error":{
    "code":2,
    "message":"Access denied"
  },
  "id":"1"
}

PHP API client:

<?php
require_once './api.mailbox.org.client.php';
$api = new api_mailbox_org_client();
$params = array('user' => 'test_account', 'pass' => '123456');
$r = $api->call('auth', $params);
if ($r === FALSE) {
    echo $api->error_code().': '.$api->error_message();
} else {
	echo $r['session'];
}

 

deauth

Request with valid Auth-ID
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"deauth",
  "params":""
}
Response
{
  "jsonrpc":"2.0",
  "result":true,
  "id":"1"
}

PHP API client:

<?php
require_once './api.mailbox.org.client.php';
 
// assuming Auth-ID in some $_SESSION variable
$session = $_SESSION['api_auth_id'];
 
$api = new api_mailbox_org_client($session);
$r = $api->call('deauth');
if ($r === FALSE) {
    echo $api->error_code().': '.$api->error_message();
} else {
	echo 'success';
}

hello.world

Request
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"hello.world",
  "params":""
}
Response
{
  "jsonrpc":"2.0",
  "result":"Hello World!",
  "id":"1"
}

hello.innerworld

Request with valid Auth-ID
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"hello.innerworld",
  "params":""
}
Response
{
  "jsonrpc":"2.0",
  "result":"Hello Inner-World!",
  "id":"1"
}

 

domain.list

Request with valid Auth-ID
{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"domain.list",
  "params":{
      "account":"test_account"
  }
}
Response
{
  "jsonrpc":"2.0",
  "result":[
    {
      "domain":"domain1.test",
      "count_mails":2
    },
    {
      "domain":"domain2.test",
      "count_mails":0
    },
    {
      "domain":"domain3.test",
      "count_mails":33
    },
    {
      "domain":"domain4.test",
      "count_mails":0
    }
  ],
  "id":"1"
}