Account Management

These endpoints let you manage your account's credit balance and OAuth2 authentication tokens programmatically. Check your balance before sending campaigns, purchase credits when running low, and manage token lifecycle for production applications.

Credits

Every message you send consumes credits. Use GET /v1/credits to check your current balance and POST /v1/credits/purchase to buy more. The purchase endpoint requires credits (integer) and creditCardLastFour (string). You can optionally include a couponCode.

# Check your credit balance
curl --request GET \
  --url https://a.eztexting.com/v1/credits \
  --header "Authorization: Basic $(echo -n 'your_username:your_password' | base64)"

# Purchase additional credits
curl --request POST \
  --url https://a.eztexting.com/v1/credits/purchase \
  --header "Authorization: Basic $(echo -n 'your_username:your_password' | base64)" \
  --header "Content-Type: application/json" \
  --data '{"credits": 1000, "creditCardLastFour": "4242"}'

OAuth2 tokens

OAuth2 is the recommended authentication method for production applications. Tokens expire after 5,400 seconds (90 minutes). Refresh tokens remain valid for 60 days. The token endpoints don't require existing authentication — you create a token by posting your credentials.

# Create an OAuth2 token
curl --request POST \
  --url https://a.eztexting.com/v1/tokens/create \
  --header "Content-Type: application/json" \
  --data '{
    "username": "your_username",
    "password": "your_password"
  }'

# Refresh a token before it expires
curl --request POST \
  --url https://a.eztexting.com/v1/tokens/refresh \
  --header "Content-Type: application/json" \
  --data '{
    "refreshToken": "your_refresh_token_here"
  }'

# Revoke a token
curl --request POST \
  --url https://a.eztexting.com/v1/tokens/revoke \
  --header "Content-Type: application/json" \
  --data '{
    "token": "your_access_token_here",
    "type": "ACCESS_TOKEN"
  }'

Token lifecycle

  1. CreatePOST /v1/tokens/create with username (your EZ Texting username or email) and password. Returns accessToken, refreshToken, and expiresInSeconds.
  2. Use — Include the access token in requests as Authorization: Bearer {token}.
  3. Refresh — Before the access token expires, call POST /v1/tokens/refresh with the refreshToken.
  4. Revoke — When a token is no longer needed, call POST /v1/tokens/revoke with the token and its type (ACCESS_TOKEN or REFRESH_TOKEN).
Security tip:Store tokens as environment variables. Never hardcode credentials or tokens in your source code. Revoke tokens when they're no longer needed, and use refresh tokens to avoid storing your username/password in long-running applications.

Endpoints reference

EndpointMethodDescription
/v1/creditsGETCheck credit balance
/v1/credits/purchasePOSTPurchase additional credits
/v1/tokens/createPOSTGenerate OAuth2 access token
/v1/tokens/refreshPOSTRefresh an expiring token
/v1/tokens/revokePOSTRevoke an active token

Next steps