> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.joincandidhealth.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.joincandidhealth.com/_mcp/server.

# Create patient payment

POST https://api.joincandidhealth.com/api/patient-payments/v4
Content-Type: application/json

Creates a new patient payment record and returns the newly created PatientPayment object.
The allocations can describe whether the payment is being applied toward a specific service line,
claim, or billing provider.

Reference: https://docs.joincandidhealth.com/api-reference/patient-collections/patient-payments/v-4/create

## Authentication

- OAuth2 — send the obtained token as `Authorization: Bearer <token>`

## Servers

- `https://api.joincandidhealth.com` (Production, default)
- `https://api-staging.joincandidhealth.com` (Staging)
- `https://sandbox-api.joincandidhealth.com` (CandidSandbox)
- `https://staging-api.joincandidhealth.com` (CandidStaging)
- `http://localhost:5050` (Local)

## Request

### Body (application/json)

This endpoint expects an object.

- `amount_cents` (integer, required)
- `patient_external_id` (string, required)
- `allocations` (list of AllocationCreate, required)
- `payment_timestamp` (datetime, optional)
- `payment_note` (string, optional)
- `invoice` (UUID, optional)
- `payment_method_detail` (PaymentMethodDetailCreate, optional)
- `payment_source` (enum, optional) — Allowed payment sources when creating a patient payment via the API.
  - Allowed values: `MANUAL_ENTRY`, `PHREESIA`, `SHERPA_HEALTH`, `LOCKBOX`
- `source_internal_id` (string, optional)
- `allocation_restrictions` (list of AllocationRestrictionCreate, optional) — Optional restrictions constraining which claims this payment's credit can be auto-allocated to (e.g. billing provider NPI). Restriction (type, value) pairs must be unique. When omitted, the payment is unrestricted.

## Response

### 200

- `patient_payment_id` (UUID, required)
- `organization_id` (UUID, required)
- `payment_source` (enum, required)
  - Allowed values: `MANUAL_ENTRY`, `CHARGEBEE`, `SQUARE`, `STRIPE`, `ELATION`, `CEDAR`, `HEALTHIE`, `REALLOCATION`, `PHREESIA`, `INSTAMED`, `SHERPA_HEALTH`, `LOCKBOX`
- `amount_cents` (integer, required)
- `patient_external_id` (string, required)
- `allocations` (list of Allocation, required)
- `source_internal_id` (string, optional)
- `payment_timestamp` (datetime, optional)
- `payment_note` (string, optional)
- `invoice` (UUID, optional)
- `payment_method_detail` (PaymentMethodDetail, optional)

## Errors

### 404 Entity Not Found Error

- `errorName` ("EntityNotFoundError", required)
- `content` (EntityNotFoundErrorMessage, required)

### 403 Unauthorized Error

- `errorName` ("UnauthorizedError", required)
- `content` (UnauthorizedErrorMessage, required)

### 422 Unprocessable Entity Error

- `errorName` ("UnprocessableEntityError", required)
- `content` (UnprocessableEntityErrorMessage, required)

## Types

### AllocationCreate

Allocations are portions of payments that are applied to specific resources, known as targets. Each allocation has and amount, defined in cents, and a target.

- `amount_cents` (integer, required)
- `target` (AllocationTargetCreate, required) — Allocation targets describe whether the portion of a payment is being applied toward a specific service line, claim, billing provider, or is unallocated.
- `earmark` (AllocationEarmarkType, optional) — If enabled for your organization, optional earmarking configuration for patient prepayments. When provided on unattributed allocations, holds the payment for future auto-allocation to matching encounters.

### PaymentMethodDetailCreate

- `payment_method` (PaymentMethodCreate, required)
- `collected_at_address` (StreetAddressShortZip, optional)
- `organization_service_facility_id` (UUID, optional)
- `provider_info` (PaymentMethodProviderInfo, optional)

### AllocationRestrictionCreate

Constrains which claims a payment's credit can be auto-allocated to. Restrictions of the same restriction_type are OR'd together (any value may match); different restriction_types are AND'd (every type present must match). A payment with no restrictions can be allocated to any claim.

- `restriction_type` (enum, required) — The dimension along which a payment's auto-allocation can be restricted.
  - Allowed values: `billing_provider_npi`, `service_facility_id`
- `restriction_value` (string, required) — For billing_provider_npi, the NPI. For service_facility_id, the organization service facility ID.

### Allocation

- `amount_cents` (integer, required)
- `target` (AllocationTarget, required) — Allocation targets describe whether the portion of a payment is being applied toward a specific service line, claim, billing provider, or is unallocated.
- `allocation_id` (UUID, optional)
- `earmark` (BalanceEarmark, optional) — The active earmark created by this allocation, if any. Only present when this allocation created an earmark for future auto-allocation and the earmark has not been deleted.
- `allocated_on` (datetime, optional)

