Trax Platform APIv1

Memberships

A family buys memberships in the cart, like registrations, in one of two ways:

Every call here except the list needs the family's access token.

The server works out every date and price. A request names only who, which membership type and, for an activity's membership, which activity. Never send dates, fees or amounts: the API computes them from the organization's setup and calendar, and ignores anything else.

The memberships list

GET …/memberships lists the types offered online here (Portal guide). canPurchase is false for a type whose setup keeps it off sale online, for example a fee split into several amounts. Show it, and send families to the organization.

A type's duration is one of:

Can this member buy it?

A membership this portal doesn't offer

GET https://api.nfocus.solutions/v1/portals/riverbend/north/memberships/999999/eligibility → 404, problem details

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/memberships/999999/eligibility' \
  -H 'Authorization: Bearer your_access_token'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/memberships/999999/eligibility', {
  headers: {
    'Authorization': 'Bearer your_access_token',
  },
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/north/memberships/999999/eligibility");
request.Headers.Authorization = new("Bearer", "your_access_token");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

GET …/memberships/{membershipTypeId}/eligibility answers for each household member:

Field Meaning
members[].canBuy true when the member can buy the membership on its own now
members[].periods The dates they would get (startDate and endDate both included), the price, the minimum, and the due date
members[].totalCents What the membership would charge
members[].problems Why not, with a code (below)

It answers 404 membership-not-found for a type that isn't on this portal's list.

Buying one on its own

POST …/cart/items:

{ "kind": "membership", "membershipTypeId": 12, "personId": 1052 }

A membership line without a type

POST https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items → 400, problem details

curl
curl -s -X POST 'https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items' \
  -H 'Authorization: Bearer your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"kind": "membership", "personId": 1234 }'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_access_token',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"kind": "membership", "personId": 1234 }),
});
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nfocus.solutions/v1/portals/riverbend/north/cart/items");
request.Headers.Authorization = new("Bearer", "your_access_token");
request.Content = new StringContent("""
    {"kind": "membership", "personId": 1234 }
    """, System.Text.Encoding.UTF8, "application/json");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

The line has kind: "membership" and a membership object:

Field Meaning
membership.id, membership.name The type
membership.forActivity The activity it was added for, or null
membership.waiverText The type's waiver, to show with the line (recording the family's acceptance comes with the checkout forms step)
membership.periods[] Each membership the line buys: startDate, endDate (both included), amountCents, minimumDueCents, dueDate, payTodayCents

The rest of the line works like a registration's: totalCents, minimumCents, payCents, laterCents and problems. Choose today's payment with PATCH …/cart/items/{id} (Cart and checkout guide).

Its dates:

No early renewal: a member who holds a current or upcoming membership of the type can't buy another on its own. The problem membership-already-held carries renewsOn, the first day a new one can be bought. The next period can be bought ahead through an activity that needs it (below).

Buying one for an activity

When a member's activity line shows membership-required, its membershipTypes list the types that would do. Those with canBuy: true can be bought in the same cart. The activity line can still be added; until a membership covers it, it shows the problem and the cart can't check out.

Add the membership for that activity line:

{ "kind": "membership", "membershipTypeId": 12, "personId": 1052, "activityId": 41 }

The server fills only the days the member isn't covered for, from the activity's first day (or today, once it has started) to its last. It counts:

So a membership can be bought ahead: it starts the day after the held one ends. A long activity can need several periods back to back. Each period is one membership at the full fee, listed in membership.periods.

Rules for these lines:

Problems

Code When
membership-not-offered The type isn't on this portal's list, or the activity doesn't accept it
membership-unavailable The type can't be bought online (not public, a fee with several amounts, or a duration the organization hasn't set up fully); contact the organization
memberships-hidden This portal doesn't sell memberships on their own; one an activity needs can still be bought
membership-already-held (with renewsOn) The member already has a current or upcoming membership of the type
membership-overlap A period would overlap a membership of the same type the member holds or has in the cart
membership-not-needed The activity is already covered; remove the line
membership-cannot-cover The type's calendar window can't cover the activity's dates; choose another type
membership-activity-missing The activity the membership was added for isn't in the cart
household-not-verified, parent-portal-only As for registrations

Any household member can hold a membership, adults included: there are no age or gender rules. The balance-due rule never applies to memberships.

Checkout

Membership lines check out with the rest of the cart. In the order, a membership line has kind: "membership", membershipTypeId, activityId (the activity it was bought for, or null) and periods. The receipt email lists each membership with its dates. Two checkouts can't both buy overlapping memberships: the second answers 409 cart-changed.

What changed from the current portal