Recipient group

[!info] Overview The RecipientGroup REST API manages recipient groups (supplier groups) in the pkbillms billing system. Recipient groups organize payment recipients into logical collections for easier management and categorization.

📋 Table of Contents


Quick Reference

[!abstract] API Configuration

  • Base URL: /api

  • Entity Name: pkbillmsRecipientGroup

  • Controller: RecipientGroupResource

  • Framework: Spring Boot + JHipster

  • Auth: Required (Spring Security)

  • Content-Type: application/json

Endpoints Summary

Method
Endpoint
Description
Status

POST

/api/recipient-groups

Create new recipient group

201

PUT

/api/recipient-groups/{id}

Full update

200

PATCH

/api/recipient-groups/{id}

Partial update

200

GET

/api/recipient-groups

Get all with criteria

200

GET

/api/recipient-groups/{id}

Get by ID

200

GET

/api/recipient-groups/count

Count by criteria

200

DELETE

/api/recipient-groups/{id}

Delete recipient group

204


Data Models

RecipientGroup DTO Structure

[!note] Data Transfer Object Represents a group of payment recipients with organizational metadata.

Field Specifications

Field
Type
Required
Max/Range
DB Column
Description

id

Long

❌ Auto

-

id

Primary key

name

String

64

name

Group name

active

Boolean

-

active

Active/Inactive status

more

String

-

more

Additional information

recipients

Set

-

rel_table

Associated recipients

Audit Fields (Inherited)

[!success] Auto-managed These fields are automatically populated by the system.

Field
Type
Description

createdBy

String

Creator username

createdDate

Instant

Creation timestamp

lastModifiedBy

String

Last modifier

lastModifiedDate

Instant

Last modification


API Endpoints

Create RecipientGroup

POST /api/recipient-groups

Creates a new recipient group entity.

Request

Headers:

Body:

[!warning] Validation Rules

  • id must be null (auto-generated)

  • name is required (max 64 characters)

  • active is required

  • recipients is required (must contain at least one recipient)

  • Recipients must exist in the database

Response

✅ Success (201 Created):

❌ Error (400 - ID exists):


Update RecipientGroup

PUT /api/recipient-groups/{id}

Completely updates an existing recipient group.

Path Parameters

  • id (Long) - RecipientGroup identifier

Request

Headers:

Body:

[!warning] Validation

  • Body id must not be null

  • Path id must match body id

  • RecipientGroup must exist in database

  • All recipients must exist in database

Response

✅ Success (200 OK):

❌ Errors:

Status
Detail
Message

400

Invalid id

error.idnull

400

Invalid ID

error.idinvalid

400

Entity not found

error.idnotfound


Partial Update

PATCH /api/recipient-groups/{id}

Updates only specified fields. Null fields are ignored.

Path Parameters

  • id (Long) - RecipientGroup identifier

Request

Headers:

Body (Example - deactivate group):

Body (Example - update name and additional info):

[!tip] Partial Update Behavior

  • Only non-null fields are updated

  • Other fields remain unchanged

  • Perfect for status toggles or single field updates

  • Recipients can be updated without changing other fields

Response

✅ Success (200 OK):


Get All RecipientGroups

GET /api/recipient-groups

Retrieves paginated list with filtering criteria.

Query Parameters

Pagination:

  • page - Page number (0-indexed, default: 0)

  • size - Items per page (default: 20)

  • sort - Sort criteria (e.g., name,asc)

  • unPaged - Boolean for unpaged results

Filters (RecipientGroupCriteria):

  • id.equals, id.in

  • name.contains, name.equals

  • active.equals - Filter by status

  • recipientId.equals, recipientId.in - Filter by recipient

Example Requests

Response

✅ Success (200 OK):


Get Single RecipientGroup

GET /api/recipient-groups/{id}

Retrieves a single recipient group by ID with all relationships.

Path Parameters

  • id (Long) - RecipientGroup identifier

Request

Response

✅ Success (200 OK):

❌ Error (404 Not Found):


Count RecipientGroups

GET /api/recipient-groups/count

Returns count of recipient groups matching criteria.

Query Parameters

