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-SplitPay-API-Key header.

http
X-SplitPay-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.

Idempotency

To safely retry create-session requests, send an Idempotency-Key header.

http
Idempotency-Key: 6f82d2e3-5252-4f3c-b45d-c238c5f9c7ce
  • This header is optional but strongly recommended.
  • Maximum length is 120 characters.
  • Reusing the same key with the exact same payload returns the original split session.
  • Reusing the same key with a different payload returns a conflict error.

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
totalAmountnumberYesTotal amount for the split session
itemsarray of objectsRequired for ITEM_CLAIMItems available in the split session
currencystringYesISO currency code for the session
splitTypestringYesType of split session
expectedContributorsintegerNo (required before contributions for EQUAL_COUNT)Number of contributors for equal split sessions. Must be between 2 and 10
convenienceFeeTypestringNoConvenience fee mode. Values: NONE, FIXED_PER_CONTRIBUTION (defaults to NONE)
convenienceFeeValuenumberNoConvenience fee value (defaults to 0.00)
metastringNoOptional metadata, up to 1024 characters
successRedirectUrlstringRecommendedRedirect URL after a successful payment flow
cancelRedirectUrlstringRecommendedRedirect URL if the user cancels
failedRedirectUrlstringRecommendedRedirect URL if the payment fails
detailTitlestringNoTitle or label shown for the split session
expiryMinutesintegerNoSession expiry time in minutes. Must be between 1 and 60 (defaults to 15)

Check Split Session Availability

Before showing a FairShare split-payments option on your own website or checkout, call this endpoint to confirm that the merchant can currently create split sessions in that environment.

This check is recommended before you display or enable a split payment option in your product.

Use this endpoint:

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

Authentication:

http
X-SplitPay-API-Key: YOUR_API_KEY

The environment is inferred from the API key you send:

  • Sandbox key (sdbx_...) checks sandbox availability
  • Live key (live_...) checks live availability

This endpoint is designed to be safe to call before split-session creation. It tells you whether the merchant is currently eligible to create split sessions and, if not, returns blockers explaining what still needs attention.

What It Returns

FieldTypeDescription
environmentstringEnvironment derived from the API key
canCreateSplitSessionbooleanWhether split session creation should work right now
blockersarray of stringsMachine-readable blockers explaining why it is unavailable
merchantStatusstringCurrent merchant status
hasPaymentMethodOnFilebooleanWhether the merchant has a payment method on file
gatewaystring or nullConnected PSP for that environment, if present
connectionStatusstring or nullPSP connection status for that environment, if present

Common Blockers

BlockerMeaning
MERCHANT_PROFILE_INCOMPLETEMerchant profile is not active yet
LIVE_PAYMENT_METHOD_REQUIREDLive mode is blocked until a payment method is on file
PSP_CONNECTION_MISSINGNo PSP connection exists for the environment
PSP_CONNECTION_NOT_ACTIVEA PSP connection exists but is not active

Example Success Response

json
{
  "environment": "LIVE",
  "canCreateSplitSession": true,
  "blockers": [],
  "merchantStatus": "ACTIVE",
  "hasPaymentMethodOnFile": true,
  "gateway": "STRIPE",
  "connectionStatus": "ACTIVE"
}

Example Unavailable Response

