Skip to main content
POST
/
wallets
/
{walletId}
/
withdraw
cURL
curl --request POST \
  --url https://api.grainfinance.co/v1/wallets/{walletId}/withdraw \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "amount": 10000
}
'
import requests

url = "https://api.grainfinance.co/v1/wallets/{walletId}/withdraw"

payload = { "amount": 10000 }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 10000})
};

fetch('https://api.grainfinance.co/v1/wallets/{walletId}/withdraw', 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://api.grainfinance.co/v1/wallets/{walletId}/withdraw",
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' => 10000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://api.grainfinance.co/v1/wallets/{walletId}/withdraw"

payload := strings.NewReader("{\n \"amount\": 10000\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.grainfinance.co/v1/wallets/{walletId}/withdraw")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 10000\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.grainfinance.co/v1/wallets/{walletId}/withdraw")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 10000\n}"

response = http.request(request)
puts response.read_body
{
  "id": "1b0ada1e-fa1b-4cfe-a553-01b340c5650e"
}
{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}
{
"message": "The request failed because the resource does not exist."
}
{
"message": "The request failed because a business rule constraint was violated."
}
{
"message": "The request failed because it is either semantically incorrect or has failed business validation."
}

Authorizations

Authorization
string
header
required

Basic authentication using the partner API keys from https://console.grainfinance.co/keys

Path Parameters

walletId
string<uuid>
required

The id of the wallet within the Grain platform. Stringified UUIDv4. See RFC 4112

Pattern: [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}

Body

application/json

The payload required in order to withdraw fund transfers

The payload required in order to withdraw fund transfers

amount
number<double>
required

The amount of the funds requested to be withdrawn.

Example:

10000

Response

Withdraw completed successfully

A response containing the ID of the created object.

id
string<uuid>
required

The id of the created object.

Pattern: [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}
Example:

"1b0ada1e-fa1b-4cfe-a553-01b340c5650e"