Skip to content

Create Split Sessions via API

FairShare lets you create split sessions programmatically through the API.

This is best for merchants who want to create split sessions from their own backend, checkout, or application flow.

On This Page

Integration Options

You have two ways to use this:

OptionDescription
Build your own API flowCall the FairShare API directly from your backend and control the session creation flow yourself
Use the embeddable buttonAdd the FairShare button to your checkout and let it handle split session creation automatically

If you want full control over the experience, use the API directly. If you want a faster integration, use the embeddable button.

Authentication

To create split sessions through the API, include your merchant API key in the x-api-key header.

http
x-api-key: YOUR_API_KEY

Use your sandbox API key in sandbox and your live API key in live.

If you have not set up credentials yet, see API Keys.

Create a Split Session

Use this endpoint:

http
POST https://api.fairsharepay.com/api/v1/split-sessions

Request Fields

The request body contains the split session configuration.

FieldTypeRequiredDescription
totalAmountQarnumberYesTotal amount for the split session in QAR
itemsarray of objectsRequired for ITEM_CLAIMItems available in the split session
currencystringYesCurrency code for the session
splitTypestringYesType of split session
expectedContributorsintegerRequired for EQUAL_COUNTNumber of contributors expected for equal split sessions. Must be between 2 and 10
metastringNoOptional metadata, up to 1024 characters
successRedirectUrlstringRecommendedRedirect URL after a successful payment flow
cancelRedirectUrlstringRecommendedRedirect URL if the user cancels
detailTitlestringNoTitle or label shown for the split session
failedRedirectUrlstringRecommendedRedirect URL if the payment fails
expiryMinutesintegerYesSession expiry time in minutes. Must be between 1 and 60

Split Types

The splitType field supports the following values:

ValueDashboard LabelDescription
ITEM_CLAIMPick ItemsContributors select items and pay for what they picked
PROPORTIONAL_POOLFlexible AmountContributors pay any amount toward the total
EQUAL_COUNTSplit EvenlyThe total is divided equally across a fixed number of contributors

Items Object

If you use ITEM_CLAIM, include an items array.

Each item supports the following fields:

FieldTypeRequiredDescription
idstringYesYour item identifier
descriptionstringYesItem name or description
pricenumberYesPrice per unit
quantityintegerYesQuantity available. Must be at least 1
imageUrlstringNoOptional image URL

Examples by Split Type

Pick Items

Use ITEM_CLAIM when contributors should choose what they are paying for.

json
{
  "totalAmountQar": 120,
  "currency": "QAR",
  "splitType": "ITEM_CLAIM",
  "detailTitle": "Team dinner",
  "expiryMinutes": 15,
  "successRedirectUrl": "https://example.com/success",
  "cancelRedirectUrl": "https://example.com/cancel",
  "failedRedirectUrl": "https://example.com/failed",
  "items": [
    {
      "id": "pizza-1",
      "description": "Pizza",
      "price": 40,
      "quantity": 2,
      "imageUrl": "https://example.com/pizza.png"
    },
    {
      "id": "drink-1",
      "description": "Soft Drink",
      "price": 20,
      "quantity": 2
    }
  ]
}

Flexible Amount

Use PROPORTIONAL_POOL when contributors can each pay any amount toward the total.

json
{
  "totalAmountQar": 300,
  "currency": "QAR",
  "splitType": "PROPORTIONAL_POOL",
  "detailTitle": "Office gift",
  "expiryMinutes": 30,
  "successRedirectUrl": "https://example.com/success",
  "cancelRedirectUrl": "https://example.com/cancel",
  "failedRedirectUrl": "https://example.com/failed"
}

Split Evenly

Use EQUAL_COUNT when everyone should pay an equal share.

json
{
  "totalAmountQar": 200,
  "currency": "QAR",
  "splitType": "EQUAL_COUNT",
  "expectedContributors": 4,
  "detailTitle": "Group order",
  "expiryMinutes": 20,
  "successRedirectUrl": "https://example.com/success",
  "cancelRedirectUrl": "https://example.com/cancel",
  "failedRedirectUrl": "https://example.com/failed"
}

Response

When the split session is created successfully, FairShare returns the session details.

Common response fields include:

FieldDescription
idSplit session ID
splitSessionLinkShareable session link
totalTotal session amount
collectedAmount collected so far
statusCurrent session status
createdAtCreation timestamp
expiresAtExpiry timestamp
completedAtCompletion timestamp, if completed
refundedAtRefund timestamp, if refunded
currencySession currency
gatewayConnected payment gateway
environmentSANDBOX or LIVE
splitTypeSession split type
expectedContributorsExpected contributor count
minContributionMinimum contribution, if applicable
detailTitleSession title
leadContributorNameLead contributor name
leadContributorEmailLead contributor email
metaMetadata
itemsSession items

Split Session Statuses

A split session can return the following statuses:

StatusMeaning
PENDINGSession created and awaiting contributions
PARTIALSession has received some contributions but is not complete
SUCCEEDEDPayment flow succeeded
EXPIREDSession expired before completion
COMPLETEDSession was fully completed
REFUNDEDSession was refunded

Get a Split Session

http
GET https://api.fairsharepay.com/api/v1/split-sessions/{id}

Use this to retrieve the current details of a split session.

  • Create the split session through your backend
  • Receive the splitSessionLink in the response
  • Redirect the user to that link or send it directly
  • Use webhooks or GET /api/v1/split-sessions/{id} to track progress

Important

  • Call these APIs from your backend, not from frontend code
  • Use the API key that matches your current environment
  • Use ITEM_CLAIM for Pick Items
  • Use PROPORTIONAL_POOL for Flexible Amount
  • Use EQUAL_COUNT for Split Evenly