curl --request POST \
--url https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"payment_record_id": "<string>",
"bank_record_id": "<string>",
"reason": "<string>"
}
'import requests
url = "https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns"
payload = {
"payment_record_id": "<string>",
"bank_record_id": "<string>",
"reason": "<string>"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({payment_record_id: '<string>', bank_record_id: '<string>', reason: '<string>'})
};
fetch('https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns', 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.endclose.com/v1/reconciliations/{reconciliation_id}/returns",
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([
'payment_record_id' => '<string>',
'bank_record_id' => '<string>',
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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.endclose.com/v1/reconciliations/{reconciliation_id}/returns"
payload := strings.NewReader("{\n \"payment_record_id\": \"<string>\",\n \"bank_record_id\": \"<string>\",\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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.endclose.com/v1/reconciliations/{reconciliation_id}/returns")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"payment_record_id\": \"<string>\",\n \"bank_record_id\": \"<string>\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_record_id\": \"<string>\",\n \"bank_record_id\": \"<string>\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"return_record": {
"amount": 123,
"direction": "credit",
"date": "2023-12-25",
"data_stream_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"decimal_places": 2,
"description": "<string>",
"metadata": {},
"external_id": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"record_type": "payment",
"return_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"returns": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
}
],
"residual_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"residual": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
},
"split_from_record_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"split_role": "carve_out",
"split_from": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"partially_matched": true,
"partially_matched_reconciliation_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"split": {
"matched_amount": 123,
"open_amount": 123,
"fully_matched": true,
"parts": 123,
"remainders": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
}
]
}
},
"reconciliation_match": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "<string>",
"group_key": "<string>",
"reconciliation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reconciliation_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"record_count": 123
},
"residual_record": {
"amount": 123,
"direction": "credit",
"date": "2023-12-25",
"data_stream_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"decimal_places": 2,
"description": "<string>",
"metadata": {},
"external_id": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"record_type": "payment",
"return_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"returns": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
}
],
"residual_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"residual": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
},
"split_from_record_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"split_role": "carve_out",
"split_from": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"partially_matched": true,
"partially_matched_reconciliation_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"split": {
"matched_amount": 123,
"open_amount": 123,
"fully_matched": true,
"parts": 123,
"remainders": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
}
]
}
}
}Record a return
Records a return (for example an ACH return or a reversed card payment) of a payment and reconciles it to the bank transaction that moved the money back. End Close creates a new record with record_type return on the payment’s data stream. Its amount is the bank transaction’s amount, its direction is opposite to the payment, and its return_of is the payment. The return is matched to the bank transaction. The payment keeps its own match, if it has one, and lists the return under returns, so this works for a return that arrives before or after the payment is matched.
The payment and the bank transaction must be on opposite sides of the reconciliation, move money in opposite directions, and use the same currency. The bank transaction must be unreconciled in this reconciliation. A partial return (a bank amount below the payment amount) is allowed. A payment can have several returns, but together they cannot exceed the payment amount. When the returns add up to less than the payment amount, End Close also keeps a residual record open for the rest, on the reconciliation’s adjustments data stream. It has the payment’s direction and currency, and its residual_of is the payment. Each later return replaces it, and a full return deletes it. A return is refused while the residual is matched or written off.
curl --request POST \
--url https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"payment_record_id": "<string>",
"bank_record_id": "<string>",
"reason": "<string>"
}
'import requests
url = "https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns"
payload = {
"payment_record_id": "<string>",
"bank_record_id": "<string>",
"reason": "<string>"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({payment_record_id: '<string>', bank_record_id: '<string>', reason: '<string>'})
};
fetch('https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns', 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.endclose.com/v1/reconciliations/{reconciliation_id}/returns",
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([
'payment_record_id' => '<string>',
'bank_record_id' => '<string>',
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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.endclose.com/v1/reconciliations/{reconciliation_id}/returns"
payload := strings.NewReader("{\n \"payment_record_id\": \"<string>\",\n \"bank_record_id\": \"<string>\",\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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.endclose.com/v1/reconciliations/{reconciliation_id}/returns")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"payment_record_id\": \"<string>\",\n \"bank_record_id\": \"<string>\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.endclose.com/v1/reconciliations/{reconciliation_id}/returns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_record_id\": \"<string>\",\n \"bank_record_id\": \"<string>\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"return_record": {
"amount": 123,
"direction": "credit",
"date": "2023-12-25",
"data_stream_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"decimal_places": 2,
"description": "<string>",
"metadata": {},
"external_id": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"record_type": "payment",
"return_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"returns": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
}
],
"residual_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"residual": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
},
"split_from_record_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"split_role": "carve_out",
"split_from": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"partially_matched": true,
"partially_matched_reconciliation_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"split": {
"matched_amount": 123,
"open_amount": 123,
"fully_matched": true,
"parts": 123,
"remainders": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
}
]
}
},
"reconciliation_match": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "<string>",
"group_key": "<string>",
"reconciliation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reconciliation_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"record_count": 123
},
"residual_record": {
"amount": 123,
"direction": "credit",
"date": "2023-12-25",
"data_stream_key": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"decimal_places": 2,
"description": "<string>",
"metadata": {},
"external_id": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"record_type": "payment",
"return_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"returns": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
}
],
"residual_of": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"residual": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
},
"split_from_record_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"split_role": "carve_out",
"split_from": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
}
},
"partially_matched": true,
"partially_matched_reconciliation_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"split": {
"matched_amount": 123,
"open_amount": 123,
"fully_matched": true,
"parts": 123,
"remainders": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"currency": "<string>",
"decimal_places": 123,
"direction": "credit",
"description": "<string>",
"date": "2023-12-25",
"external_id": "<string>",
"data_stream_key": "<string>",
"bank_account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"mask": "<string>",
"display_name": "<string>"
},
"matched": true
}
]
}
}
}Headers
Optional. Send the same key when retrying a write you are not sure landed: the first response is returned again (with Idempotent-Replayed: true) instead of writing twice. A key used for a different request is refused with 422; one whose first request is still running gets 409. A refused or failed request does not use up its key. Keys are per environment and kept for 7 days.
255Body
Response
Return recorded and reconciled