🏆 Partner API Reference
Complete reference for awarding miles and processing transactions.
Get User Information
Retrieve user information including their unique identifier and current miles balance.
Required Scope: miles:read
Example Request
curl -X GET https://backend.earthmiles.app/api/partner-api/me \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Responses
| Status Code | Response |
|---|---|
| 200 | { "id": "cmfmrl4t1000008kygcua1gxs", "balance": 1250 } |
| 404 | { "error": "User not found" } |
Award Points
Award miles to users based on the defined categories.
Required Scope: miles:write
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
bonusRuleId |
string | ✅ | ID of the bonus rule |
pointsToAward |
number | Conditional | Required for dynamic rules (must be 1 or more) |
Dynamic vs Fixed Rules
The behavior of pointsToAward depends on the bonus rule type:
- Dynamic rule:
pointsToAwardis required and must be 1 or more. The provided value is awarded to the user. - Fixed rule: do not include
pointsToAward. If provided, it is ignored and the rule's fixed points are awarded instead.
Example Request
curl -X POST https://backend.earthmiles.app/api/partner-api/award-points \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"categoryId": "cmfmple0x000008l16wx18dz0",
"pointsToAward": 150
}'
Responses
| Status Code | Response |
|---|---|
| 200 | { "message": "Points awarded successfully" } |
| 400 | { "error": "Category is not active." } |
Process Transaction
Process transactions and automatically award points based on purchase amounts.
Required Scope: miles:write
Request Body
{
"transactions": [
{
"description": "bike rental",
"amount": 100.50,
"currency": "DKK",
"transactionId": "f64a0299-3646-481c-9b08-c7ccd6b5df1a",
"transactionDate": "2023-07-25T10:30:00Z",
"startLocation": {
"lat": 55.6761,
"lng": 12.5683
},
"endLocation": {
"lat": 55.6894,
"lng": 12.5519
}
}
]
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
transactions |
array | ✅ | Array of transaction objects |
transactions[].description |
string | ✅ | Description of the transaction |
transactions[].amount |
number | ✅ | Transaction amount (must be positive) |
transactions[].currency |
string | ✅ | Currency code (e.g., "DKK", "NOK") |
transactions[].transactionId |
string | ✅ | Unique transaction identifier |
transactions[].transactionDate |
string | ✅ | ISO-8601 timestamp |
transactions[].startLocation |
object | ❌ | Starting location of the trip |
transactions[].endLocation |
object | ❌ | Ending location of the trip |
Transaction Description
The description field should include your special keyword so we can calculate points based on it.
If you are unsure of your special keyword, please contact us.
Also, please include as much information as possible while keeping it short; we recommend keeping descriptions under 150 characters.
Supported Currencies
The following currencies are supported for transactions:
| Currency | Code |
|---|---|
| Danish Krone | DKK |
| Norwegian Krone | NOK |
Example Request
curl -X POST https://backend.earthmiles.app/api/partner-api/process-transaction \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"transactions": [
{
"description": "bike rental",
"amount": 250.75,
"currency": "DKK",
"transactionId": "f64a0299-3646-481c-9b08-c7ccd6b5df1a",
"transactionDate": "2023-09-11T14:30:00Z",
"startLocation": { "lat": 55.6761, "lng": 12.5683 },
"endLocation": { "lat": 55.6894, "lng": 12.5519 }
}
]
}'
Responses
| Status Code | Response |
|---|---|
| 200 | { "message": "Transaction processed successfully" } |
| 400 | { "error": "Invalid transaction data" } |