REST API MGID for Advertising Agencies

* Please note that all API requests must be performed via HTTPS.

Table of contents


  1. Getting advertising agency clients list with financial stats
  2. Getting one client financial stats
  3. Getting financial stats of advertising agency
  4. Getting data of advertising agency clients expences for a period
  5. Clients balance replenishments from advertising agency wallet

 

Getting advertising agency clients list  with financial stats

Method GET
URL api.mgid.com/v1/agencies/{accountId}/clients
Headers

Accept: application/json

Authorization: Bearer {token}

Transfered parameters:

Parameter Value
accountId Identifier of user (advertising agency) account

Returned answer:

{
clients:{
 "id":_identifier_of_client's_account_,
   "email":_client's_email_,
"wallet":{
"balance":_state_of_MG_wallet_,
"credit":_overdraft_amount_,
"income":_total_replenish_sum_
}
}
}

All sums tranfered in advertising agency currency.

Possible errors:

If transferred current token is invalid, returned error is "invalid token".

 

Getting one client financial stats

Method GET
URL api.mgid.com/v1/agencies/{accountId}/clients/{client_id}
Headers

Accept: application/json

Authorization: Bearer {token}

Transfered parameters:

Parameter Value
accountId Identifier of user (advertising agency) account
client_id Advertising agency client id

Returned answer:

{
 "id":_identifier_of_client's_account_,
"wallet":{
"balance":_state_of_MG_wallet_,
"credit":_overdraft_amount_,
"income":_total_replenish_sum_
}
}

All sums tranfered in advertising agency currency

Possible errors:

If transferred current token is invalid, returned error is "invalid token";

If client id is incorrect returned answer is "Invalid client id".

 

Getting financial stats of advertising agency

Method GET
URL api.mgid.com/v1/agencies/{accountId}
Headers

Accept: application/json

Authorization: Bearer {token}

Transfered parameters:

Parameter Value
accountId Identifier of user (advertising agency) account

Returned answer:

{
 "id":_identifier_of_user(advertising_agency)_account_,
"balance":{
"personal_account":_balance_on_main_wallet_,
"bonus_account":_balance_on_bonus_wallet_,
"clients_balance":_sum_of_cuurent_clients_balances_
}
}

All sums tranfered in advertising agency currency.

Possible errors:

If transferred current token is invalid, returned error is "invalid token".

 

Getting data of advertising agency clients expences for a period

Method GET
URL api.mgid.com/v1/agencies/{accountId}/clients-spent-reports
Headers

Accept: application/json

Authorization: Bearer {token}

Transfered parameters:

Parameter Value
accountId Identifier of user (advertising agency) account
dateStart Period start date in format  YYYY-MM-DD
dateEnd Period end date in format YYYY-MM-DD
clientsIds Clients ids separated by commas, not nesessary parameter

Returned answer:

{
dateStart:Period start date in format YYYY-MM-DD,
dateEnd:Period end date in format  YYYY-MM-DD,
clients-spent-reports:[
{
"id":_identifier_of_client's_account_,
"spent":_sum_of_expences_by_directions_(goodhits +news + banners)
},

]
}

All sums transfered in advertising agency currency.

If parameter clientsIds is empty, return expenses for all advertising agency clients.

Possible errors:

If the transferred current token is invalid, returned error is "invalid token";

If client id is incorrect returned answer is "Invalid client id";

Possible format errors of parameters: dates should be in the format of YYYY-MM-DD, clientsIds should be separated by commas.

 

Clients balance replenishments from advertising agency wallet

Method POST
URL api.mgid.com/v1/agencies/{accountId}/clients/{client_id}/money-transfers?account_type={account_type}&transfer_amount={transfer_amount}
Headers

Accept: application/json

Authorization: Bearer {token}

Transfered parameters:

Parameter Value
accountId Identifier of user (advertising agency) account
client_id Advertising agency client id
account_type Account used for filling up should be one of values: personal or bonus
transfer_amount Amount in advertising agency currency should be numeric

Returned answer:

{
 "idAuth":"_identifier_of_user's_account__",
    "clientId":"_client_id_",
   "status":"success",
  "bonus\personal_account":"_accout_balance_",
bonus or personal based on incoming parameters,
   "wallet":{
 "balance":"_client's_account_balance_",

}
}

All sums transfered in advertising agency currency.

Possible errors:

1) If money on the specified account is not enough, the amount entered in the transferred data is larger than the specified purse, return the error "The amount of money in the account is less than what you are trying to transfer."

2) If the transferred current token is invalid, returned error is "invalid token"

3) If the client id is not in the system or curator is not this advertising agency, return error "Invalid client id"

4) If the account, client, and the amount of remittances are empty, return the error "Account (client, amount) is not specified "