BillOSDocs
Console
Payments
POST/businesses/{bid}/payment-requests/{id}/refund

Requires the documents scope.

Gives the money of a paid link back to the card that paid it, then issues the document that corrects its receipt: a negative קבלה (400) for a קבלה, or a חשבונית זיכוי (330) and the negative קבלה that records the money for a חשבונית מס/קבלה (320). In full by default; amount for a part, with a reason. Never more than was paid less what already went back. The invoice the receipt had closed is owed again by the refunded amount. Idempotency-Key is required: the same key is the same refund, wherever it stands. If the document fails after the money moved, the refund is refunded with documentError, and the same call issues it without asking the card company again. If the card company gives no answer the call is 409 and the refund is unknown: look in the terminal, then repeat with resolve. payment_request.refunded is sent once the document is issued. A payment on a real terminal answers 422 not_supported today (see refundable); the sandbox's simulated terminal refunds.

Path parameters

bidstringrequired
Business id, from POST /businesses.
idstringrequired
Payment request id.

Headers

Idempotency-Keystring
Your own stable id for this call. A retry returns the same row with deduped: true instead of creating a duplicate. Interchangeable with externalRef in the body.

Body (optional)

amountinteger
A part of what was paid. Omit for everything not yet refunded. Integer agorot (₪1 = 100).
reasonstring
Printed on the correcting document. Required for a part.
resolvestring
Only for a refund that is unknown: what the owner found in his terminal. One of: refunded, not_refunded.
idempotencyKeystring
The same as the Idempotency-Key header.

Response

200: { "ok": true, … }

okbooleanrequired
paymentRequestPaymentRequestrequired
A request for a payment and its public link. When the card company confirms the payment, BillOS issues the receipt itself: a קבלה (400) for an invoice it pays, a חשבונית מס/קבלה (320) for a proforma or for its own lines (a 400 for an עוסק פטור), and the invoice it paid is closed.
statusstring
One of: refunded, withdrawn.
refundobject
This refund, as in paymentRequest.refunds.
documentobject
The correcting document, null while it is still owed.
ShowHide 3 child attributes
document.idstring
document.docTypeinteger
document.docNumberinteger
dedupedboolean

Errors: 400, 401, 403, 404, 409, 422, 429. Every failure answers { "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }: branch on reason, and read hint for what to change (https://docs.billos.co.il/errors.md).

curl -X POST "$BASE/businesses/$BID/payment-requests/$DOC_ID/refund" \
  -H "X-Api-Key: $KEY"
const res = await fetch(`${BASE}/businesses/${BID}/payment-requests/${DOC_ID}/refund`, {
  method: 'POST',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
import requests
res = requests.post(
    f"{BASE}/businesses/{BID}/payment-requests/{DOC_ID}/refund",
    headers={"X-Api-Key": KEY},
)
data = res.json()
$ch = curl_init("$BASE/businesses/$BID/payment-requests/$DOC_ID/refund");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["X-Api-Key: $KEY"],
]);
$data = json_decode(curl_exec($ch), true);
using System.Text.Json;

using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Post, $"{BASE}/businesses/{BID}/payment-requests/{DOC_ID}/refund");
req.Headers.Add("X-Api-Key", KEY);
using var res = await http.SendAsync(req);
var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync()).RootElement;
$BASE https://api.billos.co.il/v1$KEY a bk_test_… or bk_live_… key