Skip to content

Orders & Commissions API

Manage tracked conversions (orders), view commission statistics, approve or reject pending commissions, and export data.


Authentication

All endpoints require a Bearer access token with the appropriate scope. See authentication.md.

ScopeAccess
orders:readList, show, stats, export
orders:writeApprove, reject, bulk approve, bulk reject

Endpoints

MethodPathScopeThrottleDescription
GET/v1/ordersorders:read120/minList orders (paginated)
GET/v1/orders/statsorders:read120/minAggregated statistics
GET/v1/orders/exportorders:read30/minCSV export
GET/v1/orders/{id}orders:read120/minSingle order detail
POST/v1/orders/{id}/approveorders:write60/minApprove pending order
POST/v1/orders/{id}/rejectorders:write60/minReject pending order
POST/v1/orders/bulk-approveorders:write60/minBulk approve
POST/v1/orders/bulk-rejectorders:write60/minBulk reject

List Orders — GET /v1/orders

Returns a paginated list of conversions with filtering, sorting, and search.

Query Parameters

ParameterTypeRequiredDefaultConstraintsDescription
searchstringNomax:255Search by order ID or affiliate name
statusstringNopending, approved, rejected, cancelledFilter by conversion status
affiliate_idintegerNoValid affiliate ID for this businessFilter by affiliate
fromdateNoYYYY-MM-DDStart of date range (inclusive)
todateNoYYYY-MM-DD, must be >= fromEnd of date range (inclusive)
sortstringNoconverted_atorder_id, order_total, commission_amount, converted_at, statusSort field
directionstringNodescasc, descSort direction
per_pageintegerNo251–100Items per page
pageintegerNo1min:1Page number

Example

bash
curl "https://heldsway.com/api/v1/orders?status=pending&sort=order_total&direction=desc&per_page=10" \
  -H "Authorization: Bearer <access_token>"

Success Response — HTTP 200

json
{
  "success": true,
  "message": "OK",
  "data": {
    "items": [
      {
        "id": 42,
        "order_id": "#135419",
        "affiliate": {
          "id": 7,
          "name": "Salman",
          "referral_code": "SALMAN2026"
        },
        "customer": {
          "name": "Geonwoo Park",
          "email": "geonwoo@example.com"
        },
        "subtotal": "70.00",
        "discount_applied": "0.00",
        "tax": "0.00",
        "order_total": "70.00",
        "commission_rate": "10.00",
        "commission_amount": "7.00",
        "currency": "USD",
        "status": "pending",
        "converted_at": "2026-04-10T14:30:00.000000Z",
        "created_at": "2026-04-10T14:30:00.000000Z"
      },
      {
        "id": 41,
        "order_id": "#135380",
        "affiliate": null,
        "customer": null,
        "subtotal": "140.00",
        "discount_applied": "0.00",
        "tax": "0.00",
        "order_total": "140.00",
        "commission_rate": "0.00",
        "commission_amount": "0.00",
        "currency": "USD",
        "status": "approved",
        "converted_at": "2026-04-08T14:30:00.000000Z",
        "created_at": "2026-04-08T14:30:00.000000Z"
      }
    ],
    "meta": {
      "current_page": 1,
      "per_page": 10,
      "total": 2,
      "last_page": 1
    }
  }
}

Response Fields

FieldTypeDescription
items[].idintegerInternal conversion record ID
items[].order_idstringExternal order identifier
items[].affiliateobject|nullAttributed affiliate (null if unattributed)
items[].affiliate.idintegerAffiliate ID
items[].affiliate.namestringAffiliate's display name
items[].affiliate.referral_codestringAffiliate's referral code
items[].customerobject|nullCustomer info (null if no customer data)
items[].customer.namestring|nullCustomer name
items[].customer.emailstring|nullCustomer email
items[].subtotalstringPre-discount amount (2 decimal places)
items[].discount_appliedstringDiscount amount
items[].taxstringTax amount
items[].order_totalstringGross total
items[].commission_ratestringCommission rate (%) applied
items[].commission_amountstringComputed commission amount
items[].currencystring3-letter currency code (default USD)
items[].statusstringpending, approved, rejected, or cancelled
items[].converted_atstring|nullISO 8601 timestamp of conversion
items[].created_atstringISO 8601 timestamp of record creation
meta.current_pageintegerCurrent page number
meta.per_pageintegerItems per page
meta.totalintegerTotal matching records
meta.last_pageintegerLast available page

Get Order Stats — GET /v1/orders/stats

Returns aggregated summary statistics for all conversions. Optionally filter by date range.

Query Parameters