### PaymentMethodDetail

- `payment_method` (PaymentMethod, required)
- `collected_at_address` (StreetAddressShortZip, optional)
- `provider_info` (PaymentMethodProviderInfo, optional)

### EntityNotFoundErrorMessage

- `id` (string, required)

### UnauthorizedErrorMessage

- `message` (string, optional)

### UnprocessableEntityErrorMessage

- `message` (string, optional)

### AllocationTargetCreate

Allocation targets describe whether the portion of a payment is being applied toward a specific service line, claim, billing provider, or is unallocated.

- `type`: `service_line_by_id`
  - `value` (UUID, required)
- `type`: `claim_by_id`
  - `value` (UUID, required)
- `type`: `claim_by_encounter_external_id`
  - `value` (string, required)
- `type`: `billing_provider_by_id`
  - `value` (UUID, required)
- `type`: `appointment_by_id_and_patient_external_id`
  - `appointment_id` (string, required)
  - `patient_external_id` (string, required)
- `type`: `unattributed`

### AllocationEarmarkType

If enabled for your organization, defines how a patient prepayment allocation should be earmarked for future auto-allocation. Earmarks hold the allocation until a matching encounter is created, then attempt to allocate to that encounter. Only applicable for unattributed allocations.

- `type`: `date_of_service`
  - `value` (string, required) — ISO 8601 date; formatted YYYY-MM-DD (i.e. 2012-02-01)
- `type`: `external_encounter_id`
  - `value` (string, required)

### PaymentMethodCreate

- `type`: `cash`
- `type`: `check`
  - `check_number` (string, required)
- `type`: `card`
  - `authorization_number` (string, optional)
- `type`: `money_order`
  - `money_order_serial_number` (string, required)

### StreetAddressShortZip

- `address1` (string, required)
- `city` (string, required)
- `state` (enum, required)
  - Allowed values: `AA`, `AE`, `AP`, `AL`, `AK`, `AS`, `AZ`, `AR`, `CA`, `CO`, `CT`, `DC`, `DE`, `FL`, `FM`, `GA`, `GU`, `HI`, `ID`, `IL`, `IN`, `IA`, `KS`, `KY`, `LA`, `ME`, `MD`, `MA`, `MH`, `MI`, `MN`, `MP`, `MS`, `MO`, `MT`, `NE`, `NV`, `NH`, `NJ`, `NM`, `NY`, `NC`, `ND`, `OH`, `OK`, `OR`, `PA`, `PR`, `PW`, `RI`, `SC`, `SD`, `TN`, `TX`, `UT`, `VI`, `VT`, `VA`, `WA`, `WV`, `WI`, `WY`, `FC`
- `zip_code` (string, required) — 5-digit zip code
- `address2` (string, optional)
- `zip_plus_four_code` (string, optional) — 4-digit zip add-on code https://en.wikipedia.org/wiki/ZIP_Code#ZIP+4

### PaymentMethodProviderInfo

- `npi` (string, optional)
- `first_name` (string, optional)
- `last_name` (string, optional)

### AllocationTarget

Allocation targets describe whether the portion of a payment is being applied toward a specific service line, claim, billing provider, or is unallocated.

- `type`: `service_line`
  - `claim_id` (UUID, required)
  - `encounter_id` (UUID, required)
  - `service_line_id` (UUID, required)
- `type`: `claim`
  - `claim_id` (UUID, required)
  - `encounter_id` (UUID, required)
- `type`: `billing_provider_id`
  - `billing_provider_id` (UUID, required)
- `type`: `appointment`
  - `appointment_id` (string, required)
  - `patient_external_id` (string, required)
- `type`: `unattributed`

### BalanceEarmark

Represents an active balance earmarking record that holds allocated funds for future auto-allocation. Earmarks are created when funds are allocated but should be held for a specific encounter or date of service. Only active (non-deleted) earmarks are returned.

- `id` (UUID, required)
- `target` (AllocationEarmarkType, required) — The target for this earmark (date of service or external encounter ID)
- `amount_earmarked_cents` (integer, optional) — The amount earmarked in cents for future allocation
- `created_by_allocation_id` (UUID, optional) — The ID of the allocation that created this earmark

### PaymentMethod

- `type`: `cash`
- `type`: `check`
  - `check_number` (string, required)
- `type`: `card`
  - `authorization_number` (string, optional)
- `type`: `money_order`
  - `money_order_serial_number` (string, required)

## Examples

**Request**

