Managing Externally Processed Gifts
The Klevr Gift Import API (klevr_ExternalGiftImport) is a Dynamics 365 Customer Engagement (CE) Custom API that allows external systems to create and...
Klevr Gift Import API
Overview
The Klevr Gift Import API (klevr_ExternalGiftImport) is a Dynamics 365 Customer Engagement (CE) Custom API that allows external systems to create and process Gift Import records within Klevr Fundraising.
The API is designed for integrations where donations, gifts, payments, or recurring giving information are captured by a third-party platform and subsequently imported into Klevr Fundraising for processing and conversion into Gifts.
When a request is received, the API:
- Creates a Gift Import (
klevr_giftimport) record. - Adds the record to a Gift Batch of type Externally Processed.
- Automatically creates the batch and batch type if they do not already exist.
- Attempts to automatically convert the Gift Import into a Gift.
- Uses existing Gift Import matching and lookup resolution functionality to populate required lookup fields.
- Creates associated Payment Method, Payment, and Payment Schedule records (when configured for externally processed imports).
- If mandatory information cannot be resolved, leaves the import record for manual completion and conversion.
This approach allows external systems to submit minimal data while leveraging Klevr's existing gift import and conversion framework.
Custom API Details
Custom API Name
klevr_ExternalGiftImport
Parameters
klevr_ExternalGiftImport_payload
Required
A JSON string containing the gift data to import.
The payload fields must match the names specified in the configured import mapping.
Example:
{
"DonorEmail": "john.smith@example.com",
"Amount": 100.00,
"BookDate": "2026-08-01",
"GiftType": "Donation"
}
klevr_ExternalGiftImport_mapping
Optional
Specifies the mapping web resource to use.
If not supplied, the API uses:
klevr_ExternalGiftImportMap.json
This allows different integrations to use different mappings without requiring code changes.
Import Mapping Configuration
The Gift Import API uses a JSON mapping file that controls how incoming payload values are applied to the Gift Import record.
A mapping entry has the following structure:
[
{
"Description": "Description of the field",
"To": "Schema name of target klevr_giftimport field",
"Type": "Field data type",
"From": "Field name expected in payload",
"LookupTableSchemaName": "Target lookup table",
"HardCodedValue": "Optional fixed value"
}
]
Mapping Properties
| Property | Description |
|-----------|-------------|
| Description | Informational text used as documentation for integrators and user guidance. |
| To | Schema name of the destination field on klevr_giftimport. |
| Type | Data type of the destination field. |
| From | Payload property name to read from. |
| LookupTableSchemaName | Required for lookup and entity reference fields. Identifies the target table. |
| HardCodedValue | Optional fixed value that overrides any payload value. |
Supported Field Types
string
decimal
money
int
integer
optionset
bool
boolean
datetime
date
guid
lookup
entityreference
Hard-Coded Values
Hard-coded values allow an integration to automatically populate specific fields regardless of what is provided in the payload.
Example:
{
"To": "klevr_sourcecode",
"Type": "optionset",
"HardCodedValue": "344590001"
}
Common use cases include:
- Setting the Gift Source.
- Setting the Import Source.
- Tracking which external platform submitted the gift.
- Configuring payment processor values.
- Applying integration-specific defaults.
Mapping Polymorphic Lookup (Polylookup) Fields
Some fields on the Gift Import table can reference more than one table. These are often referred to as polymorphic lookups or polylookups.
Examples include:
- Attributed To
- Donor
- Customer
- Related Party fields
Because the mapping engine requires a specific target entity for each Entity Reference mapping, a single mapping entry cannot represent multiple entity types.
Instead, create a separate mapping entry for each supported target table.
Example: Attributed To
The klevr_attributedtoid field can reference:
- Account
- Contact
- Collective
To support all three options, create three mapping entries:
[
{
"Description": "Attributed To Account",
"To": "klevr_attributedtoid",
"Type": "EntityReference",
"From": "klevr_AttributedToId_Account",
"LookupTableSchemaName": "account",
"HardCodedValue": ""
},
{
"Description": "Attributed To Contact",
"To": "klevr_attributedtoid",
"Type": "EntityReference",
"From": "klevr_AttributedToId_Contact",
"LookupTableSchemaName": "contact",
"HardCodedValue": ""
},
{
"Description": "Attributed To Collective",
"To": "klevr_attributedtoid",
"Type": "EntityReference",
"From": "klevr_AttributedToId_Collective",
"LookupTableSchemaName": "klevr_collective",
"HardCodedValue": ""
}
]
How It Works
The API evaluates each mapping independently.
| Payload Field | Target Entity |
|---------------|---------------|
| klevr_AttributedToId_Account | Account |
| klevr_AttributedToId_Contact | Contact |
| klevr_AttributedToId_Collective | Collective |
When a GUID is supplied for one of these payload fields, an Entity Reference is created using the table specified in LookupTableSchemaName.
Example Payloads
Attributed To Contact
{
"klevr_AttributedToId_Contact": "d8d1c138-d8cc-ee11-9079-000d3ad91f6a"
}
Attributed To Account
{
"klevr_AttributedToId_Account": "3bb1f55b-45cf-ee11-9079-000d3ad91f6a"
}
Attributed To Collective
{
"klevr_AttributedToId_Collective": "5269cce1-55cf-ee11-9079-000d3ad91f6a"
}
Best Practices for Polylookups
- Create a separate mapping entry for each supported entity type.
- Use meaningful payload property names that clearly indicate the target entity.
- Only provide one polylookup value for a given destination field.
- Validate that supplied GUIDs exist in the corresponding Dataverse table.
- Include all supported entity types in the mapping file to future-proof the integration.
Portal Integration
A common deployment pattern is to publish the Custom API through Klevr Portal.
In this approach:
-
The portal endpoint accepts only the payload.
-
The portal configuration supplies a fixed mapping name.
-
The portal calls Dynamics using:
-
The payload supplied by the external system.
-
The configured mapping file.
-
This architecture looks like:
Third Party System
|
v
Klevr Portal
|
|-- Injects Mapping Name
v
klevr_ExternalGiftImport
|
v
Dynamics 365 CE
Benefits include:
- Simpler third-party integration.
- Centralised mapping management.
- Ability to secure the endpoint using API keys.
- Support for multiple integrations using different mappings.
- Reduced risk of third parties modifying mappings.
Gift Batch Processing
Batch Type Resolution
The API searches for a Gift Batch Type with a type of:
Externally Processed
If one does not exist, it is automatically created.
Batch Resolution
The API then locates an appropriate Gift Batch.
If no matching batch exists:
A new Gift Batch record is created automatically.
The newly created Gift Import record is then associated with the batch.
Automatic Lookup Resolution
After creating the Gift Import record, the standard Klevr Gift Import matching process executes.
This process attempts to automatically resolve lookup fields based on the configured resolve queries.
Examples include:
- Donor
- Primary Contact
- Designation
- Campaign
- Appeal
- Package
- Solicited By
- Soft Credit To
- Attributed To
If exactly one matching record is found, the lookup field is automatically populated.
This reduces the amount of manual intervention required before conversion.
Gift Import Conversion Mapping
Once the Gift Import record has been created and validated, the Gift Conversion process uses the klevr_giftimportmapping.json web resource to determine how data should be transferred into downstream fundraising records.
This configuration controls mappings for:
- Gifts (
klevr_gift) - Payment Methods (
klevr_paymentmethod) - Payments (
klevr_financialtransaction) - Payment Schedules (
klevr_paymentschedule)
Mapping Structure
[
{
"From": "klevr_giftimport field schema name",
"To": "target field schema name",
"Entity": "target entity"
}
]
Mapping Properties
| Property | Description |
|-----------|-------------|
| From | Schema name of the source field on klevr_giftimport. |
| To | Schema name of the destination field. |
| Entity | Destination entity. If omitted, klevr_gift is assumed. |
Valid Entity Values
| Entity Value | Target Entity |
|-------------|---------------|
| (blank) | klevr_gift |
| klevr_paymentmethod | Payment Method |
| klevr_financialtransaction | Payment |
| klevr_paymentschedule | Payment Schedule |
Gift Mapping
If the Entity property is omitted, the mapping targets the Gift record.
Example:
{
"From": "klevr_amount",
"To": "klevr_amount"
}
Result:
Gift Import
klevr_amount
↓
Gift
klevr_amount
Payment Method Mapping
Payment Method mappings create and populate the donor's payment method record.
Example:
{
"From": "klevr_cardnumbertoken",
"To": "klevr_cardnumbertoken",
"Entity": "klevr_paymentmethod"
}
Commonly mapped fields include:
- Contact
- Account
- Payment Processor
- Processor Method
- Card Token
- Card Number Summary
- Cardholder Name
- Expiry Date
- Card Brand
Payment Mapping
Payment mappings populate the Financial Transaction record.
Example:
{
"From": "klevr_bookdate",
"To": "klevr_transactiondate",
"Entity": "klevr_financialtransaction"
}
Commonly mapped fields include:
- Amount
- Transaction Date
- Customer
- Payment Processor
- Payment Method
- Card Details
- Related Gift
Payment Schedule Mapping
Payment Schedule mappings are primarily used for recurring gifts.
Example:
{
"From": "klevr_frequencycode",
"To": "klevr_frequencycode",
"Entity": "klevr_paymentschedule"
}
Commonly mapped fields include:
- Frequency
- Interval
- Collection Day
- Start Date
- Amount
- Donor
- Gift Source
- Platform Cost Contribution
Gift Conversion Process
After Gift Import creation:
Create Gift Import
│
├─ Resolve Lookups
│
├─ Validate Mandatory Fields
│
└─ Convert
│
├─ Create Gift
│
├─ Create Payment Method
│
├─ Create Payment
│
└─ Create Payment Schedule
The conversion engine reads each mapping row and routes values to the appropriate destination entity.
A single Gift Import record can therefore act as the source of data for all fundraising and payment-related entities required by the Klevr platform.
Handling Conversion Failures
Conversion will fail if mandatory Gift Import information has not been supplied or resolved.
Common causes include:
- Missing donor information.
- Missing gift type.
- Missing amount.
- Unresolved lookups.
- Missing required payment details.
- Business-specific mandatory fields added through customisation.
When conversion fails:
- The Gift Import remains available in the batch.
- A user opens the Gift Import record.
- Missing fields are completed or matched manually.
- The record is saved.
- The user selects Convert to Gift from the ribbon.
This allows data quality issues to be resolved without requiring the third-party system to resubmit the transaction.
Example Request
{
"klevr_ExternalGiftImport_payload": "{\"DonorEmail\":\"john.smith@example.com\",\"Amount\":100.00,\"BookDate\":\"2026-08-01\"}",
"klevr_ExternalGiftImport_mapping": "MyIntegrationGiftMap.json"
}
Best Practices
Keep Integration Mappings Minimal
Only include fields required for the specific integration.
Use Hard-Coded Values Where Appropriate
Hard-code values for:
- Source System
- Gift Source
- Payment Processor
- Channel
- Import Type
Leverage Automatic Lookup Resolution
Where possible, provide:
- Email addresses
- Campaign codes
- Designation codes
- External identifiers
This increases successful automatic conversion rates.
Validate Recurring Giving Scenarios
Ensure testing covers:
- One-off gifts
- Recurring gifts
- Credit card payments
- Direct debit payments
- Existing donors
- New donors
- Failed lookup scenarios
- Manual conversion scenarios
End-to-End Process Summary
External System
│
▼
Submit API Payload
│
▼
klevr_ExternalGiftImport
│
├── Apply Import Mapping
│
├── Create Gift Import
│
├── Add To Externally Processed Batch
│
├── Attempt Lookup Resolution
│
├── Attempt Conversion
│
├──── Success ────► Gift Created
│ Payment Created
│ Schedule Created
│
└──── Failure ────► User Completes Missing Data
Convert To Gift Manually
Result: External systems can submit gifts through a simple API while Klevr Fundraising handles validation, donor matching, gift creation, payment processing, recurring giving setup, and exception handling.
Last updated on