AlmondTill/G3N API

Pay the people who sell for you — staff commissions and referral partners

Define how staff commission is computed and read what you owe each seller; set up the partners who refer businesses to you and read what you owe them — ledgers and payout reports on both sides.

Pricing & money · a play in 4 steps.

The steps

  1. Define the commission settings for the scope. — createCommissionConfig
  2. Read what staff earned, entry by entry, and what you owe each seller for the period. — commissionEntryList, commissionPayoutReport
  3. Set up a referral partner — an affiliate who earns a share for the businesses they introduce. — createAffiliate
  4. Read the partners’ earnings ledger and what you owe each of them for the period. — affiliateAccruals, affiliatePayoutReport

The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

createCommissionConfig

createCommissionConfig — mutation · Create a new commission settings — how staff sales commission is computed at your organization.

Example request

mutation ExampleCreateCommissionConfig($input: NewCommissionConfigInput!) {
  createCommissionConfig(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    appliesToAllSalesInScope
    agentRoleId
    agentUserId
    divisionId
    categoryId
    styleId
    organizationId
    logicalFacilityId
    channel
    enabled
  }
}

Variables:

{
  "input": {
    "caption": "Blue jeans"
  }
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

{
  "data": {
    "createCommissionConfig": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "CG-EXMP-0000-000F",
      "type": "CommissionConfig",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "appliesToAllSalesInScope": true,
      "agentRoleId": "01900000-0000-7000-8000-1c1b82930000",
      "agentUserId": "01900000-0000-7000-8000-640b76dc0000",
      "divisionId": "01900000-0000-7000-8000-25bd925b0000",
      "categoryId": "01900000-0000-7000-8000-786111a40000",
      "styleId": "01900000-0000-7000-8000-2f797c8b0000",
      "organizationId": "01900000-0000-7000-8000-44b781470000",
      "logicalFacilityId": "01900000-0000-7000-8000-8026f71c0000",
      "channel": "pos",
      "enabled": true
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

commissionEntryList

commissionEntryList — query · The commission ledger — what staff earned, entry by entry.

Example request

query ExampleCommissionEntryList($agentUserId: ID) {
  commissionEntryList(agentUserId: $agentUserId) {
    items {
      id
      parentId
      entryType
      entryClass
      amountMinor
      currency
      configId
      orderId
      returnId
      caption
      createdAt
    }
    nextToken
  }
}

Variables:

{
  "agentUserId": "01900000-0000-7000-8000-640b76dc0000"
}

Example response

{
  "data": {
    "commissionEntryList": {
      "items": [
        {
          "id": "01900000-0000-7000-8000-37386ae00000",
          "parentId": "01900000-0000-7000-8000-065235280000",
          "entryType": "earn",
          "entryClass": "attributed",
          "amountMinor": 1,
          "currency": "USD",
          "configId": "01900000-0000-7000-8000-bfbd59aa0000",
          "orderId": "01900000-0000-7000-8000-f6d8263a0000",
          "returnId": "01900000-0000-7000-8000-4d4c03d20000",
          "caption": "Blue jeans",
          "createdAt": "2027-01-31T00:00:00.000Z"
        }
      ],
      "nextToken": "<the cursor from the previous page>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

commissionPayoutReport

commissionPayoutReport — query · The commission payout report — what you owe each seller for the period.

Example request

query ExampleCommissionPayoutReport($from: String!, $to: String!, $agentUserId: ID) {
  commissionPayoutReport(from: $from, to: $to, agentUserId: $agentUserId) {
    items {
      subjectId
      currency
      earnedMinor
      clawedBackMinor
      payableMinor
      entryCount
    }
    nextToken
  }
}

Variables:

{
  "from": "<from>",
  "to": "<to>",
  "agentUserId": "01900000-0000-7000-8000-640b76dc0000"
}

Example response

{
  "data": {
    "commissionPayoutReport": {
      "items": [
        {
          "subjectId": "01900000-0000-7000-8000-91fe7ba20000",
          "currency": "USD",
          "earnedMinor": 1,
          "clawedBackMinor": 1,
          "payableMinor": 1,
          "entryCount": 1
        }
      ],
      "nextToken": "<the cursor from the previous page>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

createAffiliate

createAffiliate — mutation · Create a new affiliate — a commission-earning referral partner at your organization.

Example request

mutation ExampleCreateAffiliate($input: NewAffiliateInput!) {
  createAffiliate(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    organizationIds
    ratePpm
    consumerId
    handle
    bio
    socialLinks
    audienceSize
    nicheTags
  }
}

Variables:

{
  "input": {
    "caption": "Blue jeans"
  }
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

{
  "data": {
    "createAffiliate": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "AF-EXMP-0000-000F",
      "type": "Affiliate",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "organizationIds": [
        "01900000-0000-7000-8000-60e064dc0000"
      ],
      "ratePpm": 1,
      "consumerId": "01900000-0000-7000-8000-6e8c92ec0000",
      "handle": "<handle>",
      "bio": "<bio>",
      "socialLinks": [
        "<social links>"
      ],
      "audienceSize": 1,
      "nicheTags": [
        "<niche tags>"
      ]
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

affiliateAccruals

affiliateAccruals — query · Your referral earnings ledger — subscription-share and usage-share rows for the businesses you introduced, months your own bill was settled from earnings, and any reversals, with the rate and basis on every row.

Example request

query ExampleAffiliateAccruals($limit: Int) {
  affiliateAccruals(limit: $limit) {
    id
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    entryType
    ownerOrgGroupId
    periodMonth
    cycle
    ratePercent
    collectedUsdCents
    usageBasisCents
    amountUsdCents
    billingChargeId
  }
}

Variables:

{
  "limit": 1
}

Example response

{
  "data": {
    "affiliateAccruals": [
      {
        "id": "01900000-0000-7000-8000-37386ae00000",
        "type": "<type>",
        "caption": "Blue jeans",
        "status": "<status>",
        "parentId": "01900000-0000-7000-8000-065235280000",
        "rootId": "01900000-0000-7000-8000-a093dd800000",
        "createdAt": "2027-01-31T00:00:00.000Z",
        "updatedAt": "2027-01-31T00:00:00.000Z",
        "revisionNum": 1,
        "revision": "01900000-0000-7000-8000-b7960e180000",
        "entryType": "<entry type>",
        "ownerOrgGroupId": "01900000-0000-7000-8000-0af354680000",
        "periodMonth": "<period month>",
        "cycle": 1,
        "ratePercent": 1,
        "collectedUsdCents": 1,
        "usageBasisCents": 1,
        "amountUsdCents": 1,
        "billingChargeId": "01900000-0000-7000-8000-34d522a50000"
      }
    ]
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

affiliatePayoutReport

affiliatePayoutReport — query · The payout report for affiliates — what you owe each partner for the period.

Example request

query ExampleAffiliatePayoutReport($from: String!, $to: String!, $affiliateId: ID) {
  affiliatePayoutReport(from: $from, to: $to, affiliateId: $affiliateId) {
    items {
      subjectId
      currency
      earnedMinor
      clawedBackMinor
      payableMinor
      entryCount
    }
    nextToken
  }
}

Variables:

{
  "from": "<from>",
  "to": "<to>",
  "affiliateId": "01900000-0000-7000-8000-ab1bc9b90000"
}

Example response

{
  "data": {
    "affiliatePayoutReport": {
      "items": [
        {
          "subjectId": "01900000-0000-7000-8000-91fe7ba20000",
          "currency": "USD",
          "earnedMinor": 1,
          "clawedBackMinor": 1,
          "payableMinor": 1,
          "entryCount": 1
        }
      ],
      "nextToken": "<the cursor from the previous page>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}