Get spent amounts for current outgoing payment grant
Last reviewed: Oct 9, 2026
The Get Spent Amounts for Current Outgoing Payment Grant API returns the debit and receive amounts spent against the current outgoing payment grant.
When an outgoing payment grant continuation request is successful, the client receives an access token from the authorization server. The current grant is identified by this access token.
The code snippets below let an authorized client retrieve the spent amounts for the current outgoing payment grant. For grants created with a recurring interval, the amounts returned reflect the current interval only.
Before you begin
Section titled “Before you begin”We recommend creating a wallet account on the test wallet. Creating an account allows you to test your client against the Open Payments APIs by using an ILP-enabled wallet funded with play money.
Get the spent amounts for an outgoing payment grant
Section titled “Get the spent amounts for an outgoing payment grant”Prerequisites
Initial configuration
If you’re using JavaScript, only do the first step.
-
Add
"type": "module"topackage.json. -
Add the following to
tsconfig.json{"compilerOptions": {"target": "ES2022","module": "ES2022"}}
import { createAuthenticatedClient } from '@interledger/open-payments'
// Initialize clientconst client = await createAuthenticatedClient({ walletAddressUrl: CLIENT_WALLET_ADDRESS, privateKey: PRIVATE_KEY_PATH, keyId: KEY_ID})
// Get sender wallet address informationconst walletAddress = await client.walletAddress.get({ url: WALLET_ADDRESS })
// Get spent amountsconst grantSpentAmounts = await client.outgoingPayment.getGrantSpentAmounts({ url: walletAddress.resourceServer, accessToken: OUTGOING_PAYMENT_ACCESS_TOKEN})
// Outputconsole.log('GRANT_SPENT_DEBIT_AMOUNT: ', grantSpentAmounts.spentDebitAmount)// GRANT_SPENT_DEBIT_AMOUNT: { value: '800', assetCode: 'USD', assetScale: 2 }Prerequisites
// Import dependenciesuse open_payments::client::api::AuthenticatedResources;use open_payments::client::utils::get_resource_server_url;
// Initialize clientlet client = create_authenticated_client()?;
// Get spent amountslet wallet_address_url = get_env_var("WALLET_ADDRESS_URL")?;let resource_server_url = get_resource_server_url(&wallet_address_url)?;let access_token = get_env_var("OUTGOING_PAYMENT_ACCESS_TOKEN")?;
let grant_spent_amounts = client .outgoing_payments() .get_grant_spent_amounts(&resource_server_url, Some(&access_token)) .await?;
// Outputprintln!( "GRANT_SPENT_DEBIT_AMOUNT: {:#?}", grant_spent_amounts.spent_debit_amount);// GRANT_SPENT_DEBIT_AMOUNT: Some(Amount { value: "800", asset_code: "USD", asset_scale: 2 })Prerequisites
// Import dependenciesuse OpenPayments\AuthClient;use OpenPayments\Config\Config;
// Initialize client$config = new Config( $CLIENT_WALLET_ADDRESS, $PRIVATE_KEY, $KEY_ID);$opClient = new AuthClient($config);
// Get sender wallet address information$walletAddress = $opClient->walletAddress()->get([ 'url' => $WALLET_ADDRESS]);
// Get spent amounts$grantSpentAmounts = $opClient->outgoingPayment()->getGrant([ 'url' => $walletAddress->resourceServer, 'access_token' => $OUTGOING_PAYMENT_ACCESS_TOKEN]);
// Outputecho 'GRANT_SPENT_DEBIT_AMOUNT: ' . json_encode($grantSpentAmounts->spentDebitAmount?->toArray()) . PHP_EOL;// GRANT_SPENT_DEBIT_AMOUNT: {"value":"800","assetCode":"USD","assetScale":2}Prerequisites
package main
// Import dependenciesimport ( "context" "encoding/json" "fmt" "log"
op "github.com/interledger/open-payments-go")
func main() { // Initialize client client, err := op.NewAuthenticatedClient(WALLET_ADDRESS_URL, PRIVATE_KEY_BASE_64, KEY_ID) if err != nil { log.Fatalf("Error creating authenticated client: %v\n", err) }
// Get spent amounts grantSpentAmounts, err := client.OutgoingPayment.GetGrantSpentAmounts(context.TODO(), op.OutgoingPaymentGrantGetParams{ BaseURL: RESOURCE_SERVER_URL, AccessToken: OUTGOING_PAYMENT_ACCESS_TOKEN, }) if err != nil { log.Fatalf("Error fetching grant spent amounts: %v\n", err) }
// Output grantSpentAmountsJSON, err := json.MarshalIndent(grantSpentAmounts, "", " ") if err != nil { log.Fatalf("Error marshaling grant spent amounts: %v\n", err) } fmt.Println("GRANT SPENT AMOUNTS:", string(grantSpentAmountsJSON))}Prerequisites
// Coming soonPrerequisites
// Coming soon