Create a refund
curl --request POST \
--url https://api.assembly.com/v1/refunds \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"invoiceId": "inv_123"
}
'import requests
url = "https://api.assembly.com/v1/refunds"
payload = { "invoiceId": "inv_123" }
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({invoiceId: 'inv_123'})
};
fetch('https://api.assembly.com/v1/refunds', 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.assembly.com/v1/refunds",
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([
'invoiceId' => 'inv_123'
]),
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.assembly.com/v1/refunds"
payload := strings.NewReader("{\n \"invoiceId\": \"inv_123\"\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.assembly.com/v1/refunds")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"invoiceId\": \"inv_123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.assembly.com/v1/refunds")
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 \"invoiceId\": \"inv_123\"\n}"
response = http.request(request)
puts response.read_body{
"amount": 5000,
"completedAt": "2024-02-20T14:05:00Z",
"createdAt": "<string>",
"creatorId": "<string>",
"data": "<string>",
"failureReason": "insufficient_funds",
"id": "<string>",
"identityId": "<string>",
"invoiceId": "550e8400-e29b-41d4-a716-446655440000",
"object": "<string>",
"previousAttributes": {},
"receiptKey": "receipts/re_1a2b3c.pdf",
"ref": "<string>",
"status": "succeeded",
"updatedAt": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}Refunds
Create a refund
Issues a refund against a paid invoice. The refund may be queued for review depending on the portal’s billing configuration.
POST
/
v1
/
refunds
Create a refund
curl --request POST \
--url https://api.assembly.com/v1/refunds \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"invoiceId": "inv_123"
}
'import requests
url = "https://api.assembly.com/v1/refunds"
payload = { "invoiceId": "inv_123" }
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({invoiceId: 'inv_123'})
};
fetch('https://api.assembly.com/v1/refunds', 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.assembly.com/v1/refunds",
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([
'invoiceId' => 'inv_123'
]),
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.assembly.com/v1/refunds"
payload := strings.NewReader("{\n \"invoiceId\": \"inv_123\"\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.assembly.com/v1/refunds")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"invoiceId\": \"inv_123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.assembly.com/v1/refunds")
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 \"invoiceId\": \"inv_123\"\n}"
response = http.request(request)
puts response.read_body{
"amount": 5000,
"completedAt": "2024-02-20T14:05:00Z",
"createdAt": "<string>",
"creatorId": "<string>",
"data": "<string>",
"failureReason": "insufficient_funds",
"id": "<string>",
"identityId": "<string>",
"invoiceId": "550e8400-e29b-41d4-a716-446655440000",
"object": "<string>",
"previousAttributes": {},
"receiptKey": "receipts/re_1a2b3c.pdf",
"ref": "<string>",
"status": "succeeded",
"updatedAt": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}{
"code": "<string>",
"data": "<unknown>",
"message": "<string>"
}Authorizations
Body
application/json
Refund to create
Example:
"inv_123"
Response
OK
Amount is the refunded amount in the smallest currency unit (e.g. cents).
Example:
5000
CompletedAt is the RFC 3339 timestamp at which the refund succeeded; absent until then.
Example:
"2024-02-20T14:05:00Z"
FailureReason is the reason the refund failed, populated only for failed refunds.
Example:
"insufficient_funds"
InvoiceID is the ID of the invoice the refund was issued against.
Example:
"550e8400-e29b-41d4-a716-446655440000"
ReceiptKey is the storage key of the refund receipt, when one is available.
Example:
"receipts/re_1a2b3c.pdf"
Status is the current state of the refund as it progresses through processing.
Available options:
pending, succeeded, failed Example:
"succeeded"