json
{
  "environment": "LIVE",
  "canCreateSplitSession": false,
  "blockers": [
    "LIVE_PAYMENT_METHOD_REQUIRED",
    "PSP_CONNECTION_MISSING"
  ],
  "merchantStatus": "ACTIVE",
  "hasPaymentMethodOnFile": false,
  "gateway": null,
  "connectionStatus": null
}

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
{
  "totalAmount": 120,
  "currency": "QAR",
  "splitType": "ITEM_CLAIM",
  "convenienceFeeType": "NONE",
  "convenienceFeeValue": 0,
  "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
{
  "totalAmount": 300,
  "currency": "QAR",
  "splitType": "PROPORTIONAL_POOL",
  "convenienceFeeType": "FIXED_PER_CONTRIBUTION",
  "convenienceFeeValue": 2.5,
  "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
{
  "totalAmount": 200,
  "currency": "QAR",
  "splitType": "EQUAL_COUNT",
  "expectedContributors": 4,
  "convenienceFeeType": "NONE",
  "convenienceFeeValue": 0,
  "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
createdCreation timestamp
expiresAtExpiry timestamp
completedAtCompletion timestamp, if completed
refundedAtRefund timestamp, if refunded
currencySession currency
gatewayConnected payment gateway
splitTypeSession split type
expectedContributorsExpected contributor count
minContributionMinimum contribution (for proportional pool)
convenienceFeeTypeSession convenience fee mode
convenienceFeeValueSession convenience fee value
detailTitleSession title
leadContributorNameLead contributor name
leadContributorEmailLead contributor email
metaMetadata
itemsSession items

Example Success Response

json
{
  "id": "9f6e96d3-7b18-4f0e-96b8-e2eb9f6a2a1c",
  "splitSessionLink": "https://app.fairsharepay.com/contributor/9f6e96d3-7b18-4f0e-96b8-e2eb9f6a2a1c",
  "total": 200.00,
  "collected": 0.00,
  "authorizedAmount": 0.00,
  "status": "PENDING",
  "created": "2026-04-08T10:15:30Z",
  "expiresAt": "2026-04-08T10:35:30Z",
  "completedAt": null,
  "refundedAt": null,
  "currency": "QAR",
  "gateway": "STRIPE",
  "splitType": "EQUAL_COUNT",
  "expectedContributors": 4,
  "minContribution": null,
  "convenienceFeeType": "FIXED_PER_CONTRIBUTION",
  "convenienceFeeValue": 2.50,
  "detailTitle": "Group order",
  "leadContributorName": null,
  "leadContributorEmail": null,
  "meta": "order-123",
  "successRedirectUrl": "https://example.com/success",
  "cancelRedirectUrl": "https://example.com/cancel",
  "failedRedirectUrl": "https://example.com/failed",
  "items": [],
  "contributions": []
}

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

Error Handling

The API returns structured ApiError responses with a stable code and message.

Common create-session errors:

HTTP StatusError CodeWhat it means
400VALIDATION_ERROROne or more request fields are invalid or missing.
400IDEMPOTENCY_KEY_INVALIDIdempotency-Key is invalid (for example, too long).
400EXPECTED_CONTRIBUTORS_INVALIDexpectedContributors is invalid for equal split rules.
400CONVENIENCE_FEE_INVALIDConvenience fee configuration or value is invalid.
401UNAUTHORIZEDRequest is not authenticated (missing/invalid API key).
403FORBIDDENMerchant is authenticated but not allowed to perform this action.
403LIVE_ACCESS_DISABLEDLive mode is blocked until a payment method is on file.
409IDEMPOTENCY_KEY_REUSEDThe same idempotency key was already used with a different request payload.
409PSP_CONNECTION_MISSINGNo active payment gateway connection exists for the merchant environment.
409BUSINESS_RULE_VIOLATIONRequest violates a business rule for the current state.
500INTERNAL_ERRORUnexpected server error. Retry later or contact support if persistent.

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.

Check Split Session Availability

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

Use this before rendering a split-payments button on your website or checkout.

Set Expected Contributors (Equal Split)

http
POST https://api.fairsharepay.com/api/v1/split-sessions/{id}/expected-contributors

Use this to set expectedContributors for EQUAL_COUNT sessions before contributions begin.

  • Call GET /api/v1/split-sessions/availability before rendering the FairShare split-payments entry point to make sure your merchant account can currently create split sessions.
  • Create the split session through your backend after availability is confirmed.
  • 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.
  • Call the availability endpoint before showing a split payment option in your UI.
  • Use ITEM_CLAIM for Pick Items.
  • Use PROPORTIONAL_POOL for Flexible Amount.
  • Use EQUAL_COUNT for Split Evenly.