> For the complete documentation index, see [llms.txt](https://developers.textcus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.textcus.com/overview/account-balance.md).

# Account Balance

### Endpoint <a href="#endpoint" id="endpoint"></a>

<mark style="color:green;">**`GET`**</mark> `https://api.textcus.com/api/v2/balance`

### Headers <a href="#headers" id="headers"></a>

`Authorization: Bearer API_KEY`

### **Header Parameters** <a href="#path-parameters" id="path-parameters"></a>

| Parameters                                           | Type     | Description                                                      |
| ---------------------------------------------------- | -------- | ---------------------------------------------------------------- |
| <p>apikey</p><p><em><strong>string</strong></em></p> | Required | Your unique API key is required to retrieve your TextCus balance |

## Sample Requests <a href="#sample-requests" id="sample-requests"></a>

{% tabs %}
{% tab title="PHP" %}

```php
<?php
$url = 'https://api.textcus.com/api/v2/balance';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY' // Replace 'API_KEY' with your actual API key
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: `https://api.textcus.com/api/v2/balance`,
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

axios(config).then(function(response) {
    console.log(JSON.stringify(response.data));
}).catch(function(error) {
    console.error(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = f'https://api.textcus.com/api/v2/balance'

headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}

{% tab title="Dart" %}

```dart
import 'dart:convert';
import 'package:http/http.dart' as http;

void main() async {
  String url = 'https://api.textcus.com/api/v2/balance';

  try {
    final response = await http.get(
      Uri.parse(url),
      headers: {
        'Authorization': 'Bearer API_KEY', // Replace 'API_KEY' with your actual API Key
      },
    );

    if (response.statusCode == 200) {
      // If the server returns an OK response, parse the JSON
      print(response.body);
    } else {
      // If the server did not return a 200 OK response, throw an exception.
      print('Failed to load balance. Status code: ${response.statusCode}');
    }
  } catch (e) {
    print('Error: $e');
  }
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpHeaders;
import java.net.http.HttpResponse.BodyHandlers;

public class CheckBalance {

    public static void main(String[] args) {
        String url = "https://api.textcus.com/api/v2/balance";

        try {
            // Create HttpClient
            HttpClient client = HttpClient.newHttpClient();

            // Build the GET request
            HttpRequest request = HttpRequest.newBuilder()
                    .uri(URI.create(url))
                    .header("Authorization", "Bearer API_KEY")  // Replace 'API_KEY' with your actual API Key
                    .GET()
                    .build();

            // Send the request and get the response
            HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

            // Check if the request was successful
            if (response.statusCode() == 200) {
                System.out.println("Response: " + response.body());
            } else {
                System.out.println("Failed to retrieve balance. Status code: " + response.statusCode());
                System.out.println("Response: " + response.body());
            }

        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

```

{% endtab %}

{% tab title="VB.Net" %}

```vbnet
Imports System.Net.Http
Imports System.Threading.Tasks

Module Module1
    Sub Main()
        Dim url As String = "https://api.textcus.com/api/v2/balance"

        Dim response As String = GetApiResponseAsync(url, apiKey).GetAwaiter().GetResult()

        Console.WriteLine(response)
    End Sub

    Async Function GetApiResponseAsync(url As String, apiKey As String) As Task(Of String)
        Using client As New HttpClient()
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " & apiKey) ' Replace 'API_KEY' with your actual API key

            Dim response As HttpResponseMessage = Await client.GetAsync(url)
            If response.IsSuccessStatusCode Then
                Return Await response.Content.ReadAsStringAsync()
            Else
                Return "Error: " & response.StatusCode.ToString()
            End If
        End Using
    End Function
End Module
```

{% endtab %}
{% endtabs %}

## Sample Response <a href="#sample-response" id="sample-response"></a>

{% tabs %}
{% tab title="Success" %}

```json
{
    "status": 200,
    "message": "Balance retrieved",
    "data": {
        "sms_rate": 0.028,
        "sms_balance": 71429,
        "email_balance": 2000,
        "wallet_balance": 0.00,
    }
}
```

{% endtab %}

{% tab title="Errors" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
}, 

{
    "status": 401,
    "error": "Unauthorized: Invalid API Key"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.textcus.com/overview/account-balance.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
