Back to Developer Help
8

Manage Credits & Billing

Check your credit balance and transfer credits between phone groups.

Endpoint

GET /api/v1/credits/balance Requires authentication (X-API-Key)

Common Error Responses

404 GROUP_NOT_FOUND

The specified phone group does not exist.

400 INSUFFICIENT_CREDITS

Not enough credits to transfer.

Code Samples

# Check balance
curl https://api.palmtext.com/api/v1/credits/balance \
  -H 'X-API-Key: YOUR_API_KEY'

# Transfer credits
curl -X POST https://api.palmtext.com/api/v1/credits/transfer \
  -H 'X-API-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"to_group": 2, "amount": 100}'
import requests

# Check balance
resp = requests.get(
    'https://api.palmtext.com/api/v1/credits/balance',
    headers={'X-API-Key': 'YOUR_API_KEY'}
)
print(resp.json())

# Transfer credits
resp = requests.post(
    'https://api.palmtext.com/api/v1/credits/transfer',
    headers={'X-API-Key': 'YOUR_API_KEY'},
    json={'to_group': 2, 'amount': 100}
)
print(resp.json())
// Check balance
const balRes = await fetch('https://api.palmtext.com/api/v1/credits/balance', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const balData = await balRes.json();

// Transfer credits
const transferRes = await fetch('https://api.palmtext.com/api/v1/credits/transfer', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({ to_group: 2, amount: 100 })
});
const transferData = await transferRes.json();
<?php
$ch = curl_init();

// Check balance
curl_setopt_array($ch, [
  CURLOPT_URL => 'https://api.palmtext.com/api/v1/credits/balance',
  CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY'],
  CURLOPT_RETURNTRANSFER => true,
]);
$resp = curl_exec($ch);
echo $resp;

// Transfer credits
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_URL => 'https://api.palmtext.com/api/v1/credits/transfer',
  CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY', 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode(['to_group' => 2, 'amount' => 100]),
]);
$resp = curl_exec($ch);
echo $resp;
curl_close($ch);
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {
  // Check balance
  req, _ := http.NewRequest("GET",
    "https://api.palmtext.com/api/v1/credits/balance", nil)
  req.Header.Set("X-API-Key", "YOUR_API_KEY")
  resp, _ := http.DefaultClient.Do(req)
  fmt.Println(resp.Status)
  resp.Body.Close()

  // Transfer credits
  body, _ := json.Marshal(map[string]int{"to_group": 2, "amount": 100})
  req, _ = http.NewRequest("POST",
    "https://api.palmtext.com/api/v1/credits/transfer", bytes.NewBuffer(body))
  req.Header.Set("X-API-Key", "YOUR_API_KEY")
  req.Header.Set("Content-Type", "application/json")
  resp, _ = http.DefaultClient.Do(req)
  defer resp.Body.Close()
  fmt.Println(resp.Status)
}