Interface IAccountClient
Exposes methods for managing your Vonage account, including retrieving balance, managing API secrets, and configuring account settings.
public interface IAccountClient
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.
Task<AccountSettingsResult> ChangeAccountSettingsAsync(AccountSettingsRequest request, Credentials creds = null)
Parameters
requestAccountSettingsRequestThe request containing the new callback URLs. Use AccountSettingsRequest.
credsCredentialsOptional 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.
Task<Secret> CreateApiSecretAsync(CreateSecretRequest request, string apiKey = null, Credentials creds = null)
Parameters
requestCreateSecretRequestThe request containing the new secret value. See CreateSecretRequest for password requirements.
apiKeystringThe API key to create a secret for. Defaults to the authenticated account's API key.
credsCredentialsOptional credentials to override the default credentials.
Returns
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.
Task<Balance> GetAccountBalanceAsync(Credentials creds = null)
Parameters
credsCredentialsOptional credentials to override the default credentials.
Returns
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.
Task<Secret> RetrieveApiSecretAsync(string secretId, string apiKey = null, Credentials creds = null)
Parameters
secretIdstringThe unique identifier of the secret to retrieve.
apiKeystringThe API key the secret belongs to. Defaults to the authenticated account's API key.
credsCredentialsOptional credentials to override the default credentials.
Returns
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.
Task<SecretsRequestResult> RetrieveApiSecretsAsync(string apiKey = null, Credentials creds = null)
Parameters
apiKeystringThe API key to retrieve secrets for. Defaults to the authenticated account's API key.
credsCredentialsOptional 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.
Task<bool> RevokeApiSecretAsync(string secretId, string apiKey = null, Credentials creds = null)
Parameters
secretIdstringThe unique identifier of the secret to revoke.
apiKeystringThe API key the secret belongs to. Defaults to the authenticated account's API key.
credsCredentialsOptional credentials to override the default credentials.
Returns
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.
Task<TopUpResult> TopUpAccountBalanceAsync(TopUpRequest request, Credentials creds = null)
Parameters
requestTopUpRequestThe top-up request containing the transaction reference from when auto-reload was enabled.
credsCredentialsOptional 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);