Same filtering parameters as [[#Get All RecipientGroups]]

Example Requests

Response

✅ Success (200 OK):


Delete RecipientGroup

DELETE /api/recipient-groups/{id}

Deletes a recipient group from the database.

Path Parameters

  • id (Long) - RecipientGroup identifier

Request

Response

✅ Success (204 No Content):

[!warning] Delete Behavior

  • Removes the recipient group entity

  • Removes many-to-many relationships with recipients

  • Does not delete the recipients themselves

  • Recipients remain available for other groups


Examples

Example 1: Create Group for Utility Providers

  • Setup Utility Providers Group Request:

Example 2: Update Group with New Recipients

  • Add Recipients to Existing Group Request:

Example 3: Deactivate Group

  • Temporarily Deactivate Group Request:

Response:

Example 4: Get Active Groups Only

  • Filter Active Groups Request:

Response:

Example 5: Search Groups by Name

  • Find Groups Containing "Mobile" Request:


Error Handling

Error Response Format

[!failure] RFC 7807 Problem Details All errors follow standardized format.

HTTP Status Codes

Code
Type
Description
Common Causes

400

Bad Request

Invalid request

Validation failure, ID mismatch, null required fields

401

Unauthorized

Auth required

Missing/invalid token

403

Forbidden

Access denied

Insufficient permissions

404

Not Found

Resource missing

Invalid ID, deleted entity

409

Conflict

Resource conflict

Duplicate name (if enforced)

500

Server Error

Internal error

Database error, exception

Validation Error Example

[!bug] Field Validation Errors


Validation Rules

Required Fields

[!check] Mandatory Fields

  • name - Group name

  • active - Active status

  • recipients - At least one recipient

Field Constraints

Field
Rules
Error Messages

id

Null for POST

"A new recipientGroup cannot already have an ID"

id

Not null for PUT/PATCH

"Invalid id"

name

@NotNull, @Size(max=64)

"must not be null", "size must be between 0 and 64"

active

@NotNull

"must not be null"

more

Optional

No size limit

recipients

@NotNull, not empty

"must not be null", "must not be empty"

Business Rules

[!info] Business Validation

  • name should be descriptive and unique (recommended)

  • At least one recipient must be associated with the group

  • Recipients must exist in the database before association

  • Inactive groups may still maintain recipient associations

  • Many-to-many relationship allows recipients to belong to multiple groups


Security & Authentication

Authorization

[!abstract] Access Control

The RecipientGroup API requires proper authentication and authorization:

Required Permissions:

  • CREATE - Create new recipient groups

  • UPDATE - Modify existing groups

  • READ - View groups and their details

  • DELETE - Remove groups

Many-to-Many Relationship

[!info] Recipient Association

RecipientGroups use a many-to-many relationship with Recipients:

Join Table: rel_recipient_group__recipient

Column
Type
Description

recipient_group_id

Long

Foreign key to recipient_group

recipient_id

Long

Foreign key to recipient

Characteristics:

  • One recipient can belong to multiple groups

  • One group can contain multiple recipients

  • Deleting a group removes associations but not recipients

  • Deleting a recipient removes it from all groups

Active Status Management

[!tip] Group Lifecycle

Groups can be activated or deactivated:

Best Practices:

Additional Information Field

[!note] Flexible Metadata

The more field provides flexibility for additional data:

Use Cases:

  • Detailed group descriptions

  • Business rules or criteria

  • Contact information

  • Internal notes

  • JSON-formatted metadata (if needed)

Example:


🔧 cURL Command Reference

Create

Update

Partial Update

Get All

Get Single

Count

Delete


📝 Notes

[!success] Key Features

  • Simple CRUD operations for group management

  • Flexible many-to-many recipient associations

  • Active/inactive status for lifecycle management

  • Pagination and filtering support

  • Full audit trail (created/modified by/date)

[!tip] Best Practices

  • Use descriptive group names

  • Leverage the more field for additional context

  • Deactivate instead of delete for data retention

  • Regularly review and update group memberships

  • Use pagination for large result sets

[!warning] Important Considerations

  • Deleting a group does not delete associated recipients

  • Recipients can belong to multiple groups simultaneously

  • All recipient IDs must exist before group creation/update

  • Group names should be unique for clarity (though not enforced by DB)

Last updated