Savings Simulate interest (sandbox)
Simulate interest (sandbox)
Sandbox only. Adds interest to a savings now, as the nightly run does in live, and sends `savings.interest.credited` with `source` `simulated`. The savings must hold money first. Needs a key that can initiate transfers. A live key gets a 400.
Api-Key
Headers
NameDescription
Idempotency-Key1 to 255 printable ASCII characters. A retry with the same key within 24 hours returns the first response, including a 400. After you correct a request, send a new key.
Body parameters
NameDescription
account_idThe savings account
wallet_idA savings wallet with no account
amountThe interest to add, from 0.000001 to 1000, with at most 6 decimal places
Response
Returns 200 OK. The interest was added
NameDescription
dataShow 8 child attributesobject
transaction_idThe
savings_interest transactiontypePossible values:
savings_interestaccount_idwallet_idamountcurrencyPossible values:
USDCsaved_balanceThe saved balance after the interest
statusPossible values:
completederrorErrors
| Status | Meaning |
|---|---|
| 200 | The interest was added |
| 400 | A live key, both or neither of account_id and wallet_id, an amount out of range, nothing saved yet, or an id that is not a savings one |
| 403 | The key cannot initiate transfers |
| 404 | The id is not a savings account or savings wallet of yours |
Was this page helpful? Yes No
Previous
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl --request POST \
--url 'https://api.gravv.xyz/v1/savings/simulate/interest' \
--header 'Api-Key: <api-key>' \
--header 'Idempotency-Key: savings-interest-1' \
--header 'Content-Type: application/json' \
--data '{
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount": "0.25"
}'
const response = await fetch('https://api.gravv.xyz/v1/savings/simulate/interest', {
method: 'POST',
headers: {
'Api-Key': '<api-key>',
'Idempotency-Key': 'savings-interest-1',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount": "0.25"
}),
});
const data = await response.json();
console.log(response.status, data);
import requests
url = "https://api.gravv.xyz/v1/savings/simulate/interest"
headers = {
"Api-Key": "<api-key>",
"Idempotency-Key": "savings-interest-1",
}
payload = {
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount": "0.25",
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount": "0.25"
}`)
req, err := http.NewRequest("POST", "https://api.gravv.xyz/v1/savings/simulate/interest", bytes.NewReader(payload))
if err != nil {
panic(err)
}
req.Header.Set("Api-Key", "<api-key>")
req.Header.Set("Idempotency-Key", "savings-interest-1")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(body))
}
require "json"
require "net/http"
require "uri"
uri = URI("https://api.gravv.xyz/v1/savings/simulate/interest")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Post.new(uri)
request["Api-Key"] = "<api-key>"
request["Idempotency-Key"] = "savings-interest-1"
request["Content-Type"] = "application/json"
request.body = JSON.generate({
"account_id" => "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount" => "0.25",
})
response = http.request(request)
puts response.code
puts response.body
<?php
$payload = [
'account_id' => 'd9eae506-77b4-4e8b-8ab3-caaf96054d79',
'amount' => '0.25',
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.gravv.xyz/v1/savings/simulate/interest',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Api-Key: <api-key>',
'Idempotency-Key: savings-interest-1',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
echo $status, PHP_EOL, $response, PHP_EOL;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount": "0.25"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.gravv.xyz/v1/savings/simulate/interest"))
.header("Api-Key", "<api-key>")
.header("Idempotency-Key", "savings-interest-1")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.gravv.xyz/v1/savings/simulate/interest");
request.Headers.TryAddWithoutValidation("Api-Key", "<api-key>");
request.Headers.TryAddWithoutValidation("Idempotency-Key", "savings-interest-1");
request.Content = new StringContent(
"""
{
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"amount": "0.25"
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Responseapplication/json
200400403404OK
{
"data": {
"transaction_id": "b75f078b-6c03-4a6d-b8e4-ecc1634b6727",
"type": "savings_interest",
"account_id": "d9eae506-77b4-4e8b-8ab3-caaf96054d79",
"wallet_id": "d4ed232e-ebd1-43b3-b6d7-b6739cadd13f",
"amount": "0.25",
"currency": "USDC",
"saved_balance": "110.250000",
"status": "completed"
},
"error": null
}
{
"data": null,
"error": "nothing saved: save into this account before simulating interest"
}
{
"data": {},
"error": "string"
}
{
"data": null,
"error": "savings account not found"
}