Wallets
Top Up a Wallet
Add balance to a wallet — record money received, or grant promotional credit.
POST
/
v1
/
wallets
/
{id}
/
top-up
Add balance to a wallet
curl --request POST \
--url https://billing.example.com/v1/wallets/{id}/top-up \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"source": "manual",
"expires_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://billing.example.com/v1/wallets/{id}/top-up"
payload = {
"amount": 123,
"source": "manual",
"expires_at": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 123, source: 'manual', expires_at: '2023-11-07T05:31:56Z'})
};
fetch('https://billing.example.com/v1/wallets/{id}/top-up', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/wallets/{id}/top-up",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'source' => 'manual',
'expires_at' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/wallets/{id}/top-up"
payload := strings.NewReader("{\n \"amount\": 123,\n \"source\": \"manual\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/wallets/{id}/top-up")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"source\": \"manual\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/wallets/{id}/top-up")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"source\": \"manual\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"wallet_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "top_up",
"source": "manual",
"amount": 123,
"remaining": 123,
"balance_after": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | Yes | The wallet ID. |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | integer | Yes | Minor currency units; must be greater than 0. |
source | string | No | manual (default) records money already received — bank transfer or offline. promotional grants credit with no money movement. |
expires_at | string | null | No | Promotional top-ups only: when the granted credit lapses. |
Example request
curl -X POST https://api.recurso.dev/v1/wallets/5a8c2f91-3e7b-4d0a-9c6f-2b4e8a1d7c53/top-up \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 5000000,
"source": "manual"
}'
Example response
{
"data": {
"id": "7e3b9d25-8f1c-4a6e-b2d7-4c9f0a5e8b12",
"wallet_id": "5a8c2f91-3e7b-4d0a-9c6f-2b4e8a1d7c53",
"type": "top_up",
"source": "manual",
"amount": 5000000,
"balance_after": 5000000,
"created_at": "2026-08-01T12:00:00Z"
}
}
manual top-up debits Cash and
credits Customer Credit (Code 11); a promotional top-up debits Credits &
Adjustments instead (Code 8) — no cash moved.
Errors
| Status | Code | When | Fix |
|---|---|---|---|
400 | validation_failed | id in the path is not a UUID, or the body is malformed | Use the wallet’s UUID and valid JSON |
400 | validation_failed | amount is missing or not greater than zero | Send a positive amount in minor units |
400 | validation_failed | source is neither manual nor promotional | Pick one of the two sources (default is manual) |
400 | validation_failed | expires_at set on a non-promotional top-up, or not in the future | Only promotional credit may expire, and only at a future time |
404 | not_found | Wallet doesn’t exist (or belongs to another tenant) | Check the wallet ID via List Wallets |
Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Path Parameters
Body
application/json
Response
The recorded top-up transaction
One append-only wallet movement with the balance after it.
Show child attributes
Show child attributes
⌘I
Add balance to a wallet
curl --request POST \
--url https://billing.example.com/v1/wallets/{id}/top-up \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"source": "manual",
"expires_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://billing.example.com/v1/wallets/{id}/top-up"
payload = {
"amount": 123,
"source": "manual",
"expires_at": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 123, source: 'manual', expires_at: '2023-11-07T05:31:56Z'})
};
fetch('https://billing.example.com/v1/wallets/{id}/top-up', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/wallets/{id}/top-up",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'source' => 'manual',
'expires_at' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/wallets/{id}/top-up"
payload := strings.NewReader("{\n \"amount\": 123,\n \"source\": \"manual\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/wallets/{id}/top-up")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"source\": \"manual\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/wallets/{id}/top-up")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"source\": \"manual\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"wallet_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "top_up",
"source": "manual",
"amount": 123,
"remaining": 123,
"balance_after": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}