Cards Withdraw from a card
Withdraw from a card
Moves money from an `active`, frozen or `blocked` card back to its linked card account or linked wallet. One call works for every card: some pay out straight away (`status` `completed`, with `tx_hash`), the others by transfer (`status` `pending`, with `transfer_id`). Gravv sends the `cards.transaction.withdraw` webhook when the withdrawal ends. A call that errors or times out may still have moved the money: read the card balance and your webhooks before you retry with a new Idempotency-Key.
Api-Key
Headers
NameDescription
Idempotency-Key1 to 255 printable ASCII characters. A retry with the same key within 24 hours returns the first response. Use a new key for each new card or withdrawal, and the same key to retry a failed one.
Body parameters
NameDescription
card_idamountUSD, as a JSON number with at most 2 decimal places, not more than the card's
balanceResponse
Returns 200 OK. The withdrawal is done (completed) or on its way (pending)
NameDescription
dataShow 4 child attributesobject
tx_hashThe chain transaction, when the card paid out straight away. Empty otherwise
transfer_idThe transfer that pays the money out, when the card pays out by transfer
statusPossible values:
completed, pendingroutePossible values:
card, transfererrorErrors
| Status | Meaning |
|---|---|
| 200 | The withdrawal is done (completed) or on its way (pending) |
| 400 | The card is inactive, the amount is not positive, or the balance is too low |
Was this page helpful? Yes No
Previous
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl --request POST \
--url 'https://api.gravv.xyz/v1/cards/withdraw' \
--header 'Api-Key: <api-key>' \
--header 'Idempotency-Key: issue-card-jane-1' \
--header 'Content-Type: application/json' \
--data '{
"card_id": "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount": 20
}'
const response = await fetch('https://api.gravv.xyz/v1/cards/withdraw', {
method: 'POST',
headers: {
'Api-Key': '<api-key>',
'Idempotency-Key': 'issue-card-jane-1',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"card_id": "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount": 20
}),
});
const data = await response.json();
console.log(response.status, data);
import requests
url = "https://api.gravv.xyz/v1/cards/withdraw"
headers = {
"Api-Key": "<api-key>",
"Idempotency-Key": "issue-card-jane-1",
}
payload = {
"card_id": "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount": 20,
}
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(`{
"card_id": "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount": 20
}`)
req, err := http.NewRequest("POST", "https://api.gravv.xyz/v1/cards/withdraw", bytes.NewReader(payload))
if err != nil {
panic(err)
}
req.Header.Set("Api-Key", "<api-key>")
req.Header.Set("Idempotency-Key", "issue-card-jane-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/cards/withdraw")
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"] = "issue-card-jane-1"
request["Content-Type"] = "application/json"
request.body = JSON.generate({
"card_id" => "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount" => 20,
})
response = http.request(request)
puts response.code
puts response.body
<?php
$payload = [
'card_id' => 'dce0192a-9b3d-440b-9500-33dc9ac8dc20',
'amount' => 20,
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.gravv.xyz/v1/cards/withdraw',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Api-Key: <api-key>',
'Idempotency-Key: issue-card-jane-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 = """
{
"card_id": "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount": 20
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.gravv.xyz/v1/cards/withdraw"))
.header("Api-Key", "<api-key>")
.header("Idempotency-Key", "issue-card-jane-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/cards/withdraw");
request.Headers.TryAddWithoutValidation("Api-Key", "<api-key>");
request.Headers.TryAddWithoutValidation("Idempotency-Key", "issue-card-jane-1");
request.Content = new StringContent(
"""
{
"card_id": "dce0192a-9b3d-440b-9500-33dc9ac8dc20",
"amount": 20
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Responseapplication/json
200400OK
{
"data": {
"tx_hash": "0x2e5d0af9189b4b4c23bc64b96295e730609ec91e50e452a5da0a4af4bfe5c192",
"status": "completed",
"route": "card"
},
"error": null
}
{
"data": null,
"error": "insufficient balance"
}