Table of Contents

Class AccountClient

Namespace
Vonage.Accounts
Assembly
Vonage.dll

Client for managing Vonage account operations including balance inquiries, API secret management, and account settings. Implements the Vonage Account API.

public class AccountClient : IAccountClient
Inheritance
AccountClient
Implements
Inherited Members

Constructors

AccountClient(Credentials)

Initializes a new instance of the AccountClient class.

public AccountClient(Credentials creds = null)

Parameters

creds Credentials

Optional credentials to use for authentication.

Properties

Credentials

The credentials used for authenticating API requests.

public Credentials Credentials { get; set; }

Property Value

Credentials

Methods

ChangeAccountSettingsAsync(AccountSettingsRequest, Credentials)

Updates the default webhook callback URLs associated with your account for incoming SMS messages and delivery receipts. The provided URLs must be valid and return a 200 OK response for Vonage to save the settings.

public Task<AccountSettingsResult> ChangeAccountSettingsAsync(AccountSettingsRequest request, Credentials creds = null)

Parameters

request AccountSettingsRequest

The request containing the new callback URLs. Use AccountSettingsRequest.

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<AccountSettingsResult>

An AccountSettingsResult containing the updated settings and rate limits.

Examples

var request = new AccountSettingsRequest
{
    MoCallBackUrl = "https://example.com/webhooks/inbound-sms",
    DrCallBackUrl = "https://example.com/webhooks/delivery-receipt"
};
var result = await client.AccountClient.ChangeAccountSettingsAsync(request);
See Also

CreateApiSecretAsync(CreateSecretRequest, string, Credentials)

Creates a new API secret for the specified API key. You can have a maximum of two secrets per API key.

public Task<Secret> CreateApiSecretAsync(CreateSecretRequest request, string apiKey = null, Credentials creds = null)

Parameters

request CreateSecretRequest

The request containing the new secret value. See CreateSecretRequest for password requirements.

apiKey string

The API key to create a secret for. Defaults to the authenticated account's API key.

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<Secret>

A Secret containing the created secret's ID and creation timestamp.

Examples

var request = new CreateSecretRequest { Secret = "MyNewS3cret!" };
var secret = await client.AccountClient.CreateApiSecretAsync(request);
Console.WriteLine($"Created secret with ID: {secret.Id}");
See Also

GetAccountBalanceAsync(Credentials)

Retrieves the current balance of your Vonage API account.

public Task<Balance> GetAccountBalanceAsync(Credentials creds = null)

Parameters

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<Balance>

A Balance object containing the account balance in EUR and auto-reload status.

Examples

var balance = await client.AccountClient.GetAccountBalanceAsync();
Console.WriteLine($"Balance: {balance.Value} EUR");
Console.WriteLine($"Auto-reload: {balance.AutoReload}");
See Also

RetrieveApiSecretAsync(string, string, Credentials)

Retrieves information about a specific API secret.

public Task<Secret> RetrieveApiSecretAsync(string secretId, string apiKey = null, Credentials creds = null)

Parameters

secretId string

The unique identifier of the secret to retrieve.

apiKey string

The API key the secret belongs to. Defaults to the authenticated account's API key.

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<Secret>

A Secret containing the secret's ID, creation timestamp, and reference links.

Examples

var secret = await client.AccountClient.RetrieveApiSecretAsync("secret-id-123");
Console.WriteLine($"Secret created at: {secret.CreatedAt}");
See Also

RetrieveApiSecretsAsync(string, Credentials)

Retrieves all API secrets associated with the specified API key. It is recommended to rotate secrets periodically for security purposes. To manage secrets for secondary accounts, authenticate with primary credentials and supply the secondary API key.

public Task<SecretsRequestResult> RetrieveApiSecretsAsync(string apiKey = null, Credentials creds = null)

Parameters

apiKey string

The API key to retrieve secrets for. Defaults to the authenticated account's API key.

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<SecretsRequestResult>

A SecretsRequestResult containing the list of secrets.

Examples

var result = await client.AccountClient.RetrieveApiSecretsAsync();
foreach (var secret in result.Embedded.Secrets)
{
    Console.WriteLine($"Secret ID: {secret.Id}, Created: {secret.CreatedAt}");
}
See Also

RevokeApiSecretAsync(string, string, Credentials)

Revokes (deletes) an API secret. Ensure you have another valid secret before revoking, as at least one secret is required for API authentication.

public Task<bool> RevokeApiSecretAsync(string secretId, string apiKey = null, Credentials creds = null)

Parameters

secretId string

The unique identifier of the secret to revoke.

apiKey string

The API key the secret belongs to. Defaults to the authenticated account's API key.

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<bool>

true if the secret was successfully revoked.

Examples

var success = await client.AccountClient.RevokeApiSecretAsync("secret-id-123");
if (success)
{
    Console.WriteLine("Secret revoked successfully.");
}
See Also

TopUpAccountBalanceAsync(TopUpRequest, Credentials)

Tops up your account balance when auto-reload is enabled in the dashboard. The top-up amount matches the amount configured when auto-reload was enabled. Account balance is checked every 5-10 minutes for automatic top-up; use this endpoint when credit may be exhausted faster than automatic top-up occurs.

public Task<TopUpResult> TopUpAccountBalanceAsync(TopUpRequest request, Credentials creds = null)

Parameters

request TopUpRequest

The top-up request containing the transaction reference from when auto-reload was enabled.

creds Credentials

Optional credentials to override the default credentials.

Returns

Task<TopUpResult>

A TopUpResult containing the response status.

Examples

var request = new TopUpRequest { Trx = "your-transaction-reference" };
var result = await client.AccountClient.TopUpAccountBalanceAsync(request);