ParameterTypeRequiredConstraintsDescription
fromdateNoYYYY-MM-DDStart of date range
todateNoYYYY-MM-DD, must be >= fromEnd of date range

Example

bash
curl "https://heldsway.com/api/v1/orders/stats?from=2026-04-01&to=2026-04-15" \
  -H "Authorization: Bearer <access_token>"

Success Response — HTTP 200

json
{
  "success": true,
  "message": "OK",
  "data": {
    "total_orders": 2,
    "total_revenue": 210.00,
    "total_commission": 14.00,
    "pending_commission": 0.00,
    "approved_commission": 14.00
  }
}

Response Fields

FieldTypeDescription
total_ordersintegerTotal number of conversions
total_revenuenumberSum of order_total across all conversions
total_commissionnumberSum of commission_amount across all conversions
pending_commissionnumberSum of commission_amount for pending conversions
approved_commissionnumberSum of commission_amount for approved conversions

Get Order Detail — GET /v1/orders/{id}

Returns the full detail for a single conversion, including line items and click attribution.

Path Parameters

ParameterTypeDescription
idintegerConversion record ID

Example

bash
curl "https://heldsway.com/api/v1/orders/42" \
  -H "Authorization: Bearer <access_token>"

Success Response — HTTP 200

json
{
  "success": true,
  "message": "OK",
  "data": {
    "id": 42,
    "order_id": "#135380",
    "affiliate": {
      "id": 7,
      "name": "Salman",
      "referral_code": "SALMAN2026",
      "commission_rate": "10.00"
    },
    "customer": {
      "name": "Jane Smith",
      "email": "jane@example.com"
    },
    "subtotal": "140.00",
    "discount_applied": "0.00",
    "tax": "0.00",
    "order_total": "140.00",
    "commission_rate": "10.00",
    "commission_amount": "14.00",
    "currency": "USD",
    "status": "approved",
    "line_items": [
      { "name": "Mountain Bike Rental", "quantity": 1, "price": "140.00" }
    ],
    "ip_address": "192.168.1.100",
    "click": {
      "id": 123,
      "referral_link_id": 45,
      "landing_page": "https://mountainthreads.example.com/bikes",
      "referrer": "https://instagram.com",
      "created_at": "2026-04-08T10:00:00.000000Z"
    },
    "converted_at": "2026-04-08T14:30:00.000000Z",
    "created_at": "2026-04-08T14:30:00.000000Z",
    "updated_at": "2026-04-08T15:00:00.000000Z"
  }
}

Additional Detail Fields

These fields appear only in the detail response (not in the list):

FieldTypeDescription
affiliate.commission_ratestring|nullAffiliate's override commission rate (may differ from business default)
line_itemsarray|nullProduct details from the order
ip_addressstring|nullCustomer's IP address
clickobject|nullAttribution click data (null if direct conversion)
click.idintegerClick record ID
click.referral_link_idintegerAssociated referral link ID
click.landing_pagestring|nullPage URL where the click landed
click.referrerstring|nullReferring URL
click.created_atstringISO 8601 timestamp of the click
updated_atstringISO 8601 timestamp of last update

Error — HTTP 404

json
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Order not found."
  }
}

Approve Order — POST /v1/orders/{id}/approve

Transitions a pending conversion to approved status. The commission is considered owed once approved.

Path Parameters

ParameterTypeDescription
idintegerConversion record ID

Body Parameters

FieldTypeRequiredConstraintsDescription
notesstringNomax:1000Approval notes (stored in audit log)

Example

bash
curl -X POST "https://heldsway.com/api/v1/orders/42/approve" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{ "notes": "Verified payment received" }'

Success Response — HTTP 200

json
{
  "success": true,
  "message": "Order #135419 approved.",
  "data": {
    "id": 42,
    "order_id": "#135419",
    "status": "approved",
    "commission_amount": "7.00",
    "updated_at": "2026-04-15T12:00:00.000000Z"
  }
}

Error — HTTP 409 (Invalid Status Transition)

json
{
  "success": false,
  "error": {
    "code": "INVALID_STATUS",
    "message": "Only pending conversions can be approved. Current status: approved"
  }
}

Error — HTTP 404

json
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Order not found."
  }
}

Reject Order — POST /v1/orders/{id}/reject

Transitions a pending conversion to rejected status. The commission is voided.

Path Parameters

ParameterTypeDescription
idintegerConversion record ID

Body Parameters

FieldTypeRequiredConstraintsDescription
reasonstringNomax:1000Rejection reason (stored in audit log)

Example

bash
curl -X POST "https://heldsway.com/api/v1/orders/42/reject" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "Fraudulent order - chargeback received" }'

Success Response — HTTP 200

