* Please note that all API requests must be performed via HTTPS.
Table of contents
- Advertising agency client registration
- Getting token for advertising agency
- Getting advertising agency clients list with financial stats
- Getting one client financial stats
- Getting financial stats of advertising agency
- Getting data of advertising agency clients expences for a period
- Clients balance replenishments from advertising agency wallet
Advertising agency client registration
Method | POST |
URL | api.mgid.com/v1/clients/ |
Headers |
Accept: application/json Authorization: Bearer {token} |
Transfered parameters:
Parameter | Value |
email of new user | |
phone | new user's phone in international format +1(555)555-55-55 / +49(55)55-55-55. |
skype | new user's skype |
telegram | new user's telegram |
name | new user's name |
manager | Hash which indicates a curator to put in all directions to create a client |
Customer registration hash can be found in the advertising agency profile in the admin panel.
Returned answer:
{
"id":"_client_id_",
"email":"_client_email_",
"phone":"_client_phone_",
"skype":"_client_skype_",
"telegram":"_client_telegram_",
"name":"_client_name_",
"password":"_client_password_",
"additional":"_id:_identifier_of_user_account_ "
}
Possible errors:
For using parameter 'manager' curator (advertising agency) should have a currency and support manager.
Getting token for advertising agency
Method | POST |
URL | api.mgid.com/v1/auth/agencies-token |
Transfered parameters:
Parameter | Value |
login | Advertising agency login in MGID system |
password | Advertising agency password used to login into MGID system |
Returned answer:
{
"token":"_current_token_", "refreshToken":"_token_for_updating_" "accountId":"_identifier_of_user_account__"
}
_current_token_ used for Advertising agency identification; _token_for_updating_- will be used in the next versions to update the current overdue token.
Possible errors:
If login does not exist system return "Login does not exist";
If you enter the wrong password returns the error "Incorrect password."
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 "