```json
{
  "amount_cents": 1,
  "patient_external_id": "patient_external_id",
  "allocations": [
    {
      "amount_cents": 1,
      "target": {
        "type": "service_line_by_id",
        "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      }
    },
    {
      "amount_cents": 1,
      "target": {
        "type": "service_line_by_id",
        "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      }
    }
  ]
}
```

**Response**

```json
{
  "patient_payment_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  "organization_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  "payment_source": "MANUAL_ENTRY",
  "amount_cents": 1,
  "patient_external_id": "patient_external_id",
  "allocations": [
    {
      "amount_cents": 1,
      "target": {
        "type": "service_line",
        "claim_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
        "encounter_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
        "service_line_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      },
      "allocation_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
      "earmark": {
        "id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
        "target": {
          "type": "date_of_service",
          "value": "target"
        },
        "amount_earmarked_cents": 1,
        "created_by_allocation_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      },
      "allocated_on": "2024-01-15T09:30:00Z"
    },
    {
      "amount_cents": 1,
      "target": {
        "type": "service_line",
        "claim_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
        "encounter_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
        "service_line_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      },
      "allocation_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
      "earmark": {
        "id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
        "target": {
          "type": "date_of_service",
          "value": "target"
        },
        "amount_earmarked_cents": 1,
        "created_by_allocation_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      },
      "allocated_on": "2024-01-15T09:30:00Z"
    }
  ],
  "source_internal_id": "source_internal_id",
  "payment_timestamp": "2024-01-15T09:30:00Z",
  "payment_note": "payment_note",
  "invoice": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  "payment_method_detail": {
    "payment_method": {
      "type": "cash"
    },
    "collected_at_address": {
      "address1": "address1",
      "city": "city",
      "state": "AA",
      "zip_code": "zip_code",
      "address2": "address2",
      "zip_plus_four_code": "zip_plus_four_code"
    },
    "provider_info": {
      "npi": "npi",
      "first_name": "first_name",
      "last_name": "last_name"
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.joincandidhealth.com/api/patient-payments/v4"

payload = {
    "amount_cents": 1,
    "patient_external_id": "patient_external_id",
    "allocations": [
        {
            "amount_cents": 1,
            "target": {
                "type": "service_line_by_id",
                "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
            }
        },
        {
            "amount_cents": 1,
            "target": {
                "type": "service_line_by_id",
                "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
            }
        }
    ]
}
headers = {
    "Authorization": "<token>.",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.joincandidhealth.com/api/patient-payments/v4';
const options = {
  method: 'POST',
  headers: {Authorization: '<token>.', 'Content-Type': 'application/json'},
  body: '{"amount_cents":1,"patient_external_id":"patient_external_id","allocations":[{"amount_cents":1,"target":{"type":"service_line_by_id","value":"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"}},{"amount_cents":1,"target":{"type":"service_line_by_id","value":"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"}}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.joincandidhealth.com/api/patient-payments/v4"

	payload := strings.NewReader("{\n  \"amount_cents\": 1,\n  \"patient_external_id\": \"patient_external_id\",\n  \"allocations\": [\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    },\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    }\n  ]\n}")

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

	req.Header.Add("Authorization", "<token>.")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.joincandidhealth.com/api/patient-payments/v4")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<token>.'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount_cents\": 1,\n  \"patient_external_id\": \"patient_external_id\",\n  \"allocations\": [\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    },\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.joincandidhealth.com/api/patient-payments/v4")
  .header("Authorization", "<token>.")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount_cents\": 1,\n  \"patient_external_id\": \"patient_external_id\",\n  \"allocations\": [\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    },\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.joincandidhealth.com/api/patient-payments/v4', [
  'body' => '{
  "amount_cents": 1,
  "patient_external_id": "patient_external_id",
  "allocations": [
    {
      "amount_cents": 1,
      "target": {
        "type": "service_line_by_id",
        "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      }
    },
    {
      "amount_cents": 1,
      "target": {
        "type": "service_line_by_id",
        "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      }
    }
  ]
}',
  'headers' => [
    'Authorization' => '<token>.',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.joincandidhealth.com/api/patient-payments/v4");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<token>.");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount_cents\": 1,\n  \"patient_external_id\": \"patient_external_id\",\n  \"allocations\": [\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    },\n    {\n      \"amount_cents\": 1,\n      \"target\": {\n        \"type\": \"service_line_by_id\",\n        \"value\": \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\"\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<token>.",
  "Content-Type": "application/json"
]
let parameters = [
  "amount_cents": 1,
  "patient_external_id": "patient_external_id",
  "allocations": [
    [
      "amount_cents": 1,
      "target": [
        "type": "service_line_by_id",
        "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      ]
    ],
    [
      "amount_cents": 1,
      "target": [
        "type": "service_line_by_id",
        "value": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
      ]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joincandidhealth.com/api/patient-payments/v4")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```