json
{
  "success": true,
  "message": "Order #135419 rejected.",
  "data": {
    "id": 42,
    "order_id": "#135419",
    "status": "rejected",
    "commission_amount": "7.00",
    "updated_at": "2026-04-15T12:00:00.000000Z"
  }
}

Error — HTTP 409 (Invalid Status Transition)

json
{
  "success": false,
  "error": {
    "code": "INVALID_STATUS",
    "message": "Only pending conversions can be rejected. Current status: approved"
  }
}

Bulk Approve — POST /v1/orders/bulk-approve

Approves multiple pending conversions in a single request. Non-pending conversions are silently skipped.

Body Parameters

FieldTypeRequiredConstraintsDescription
idsinteger[]Yesmin:1, max:100, each distinctConversion IDs to approve

Example

bash
curl -X POST "https://heldsway.com/api/v1/orders/bulk-approve" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{ "ids": [42, 43, 44, 45, 46] }'

Success Response — HTTP 200

json
{
  "success": true,
  "message": "3 order(s) approved.",
  "data": {
    "approved_count": 3,
    "requested_count": 5,
    "skipped_count": 2
  }
}

Response Fields

FieldTypeDescription
approved_countintegerNumber of conversions actually approved
requested_countintegerTotal IDs submitted in the request
skipped_countintegerIDs that were skipped (non-existent, wrong business, or not pending)

Error — HTTP 422

json
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "details": {
      "ids": ["The ids field is required."]
    }
  }
}

Bulk Reject — POST /v1/orders/bulk-reject

Rejects multiple pending conversions in a single request. Non-pending conversions are silently skipped.

Body Parameters

FieldTypeRequiredConstraintsDescription
idsinteger[]Yesmin:1, max:100, each distinctConversion IDs to reject
reasonstringNomax:1000Rejection reason (applied to all, stored in audit log)

Example

bash
curl -X POST "https://heldsway.com/api/v1/orders/bulk-reject" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{ "ids": [47, 48], "reason": "Duplicate orders from same session" }'

Success Response — HTTP 200

json
{
  "success": true,
  "message": "2 order(s) rejected.",
  "data": {
    "rejected_count": 2,
    "requested_count": 2,
    "skipped_count": 0
  }
}

Export Orders — GET /v1/orders/export

Returns a CSV file containing conversions matching the provided filters.

Query Parameters

ParameterTypeRequiredConstraintsDescription
searchstringNomax:255Search by order ID or affiliate name
statusstringNopending, approved, rejected, cancelledFilter by conversion status
affiliate_idintegerNoValid affiliate IDFilter by affiliate
fromdateNoYYYY-MM-DDStart of date range (inclusive)
todateNoYYYY-MM-DDEnd of date range (inclusive)

Example

bash
curl "https://heldsway.com/api/v1/orders/export?status=approved&from=2026-04-01&to=2026-04-30" \
  -H "Authorization: Bearer <access_token>" \
  -o "approved_orders_april.csv"

Success Response — HTTP 200

Content-Type: text/csvContent-Disposition: attachment; filename="conversions_export_2026-04-15_103000.csv"

CSV Columns

ColumnDescription
IDInternal conversion ID
Order IDExternal order identifier
Affiliate NameName of the attributed affiliate
Referral CodeAffiliate's referral code
Customer NameCustomer name (if available)
Customer EmailCustomer email (if available)
SubtotalPre-discount amount
DiscountDiscount applied
Order TotalGross total
Commission RateCommission percentage applied
Commission AmountComputed commission
CurrencyOrder currency code
Statuspending, approved, rejected, or cancelled
Converted AtUTC timestamp of conversion

Conversion Status Workflow

  1. Pending: Initial state when a conversion is tracked.
  2. Approved: Explicitly approved by the merchant. Commission is owed.
  3. Rejected: Explicitly rejected by the merchant (e.g., fraud, return). Commission is voided.
  4. Cancelled: Order cancelled via ecommerce integration webhook. Commission is voided.

Valid Transitions:

  • pendingapproved
  • pendingrejected
  • pendingcancelled

Once approved, rejected, or cancelled, the status is terminal and cannot be changed via the API.


Error Reference

HTTP StatusCodeDescription
401UNAUTHORIZEDMissing, invalid, or expired Bearer token
403FORBIDDENMissing required orders:read or orders:write scope
404NOT_FOUNDOrder not found or doesn't belong to this business
409INVALID_STATUSAttempted invalid status transition
422VALIDATION_ERRORRequest parameters failed validation

Rate Limiting

ActionLimit
Read (List, Stats, Detail)120 requests/minute
Write (Approve, Reject, Bulk)60 requests/minute
Export30 requests/minute

Released under the MIT License.