openapi: 3.0.0
info:
  title: Management
  description: Endpoints associated with creating and managing user accounts.
servers:
  - url: https://rest.clicksend.com
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
  schemas:
    currency:
      type: object
      description: The parameters related to currency.
      properties:
        currency_name_short:
          type: string
          description: >-
            The currency used for the sender in three-letter format (e.g. USD,
            EUR, AUD, NZD, etc).
          example: AUD
        currency_prefix_d:
          type: string
          description: >-
            The symbol used to indicate the currency of the sender (e.g. $ , €,
            etc).
          example: $
        currency_prefix_c:
          type: string
          description: The currency basic unit (e.g. cents).
          example: c
        currency_name_long:
          type: string
          description: The full name of the currency.
          example: Australian Dollars
    subaccount:
      type: object
      properties:
        subaccount_id:
          type: integer
          description: The unique identifier for the subaccount.
          example: 126
        api_username:
          type: string
          description: The API username of the subaccount.
          example: johndoe1
        email:
          type: string
          format: email
          description: The email address of the subaccount.
          example: johndoe1@awesome.com
        phone_number:
          type: string
          description: The phone number of the subaccount.
          example: '+15184811001'
        first_name:
          type: string
          description: The first name of the subaccount.
          example: John
        last_name:
          type: string
          description: The last name of the subaccount.
          example: Doe
        api_key:
          type: string
          description: The API key of the subaccount.
          example: F3702045-EB2C-0091-C211-7728048DCAE2
        access_users:
          type: integer
          description: Flag indicating if the subaccount has access to users.
          example: 1
        access_billing:
          type: integer
          description: Flag indicating if the subaccount has access to billing.
          example: 1
        access_reporting:
          type: integer
          description: Flag indicating if the subaccount has access to reporting.
          example: 1
        access_contacts:
          type: integer
          description: Flag indicating if the subaccount has access to contacts.
          example: 1
        access_settings:
          type: integer
          description: Flag indicating if the subaccount has access to settings.
          example: 1
        access_sms:
          type: integer
          description: Flag indicating if the subaccount has access to SMS.
          example: 1
        access_email:
          type: integer
          description: Flag indicating if the subaccount has access to email.
          example: 1
        access_voice:
          type: integer
          description: Flag indicating if the subaccount has access to voice services.
          example: 1
        access_fax:
          type: integer
          description: Flag indicating if the subaccount has access to fax services.
          example: 1
        access_post:
          type: integer
          description: Flag indicating if the subaccount has access to post services.
          example: 1
        access_reseller:
          type: integer
          description: Flag indicating if the subaccount has access to reseller services.
          example: 1
        access_mms:
          type: integer
          description: Flag indicating if the subaccount has access to MMS services.
          example: 1
        share_campaigns:
          type: integer
          description: Flag indicating if the subaccount can share campaigns.
          example: 0
        notes:
          type: string
          nullable: true
          description: Additional notes for the subaccount.
          example: null
    account:
      type: object
      properties:
        user_id:
          type: integer
          description: The unique identifier for the user.
          example: 116
        username:
          type: string
          description: The username of the user.
          example: johndoe1
        user_email:
          type: string
          format: email
          description: The email address of the user.
          example: johndoe1@awesome.com
        active:
          type: integer
          description: Flag indicating if the user account is active.
          example: 0
        banned:
          type: integer
          description: Flag indicating if the user account is banned.
          example: 0
        balance:
          type: string
          description: The balance of the user's account.
          example: '4.998000'
        user_phone:
          type: string
          description: The phone number of the user.
          example: '+15184811001'
        reply_to:
          type: string
          description: The email address to reply to.
          example: originalemail
        delivery_to:
          type: string
          nullable: true
          description: The delivery email address.
          example: null
        user_first_name:
          type: string
          description: The first name of the user.
          example: John
        user_last_name:
          type: string
          description: The last name of the user.
          example: Doe
        account:
          type: integer
          description: The account number.
          example: 0
        account_name:
          type: string
          description: The name of the account.
          example: The Awesome Company
        account_billing_email:
          type: string
          format: email
          description: The billing email address of the account.
          example: johndoe1@awesome.com
        account_billing_mobile:
          type: string
          description: The billing mobile number of the account.
          example: '+15184811001'
        country:
          type: string
          description: The country of the user.
          example: US
        default_country_sms:
          type: string
          description: The default country for SMS.
          example: US
        auto_recharge:
          type: integer
          description: Flag indicating if auto-recharge is enabled.
          example: 0
        auto_recharge_amount:
          type: string
          description: The auto-recharge amount.
          example: '20.00'
        low_credit_amount:
          type: string
          description: The low credit amount.
          example: '0.00'
        setting_unicode_sms:
          type: integer
          description: Flag indicating if unicode SMS is enabled.
          example: 0
        setting_email_sms_subject:
          type: integer
          description: Flag indicating if email SMS subject is enabled.
          example: 0
        setting_fix_sender_id:
          type: integer
          description: Flag indicating if fixing sender ID is enabled.
          example: 0
        setting_sms_message_char_limit:
          type: integer
          description: The SMS message character limit.
          example: 6
        old_dashboard:
          type: integer
          description: Flag indicating if old dashboard is enabled.
          example: 0
        balance_commission:
          type: string
          description: The balance commission.
          example: 0.299954
        timezone:
          type: string
          description: The timezone of the user.
          example: Australia/Melbourne
        _currency:
          $ref: '#/components/schemas/currency'
        _subaccount:
          $ref: '#/components/schemas/subaccount'
    view-account-details:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here's your account.
        data:
          $ref: '#/components/schemas/account'
    view-account-usage:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here is your usage for this month.
        data:
          type: object
          properties:
            sms:
              type: array
              items:
                type: object
                properties:
                  subaccount_id:
                    type: integer
                    description: The subaccount identifier.
                  username:
                    type: string
                    description: The username associated with the subaccount.
                  total_count:
                    type: string
                    description: The total count of SMS.
                  total_price:
                    type: string
                    description: The total price of SMS.
              example:
                - subaccount_id: 1039
                  username: gerald
                  total_count: '29.00'
                  total_price: '2.1337'
                - subaccount_id: 1047
                  username: user5
                  total_count: '4.00'
                  total_price: '0.3080'
            voice:
              type: array
              items:
                type: object
                properties:
                  subaccount_id:
                    type: integer
                    description: The subaccount identifier.
                  username:
                    type: string
                    description: The username associated with the subaccount.
                  total_count:
                    type: string
                    description: The total count of voice calls.
                  total_price:
                    type: string
                    description: The total price of voice calls.
              example:
                - subaccount_id: 1039
                  username: user1
                  total_count: '6.00'
                  total_price: '0.1980'
                - subaccount_id: 1047
                  username: user5
                  total_count: '1.00'
                  total_price: '0.0330'
            fax:
              type: array
              items:
                type: object
                properties:
                  subaccount_id:
                    type: integer
                    description: The subaccount identifier.
                  username:
                    type: string
                    description: The username associated with the subaccount.
                  total_count:
                    type: string
                    description: The total count of fax messages.
                  total_price:
                    type: string
                    description: The total price of fax messages.
              example:
                - subaccount_id: 1039
                  username: user1
                  total_count: '3.00'
                  total_price: '0.6943'
                - subaccount_id: 1047
                  username: user5
                  total_count: '1.00'
                  total_price: '0.2314'
            post:
              type: array
              items:
                type: object
                properties:
                  subaccount_id:
                    type: integer
                    description: The subaccount identifier.
                  username:
                    type: string
                    description: The username associated with the subaccount.
                  total_count:
                    type: string
                    description: The total count of postal mails.
                  total_price:
                    type: string
                    description: The total price of postal mails.
              example:
                - subaccount_id: 1039
                  username: user1
                  total_count: '10'
                  total_price: '8.5624'
                - subaccount_id: 1047
                  username: user5
                  total_count: '3'
                  total_price: '2.5586'
            email:
              type: array
              items:
                type: object
                properties:
                  subaccount_id:
                    type: integer
                    description: The subaccount identifier.
                  username:
                    type: string
                    description: The username associated with the subaccount.
                  total_count:
                    type: integer
                    description: The total count of emails.
                  total_price:
                    type: string
              example:
                - subaccount_id: 1039
                  username: user1
                  total_count: 3992
                  total_price: '9.0020'
                - subaccount_id: 1047
                  username: user5
                  total_count: 998
                  total_price: '0.0000'
            sms_total:
              type: object
              properties:
                count:
                  type: string
                  description: The total count of SMS.
                price:
                  type: string
                  description: The total price of SMS.
              example:
                count: 33
                price: '2.4417'
            voice_total:
              type: object
              properties:
                count:
                  type: string
                  description: The total count of voice calls.
                price:
                  type: string
                  description: The total price of voice calls.
              example:
                count: 7
                price: '0.2310'
            fax_total:
              type: object
              properties:
                count:
                  type: string
                  description: The total count of fax messages.
                price:
                  type: string
                  description: The total price of fax messages.
              example:
                count: 4
                price: '0.9257'
            post_total:
              type: object
              properties:
                count:
                  type: string
                  description: The total count of postal mails.
                price:
                  type: string
                  description: The total price of postal mails.
              example:
                count: 13
                price: '11.1210'
            email_total:
              type: object
              properties:
                count:
                  type: integer
                  description: The total count of emails.
                price:
                  type: string
                  description: The total price of emails.
              example:
                count: 4990
                price: '9.0020'
