Beneficiaries API
Create, manage, and reuse beneficiary information for recurring payouts
Beneficiaries API
Manage saved beneficiaries for streamlined payout creation. Saving beneficiary information allows you to reuse it for recurring payments without re-entering details each time.
Endpoints Overview
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/beneficiaries | List all beneficiaries |
| POST | /api/v1/beneficiaries | Create a new beneficiary |
| GET | /api/v1/beneficiaries/:id | Get beneficiary details |
| DELETE | /api/v1/beneficiaries/:id | Delete a beneficiary |
List Beneficiaries
Retrieve a paginated list of saved beneficiaries.
Endpoint
GET /api/v1/beneficiariesAuthentication: API Key + Secret required
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | number | 1 | Page number |
limit | number | 20 | Items per page (max: 100) |
search | string | - | Search by email or name |
sort_by | string | created_at | Sort field |
sort_order | string | DESC | Sort direction (ASC or DESC) |
Response
Status Code: 200 OK
Response Headers:
X-Page: 1
X-Per-Page: 20
X-Total-Count: 45
X-Total-Pages: 3Response Body:
[
{
"id": "ben_abc123xyz",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"country": "US",
"phone": "+1234567890",
"metadata": {
"employee_id": "EMP001",
"department": "Engineering"
},
"total_payouts": 5,
"total_amount": 500.00,
"last_payout_at": "2024-01-15T10:30:00Z",
"created_at": "2024-01-01T00:00:00Z"
}
]Pagination Headers
| Header | Description |
|---|---|
X-Page | Current page number |
X-Per-Page | Items per page |
X-Total-Count | Total number of beneficiaries |
X-Total-Pages | Total number of pages |
Example
curl -X GET "{{host}}/api/v1/beneficiaries?page=1&limit=20" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"<?php
function listBeneficiaries($apiKey, $apiSecret, $page = 1, $limit = 20) {
$url = "{{host}}/api/v1/beneficiaries?page=$page&limit=$limit";
$options = [
'http' => [
'header' => "X-API-Key: $apiKey\r\nX-API-Secret: $apiSecret",
'method' => 'GET'
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
// Get pagination from response headers
$headers = $http_response_header;
$pagination = [];
foreach ($headers as $header) {
if (strpos($header, 'X-Total-Count:') === 0) {
$pagination['total'] = (int) trim(substr($header, 14));
}
if (strpos($header, 'X-Total-Pages:') === 0) {
$pagination['total_pages'] = (int) trim(substr($header, 14));
}
}
return [
'beneficiaries' => json_decode($result, true),
'pagination' => $pagination
];
}
// Usage
$response = listBeneficiaries('sk_live_abc123def456', 'your-secret-here');
foreach ($response['beneficiaries'] as $beneficiary) {
echo $beneficiary['first_name'] . ' ' . $beneficiary['last_name'] . "\n";
echo " Email: " . $beneficiary['email'] . "\n";
echo " Total Payouts: " . $beneficiary['total_payouts'] . "\n";
}
?>Create Beneficiary
Save a new beneficiary for future payouts.
Endpoint
POST /api/v1/beneficiariesAuthentication: API Key + Secret required
Request Body
{
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"country": "US",
"phone": "+1234567890",
"metadata": {
"employee_id": "EMP001",
"department": "Engineering"
}
}Field Descriptions
| Field | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Beneficiary email address |
first_name | string | Yes | Beneficiary first name |
last_name | string | Yes | Beneficiary last name |
country | string | No | Country code (ISO 3166-1 alpha-2) |
phone | string | No | Phone number with country code |
metadata | object | No | Custom metadata for your reference |
Response
Status Code: 201 Created
{
"id": "ben_abc123xyz",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"country": "US",
"phone": "+1234567890",
"metadata": {
"employee_id": "EMP001",
"department": "Engineering"
},
"total_payouts": 0,
"total_amount": 0,
"last_payout_at": null,
"created_at": "2024-01-15T10:30:00Z"
}Error Responses
400 Bad Request - Validation Error
{
"error": "ValidationException",
"message": "email is required"
}400 Bad Request - Invalid Email
{
"error": "ValidationException",
"message": "Invalid email format"
}Example
curl -X POST "{{host}}/api/v1/beneficiaries" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here" \
-H "Content-Type: application/json" \
-d '{
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"country": "US",
"metadata": {
"employee_id": "EMP001"
}
}'<?php
function createBeneficiary($accessToken, $data) {
$url = '{{host}}/api/v1/beneficiaries';
$options = [
'http' => [
'header' => [
"Content-Type: application/json",
"X-API-Key: $apiKey",
"X-API-Secret: $apiSecret"
],
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return json_decode($result, true);
}
// Usage
$beneficiary = createBeneficiary('your_access_token', [
'email' => 'john.doe@example.com',
'first_name' => 'John',
'last_name' => 'Doe',
'country' => 'US',
'metadata' => [
'employee_id' => 'EMP001'
]
]);
echo "Created beneficiary: " . $beneficiary['id'] . "\n";
?>Get Beneficiary
Retrieve details of a specific beneficiary.
Endpoint
GET /api/v1/beneficiaries/:idAuthentication: API Key + Secret required
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Beneficiary public ID |
Response
Status Code: 200 OK
{
"id": "ben_abc123xyz",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"country": "US",
"phone": "+1234567890",
"metadata": {
"employee_id": "EMP001",
"department": "Engineering"
},
"total_payouts": 5,
"total_amount": 500.00,
"last_payout_at": "2024-01-15T10:30:00Z",
"created_at": "2024-01-01T00:00:00Z"
}Error Responses
404 Not Found
{
"error": "NotFound",
"message": "Beneficiary not found"
}Example
curl -X GET "{{host}}/api/v1/beneficiaries/ben_abc123xyz" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"Delete Beneficiary
Remove a saved beneficiary. This does not affect historical payout records.
Endpoint
DELETE /api/v1/beneficiaries/:idAuthentication: API Key + Secret required
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Beneficiary public ID |
Response
Status Code: 204 No Content
No response body on success.
Error Responses
404 Not Found
{
"error": "NotFound",
"message": "Beneficiary not found"
}Example
curl -X DELETE "{{host}}/api/v1/beneficiaries/ben_abc123xyz" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"Best Practices
- Store beneficiary IDs - Save the returned
idto reference beneficiaries in future payouts - Handle duplicates - Check for existing beneficiaries before creating new ones
- Use metadata - Store custom reference data (employee IDs, department codes) in the metadata field
Related Endpoints
- Create Payout - Use beneficiary IDs when creating payouts