Skip to content

🏆 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.

GET /api/partner-api/me
Authorization: Bearer {access_token}

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.

POST /api/partner-api/award-points
Authorization: Bearer {access_token}

Required Scope: miles:write

Request Body

{
  "categoryId": "category_id",
  "pointsToAward": 100
}
Parameter Type Required Description
categoryId string ID of the category
pointsToAward number Number of points to award (must be positive)

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.

POST /api/partner-api/process-transaction
Authorization: Bearer {access_token}

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"
    }
  ]
}

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

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"
      }
    ]
  }'

Responses

Status Code Response
200 { "message": "Transaction processed successfully" }
400 { "error": "Invalid transaction data" }