curl --request POST \
--url https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"externalId": "pio-remit-88412-1",
"type": "PAYMENT",
"amount": "40.00",
"transactionDate": "2026-10-02",
"fillId": "3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34",
"payer": "Aetna",
"reference": "EFT 991204"
}
'import requests
url = "https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions"
payload = {
"externalId": "pio-remit-88412-1",
"type": "PAYMENT",
"amount": "40.00",
"transactionDate": "2026-10-02",
"fillId": "3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34",
"payer": "Aetna",
"reference": "EFT 991204"
}
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({
externalId: 'pio-remit-88412-1',
type: 'PAYMENT',
amount: '40.00',
transactionDate: '2026-10-02',
fillId: '3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34',
payer: 'Aetna',
reference: 'EFT 991204'
})
};
fetch('https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions', 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.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions",
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([
'externalId' => 'pio-remit-88412-1',
'type' => 'PAYMENT',
'amount' => '40.00',
'transactionDate' => '2026-10-02',
'fillId' => '3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34',
'payer' => 'Aetna',
'reference' => 'EFT 991204'
]),
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.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions"
payload := strings.NewReader("{\n \"externalId\": \"pio-remit-88412-1\",\n \"type\": \"PAYMENT\",\n \"amount\": \"40.00\",\n \"transactionDate\": \"2026-10-02\",\n \"fillId\": \"3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34\",\n \"payer\": \"Aetna\",\n \"reference\": \"EFT 991204\"\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.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"externalId\": \"pio-remit-88412-1\",\n \"type\": \"PAYMENT\",\n \"amount\": \"40.00\",\n \"transactionDate\": \"2026-10-02\",\n \"fillId\": \"3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34\",\n \"payer\": \"Aetna\",\n \"reference\": \"EFT 991204\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions")
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 \"externalId\": \"pio-remit-88412-1\",\n \"type\": \"PAYMENT\",\n \"amount\": \"40.00\",\n \"transactionDate\": \"2026-10-02\",\n \"fillId\": \"3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34\",\n \"payer\": \"Aetna\",\n \"reference\": \"EFT 991204\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medCaseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medReferralId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"externalId": "<string>",
"fillId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "PAYMENT",
"amount": "<string>",
"transactionDate": "2023-12-25",
"payer": "<string>",
"reference": "<string>",
"reversesTransactionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"createdVia": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z",
"replayed": true
}
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medCaseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medReferralId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"externalId": "<string>",
"fillId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "PAYMENT",
"amount": "<string>",
"transactionDate": "2023-12-25",
"payer": "<string>",
"reference": "<string>",
"reversesTransactionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"createdVia": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}Record a payment or adjustment
Records a payment, adjustment, write-off, refund or reversal. Sign convention: a positive amount reduces the balance, a negative amount increases it. The API stores the amount exactly as sent and does not check the sign against the type, so post the sign you mean. Examples: a payment received is PAYMENT “40.00”; a payer taking a payment back is PAYMENT “-40.00” or REVERSAL “-40.00”; a contractual write-down is ADJUSTMENT “15.00”; a write-off is WRITE_OFF with a positive amount; a refund the pharmacy sends out is REFUND “-10.00” (REFUND “10.00” would reduce the balance). To correct a posted transaction, post a REVERSAL with reversesTransactionId set; a REVERSAL counts under the same bucket (paid or adjustments) as the transaction it reverses. A REVERSAL with no reversesTransactionId, or whose target is not in the ledger, counts under paid. reversesTransactionId is accepted only when type is REVERSAL. Requires a provider-scoped key (cxpp_) for a pharmacy practice at STANDARD tier, on the practice’s own referral. Firm keys receive 403 wrong_scope; a non-pharmacy practice receives 403 pharmacy_only; another practice’s referral is 404. Writes are accepted while the referral is accepted, in treatment, treatment complete, closed or withdrawn — payments often arrive after the firm closes the case — and refused with 409 referral_not_writable while sent, under review, rejected or archived. Restricted-access practices receive 403 restricted_access. Idempotent on externalId: 201 on create, 200 with meta.replayed=true on a replay of the same payload, 409 external_id_conflict (error.details.existingId) for a different payload. A replay is compared with the record as it is now, so re-sending the original POST after any PATCH to that record returns 409 external_id_conflict; to recover, PATCH the record at error.details.existingId instead of re-posting. Referenced ids (prescriptionId, claimDocumentId, fillId, reversesTransactionId) are part of the compared payload, so a replay after the referenced record was deleted (its link cleared) also returns 409 external_id_conflict. Emits a pharmacy_transaction.created webhook.
curl --request POST \
--url https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"externalId": "pio-remit-88412-1",
"type": "PAYMENT",
"amount": "40.00",
"transactionDate": "2026-10-02",
"fillId": "3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34",
"payer": "Aetna",
"reference": "EFT 991204"
}
'import requests
url = "https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions"
payload = {
"externalId": "pio-remit-88412-1",
"type": "PAYMENT",
"amount": "40.00",
"transactionDate": "2026-10-02",
"fillId": "3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34",
"payer": "Aetna",
"reference": "EFT 991204"
}
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({
externalId: 'pio-remit-88412-1',
type: 'PAYMENT',
amount: '40.00',
transactionDate: '2026-10-02',
fillId: '3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34',
payer: 'Aetna',
reference: 'EFT 991204'
})
};
fetch('https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions', 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.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions",
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([
'externalId' => 'pio-remit-88412-1',
'type' => 'PAYMENT',
'amount' => '40.00',
'transactionDate' => '2026-10-02',
'fillId' => '3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34',
'payer' => 'Aetna',
'reference' => 'EFT 991204'
]),
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.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions"
payload := strings.NewReader("{\n \"externalId\": \"pio-remit-88412-1\",\n \"type\": \"PAYMENT\",\n \"amount\": \"40.00\",\n \"transactionDate\": \"2026-10-02\",\n \"fillId\": \"3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34\",\n \"payer\": \"Aetna\",\n \"reference\": \"EFT 991204\"\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.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"externalId\": \"pio-remit-88412-1\",\n \"type\": \"PAYMENT\",\n \"amount\": \"40.00\",\n \"transactionDate\": \"2026-10-02\",\n \"fillId\": \"3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34\",\n \"payer\": \"Aetna\",\n \"reference\": \"EFT 991204\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.casexchange.com/api/public/v1/med-cases/{caseId}/referrals/{referralId}/pharmacy/transactions")
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 \"externalId\": \"pio-remit-88412-1\",\n \"type\": \"PAYMENT\",\n \"amount\": \"40.00\",\n \"transactionDate\": \"2026-10-02\",\n \"fillId\": \"3f1c2b8e-6a0d-4c1e-9b7a-2d5e8f9a1c34\",\n \"payer\": \"Aetna\",\n \"reference\": \"EFT 991204\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medCaseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medReferralId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"externalId": "<string>",
"fillId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "PAYMENT",
"amount": "<string>",
"transactionDate": "2023-12-25",
"payer": "<string>",
"reference": "<string>",
"reversesTransactionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"createdVia": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z",
"replayed": true
}
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medCaseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"medReferralId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"externalId": "<string>",
"fillId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "PAYMENT",
"amount": "<string>",
"transactionDate": "2023-12-25",
"payer": "<string>",
"reference": "<string>",
"reversesTransactionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>",
"createdVia": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"requestId": "req_f2dbe1d3f6ad4a7bb5b4c9f2",
"timestamp": "2023-11-07T05:31:56Z"
}
}Authorizations
Public API key: cxp_<hex> (firm-scoped) or cxpp_<hex> (provider-scoped). Required on every request.
Path Parameters
Med case UUID: medCaseId in the referral.* webhook payload, or the id from GET /med-cases.
Med referral UUID: the referral of this case to your pharmacy practice. Find it with GET /med-cases/{id}/referrals, or take it from the referral.* webhook payload.
Body
ADJUSTMENT and WRITE_OFF count under adjustments; PAYMENT and REFUND count under paid; a REVERSAL counts under the bucket of the transaction it reverses. A REVERSAL with no reversesTransactionId, or whose target is not in the ledger, counts under paid. Sign convention: a positive amount reduces the balance, a negative amount increases it. The API stores the amount exactly as sent and does not check the sign against the type, so post the sign you mean. Examples: a payment received is PAYMENT "40.00"; a payer taking a payment back is PAYMENT "-40.00" or REVERSAL "-40.00"; a contractual write-down is ADJUSTMENT "15.00"; a write-off is WRITE_OFF with a positive amount; a refund the pharmacy sends out is REFUND "-10.00" (REFUND "10.00" would reduce the balance).
PAYMENT, ADJUSTMENT, WRITE_OFF, REFUND, REVERSAL Sign convention: a positive amount reduces the balance, a negative amount increases it. The API stores the amount exactly as sent and does not check the sign against the type, so post the sign you mean. Examples: a payment received is PAYMENT "40.00"; a payer taking a payment back is PAYMENT "-40.00" or REVERSAL "-40.00"; a contractual write-down is ADJUSTMENT "15.00"; a write-off is WRITE_OFF with a positive amount; a refund the pharmacy sends out is REFUND "-10.00" (REFUND "10.00" would reduce the balance).
| What happened | type | amount |
|---|---|---|
| Payment received | PAYMENT | "40.00" |
| Payer took a payment back | PAYMENT or REVERSAL | "-40.00" |
| Contractual write-down | ADJUSTMENT | "15.00" |
| Balance written off | WRITE_OFF | "25.00" |
| Refund the pharmacy sent out | REFUND | "-10.00" |
^-?\d{1,10}(\.\d{1,2})?$YYYY-MM-DD, a real calendar date.
Your system's id for this record (e.g. a PioneerRx event id). Unique per practice within each resource type (fills, transactions and snapshots each have their own namespace), across all of the practice's referrals and cases: it is not scoped to a referral, so do not reuse one id for two referrals. Re-sending the same externalId with the same payload returns the existing record (200, meta.replayed=true), even after the referral has moved to a status that no longer accepts new records; with a different payload, 409 external_id_conflict. A replay is compared with the record as it is now, so re-sending the original POST after any PATCH to that record returns 409 external_id_conflict; to recover, PATCH the record at error.details.existingId instead of re-posting. Referenced ids (prescriptionId, claimDocumentId, fillId, reversesTransactionId) are part of the compared payload, so a replay after the referenced record was deleted (its link cleared) also returns 409 external_id_conflict. Leading and trailing whitespace is trimmed. A POST without an externalId is accepted but never deduplicated, so always send one.
1 - 200A fill on this referral; otherwise 400 invalid_reference.
300200Allowed only when type is REVERSAL (otherwise 400 validation_error). Must be a transaction on this referral (otherwise 400 invalid_reference).
2000Response
Replay: the externalId was already used with the same payload. The existing transaction is returned, nothing is written, logged or emitted, and meta.replayed is true.