paths:
  /v3/account:
    get:
      summary: View Account Details
      operationId: view-account-details
      description: >-
        _Get account information_


        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.


        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#pagination" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/view-account-details'
      x-codeSamples:
        - lang: PHP
          source: >-
            <?php

            require_once(__DIR__ . '/vendor/autoload.php');


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\AccountApi(new
            GuzzleHttp\Client(),$config);


            try {
                $result = $apiInstance->accountGet();
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling AccountApi->accountGet: ', $e->getMessage(), PHP_EOL;
            }

            ?>  
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var accountApi = new AccountApi(configuration);
            var response = accountApi.AccountGet();          
        - lang: Java
          source: |-
            package ClickSend;

            import ClickSend.Api.AccountApi;

            public class view_account_detail {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                AccountApi apiInstance = new AccountApi(defaultClient);
                try {
                    String result = apiInstance.accountGet();
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling AccountApi#accountGet");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: |-
            var api = require('./api.js');

            var accountApi = new api.AccountApi("USERNAME", "API_KEY");

            accountApi.accountGet().then(function(response) {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });            
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::AccountApi.new

            begin
              # Get account information
              result = api_instance.account_get
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling AccountApi->account_get: #{e.response_body}"
            end            
        - lang: Python
          source: >
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.AccountApi(clicksend_client.ApiClient(configuration))


            try:
                # Get account information
                api_response = api_instance.account_get()
                print(api_response)
            except ApiException as e:
                print("Exception when calling AccountApi->account_get: %s\n" % e)            
        - lang: objc
          source: >
            #import "CSDefaultConfiguration.h"

            #import "CSAccountApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            // Configure HTTP basic authorization (authentication scheme:
            BasicAuth)

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            CSAccountApi *accountAPI = [[CSAccountApi alloc] init];

            [accountAPI accountGetWithCompletionHandler:^(NSString *output,
            NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"Output: %@", output);
                }
            }];                
        - lang: swift
          source: >
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }


            AccountAPI.accountGet { (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }

                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }            
        - lang: curl
          source: >-
            curl --include \

            --header "Authorization: Basic
            YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \

            'https://rest.clicksend.com/v3/account'
  /v3/account/usage/{year}/{month}/subaccount:
    get:
      summary: View Account Usage
      operationId: view-account-usage
      description: >-
        _Get account usage_


        | **Name** | **Type** | **Required** | **Restrictions** |
        **Description** |

        | --- | --- | --- | --- | --- |

        | year | string | true | none | Your account usage year. Example: 2019 |

        | month | string | true | none | Your account usage month. Example: 4 |


        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.


        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#pagination" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
        - name: year
          in: path
          schema:
            type: string
          required: true
        - name: month
          in: path
          schema:
            type: string
          required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/view-account-usage'
