Docs API Reference Record merchant business events Record merchant business events
Operation recordMerchantEvent
Server SDK recordMerchantEvent
Python record_merchant_event
Go RecordMerchantEventPOST /api/v1/merchant/events/record
Record merchant-reported billing, coupon use, fulfillment, benefit, authorization, usage and balance results through one entry, idempotent by eventId. Non-financial events create no invoices, revenue or spendable Longplay balance and don't change platform usage.
API v1 Updated Nov 6, 2026
On this page
Request# Except for coupon.redeemed, new events require the current App environment's merchant execution mode to be record_only. This is environment configuration, not a request field for this operation.
Save a stable eventId for each merchant event. Retries must reuse the same eventId and identical event content; reusing an eventId with different content returns an idempotency conflict.
Credential Server Key with billing:write. Call from your backend only.
SDK JavaScript createLongplayServer().recordMerchantEvent · Python record_merchant_event · Go RecordMerchantEvent
Success HTTP 200 1 curl -X POST "$LONGPLAY_API_URL/api/v1/merchant/events/record" \2 -H "Authorization: Bearer $LONGPLAY_SERVER_KEY" \ 3 -H "X-Indiana-Protocol: 0.10" \ 4 -H "Content-Type: application/json" \ 5 -d '{ 6 "type" : "purchase.closed" , 7 "eventId" : "merchant-order-123-closed" , 8 "customerId" : "8b258f8b-4228-40fa-8d24-5b16428e686d" , 9 "occurredAt" : "2026-10-03T12:00:00.000Z" , 10 "operationId" : "a8b14e0c-6576-49a4-812c-7a1587e55255" , 11 "status" : "failed" 12 } '
The response shows example data.
Body parameters# application/json eventIdstring | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string Required Event ID used for deduplication; unchanged on retries.
customerIduuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid Required The Customer UUID. Required with a Server Key; omit it with a Customer Token.
occurredAtdate-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time | date-time Required Timestamp (ISO 8601).
type"purchase.completed" | "purchase.closed" | "subscription.observed" | "subscription.change.completed" | "subscription.change.closed" | "invoice.paid" | "refund.updated" | "fulfillment.updated" | "benefit.claimed" | "benefit.closed" | "benefit.updated" | "authorization.updated" | "balance.observed" | "coupon.redeemed" | "coupon.redeemed" | "usage.observed" | "usage.observed" Required Event or operation discriminator selecting the matching request branch.
operationIduuid | uuid | uuid | null | uuid | uuid | uuid | null | uuid Optional Business operation UUID. Subscription execution references operationId from previewAttach; balance refunds reference the original consumption.
merchantOrderIdstring Optional Stable merchant-native order reference binding the original purchase and its replays.
minLength: 1 · maxLength: 200
paymentStatusenum Optional Merchant-verified payment outcome: paid or no payment required.
Show allowed values"paid""trialing""no_payment_required"
invoiceobject | null | object | null | object Optional Invoice.
Show child fieldsmerchantInvoiceIdstring | string | string Required Stable merchant-native invoice reference used to verify invoice facts and replays.
reasonenum | enum | enum Optional Rejection reason or ledger operation description; interpret with accepted and status.
currencystring | string | string Required Currency code supported by the published price.
subtotalMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
discountMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
taxMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
totalMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
paidMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
periodStartsAtdate-time | null | date-time | null | date-time | null Required Timestamp (ISO 8601).
periodEndsAtdate-time | null | date-time | null | date-time | null Required Timestamp (ISO 8601).
linesarray | array | array Required Line items.
Show child fieldsmerchantLineIdstring | string | string | string | string | string Required Stable merchant-native invoice line reference, unique within the invoice.
quantityinteger | integer | integer | integer | integer | integer Required Quantity (integer).
subtotalMinorinteger | integer | integer | integer | integer | integer Required Amount in the currency's minor unit, such as cents.
discountMinorinteger | integer | integer | integer | integer | integer Required Amount in the currency's minor unit, such as cents.
taxMinorinteger | integer | integer | integer | integer | integer Required Amount in the currency's minor unit, such as cents.
totalMinorinteger | integer | integer | integer | integer | integer Required Amount in the currency's minor unit, such as cents.
periodStartsAtdate-time | null | date-time | null | date-time | null | date-time | null | date-time | null | date-time | null Required Timestamp (ISO 8601).
periodEndsAtdate-time | null | date-time | null | date-time | null | date-time | null | date-time | null | date-time | null Required Timestamp (ISO 8601).
priceIduuid | uuid | uuid Optional Longplay Price UUID for this invoice line, matching the original quote.
nativePriceobject | object | object Optional Native price reference on a renewal line, supplied in place of priceId. Confirmed operations use the quoted priceId.
Show child fieldsmerchantPriceIdstring | string | string Required Native price identifier in the merchant catalog, resolved within the current App and environment.
productIdstring | string | string Required Product ID.
kindenum | enum | enum Required Kind; see the allowed values.
currencystring | string | string Required Currency code supported by the published price.
unitAmountMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
intervalenum | enum | enum Required Interval; see the allowed values.
intervalCountinteger | integer | integer Required Stripe Price billing interval count, at most 52.
subscriptionobject | null | object | object Optional Merchant-verified subscription snapshot; null for a purchase without a subscription.
Show child fieldsmerchantSubscriptionIdstring | string | string Required Merchant-native subscription reference represented by this snapshot.
revisioninteger | integer | integer Required Revision of the specific versioned resource; Customer profile updates have no revision.
statusenum | enum | enum Required Status; see the allowed values.
periodStartsAtdate-time | date-time | date-time Required Timestamp (ISO 8601).
periodEndsAtdate-time | date-time | date-time Required Timestamp (ISO 8601).
cancelAtPeriodEndboolean | boolean | boolean Required Whether it cancels at the end of the current period.
hasDiscountsboolean | boolean | boolean Required Whether the merchant subscription has discounts, used to determine whether subsequent changes can use standard pricing.
itemsarray | array | array Required List items.
Show child fieldsmerchantItemIdstring | string | string | string | string | string Required Stable merchant-native subscription item reference used to bind later changes to the original item.
quantityinteger | integer | integer | integer | integer | integer Required Quantity (integer).
priceIduuid | uuid | uuid Optional Longplay Price UUID represented by this subscription item.
nativePriceobject | object | object Optional Native price reference on an autonomous subscription observation, supplied in place of priceId. Confirmed operations use the quoted priceId.
Show child fieldsmerchantPriceIdstring | string | string Required Native price identifier in the merchant catalog, resolved within the current App and environment.
productIdstring | string | string Required Product ID.
kindenum | enum | enum Required Kind; see the allowed values.
currencystring | string | string Required Currency code supported by the published price.
unitAmountMinorinteger | integer | integer Required Amount in the currency's minor unit, such as cents.
intervalenum | enum | enum Required Interval; see the allowed values.
intervalCountinteger | integer | integer Required Stripe Price billing interval count, at most 52.
statusenum | enum | enum | enum | enum | enum | enum | enum Optional Status; see the allowed values.
scheduledFordate-time | null Optional Effective timestamp of the accepted scheduled subscription change, matching its original instruction.
merchantSubscriptionIdstring | string | null Optional Stable merchant-native subscription reference joining subsequent observations for that subscription.
merchantInvoiceIdstring | null | string Optional Stable merchant-native Invoice reference identifying the refunded Invoice for a native refund without an operation, including dispute funds.
merchantRefundIdstring Optional Stable merchant-native refund reference retained across retries of the same refund.
minLength: 1 · maxLength: 200
amountMinorinteger Optional Amount in the currency's minor unit, such as cents.
min: 0 · max: 100000000
currencystring Optional Currency code supported by the published price.
pattern: ^[A-Z]{3}$
merchantFulfillmentIdstring Optional Stable merchant-native fulfilment reference.
minLength: 1 · maxLength: 200
merchantBenefitIdstring | string | string Optional Stable merchant-native benefit reference joining later facts for that benefit.
resourcestring | string | string | string Optional Merchant-native resource reference, such as a credit balance or a model.
unitstring | string | string | string Optional Merchant-native unit of the quantity.
quantityinteger | integer | integer Optional Quantity (integer).
expiresAtdate-time | null | date-time | null Optional Expiry time (ISO 8601, UTC).
revisioninteger | integer | integer | integer | integer Optional Revision of the specific versioned resource; Customer profile updates have no revision.
remainingQuantityinteger | null Optional Quantity left on the benefit, or null when the merchant cannot report it.
merchantAuthorizationIdstring Optional Stable merchant-native authorization reference joining later states of that authorization.
minLength: 1 · maxLength: 200
kind"auto_topup" Optional Kind; see the allowed values.
termsReferencestring | null Optional Merchant-native terms reference bound to this authorization, or null when there is none.
availableQuantityinteger Optional Quantity currently available in the merchant-native balance.
min: 0 · max: 1000000000000
reservedQuantityinteger Optional Quantity reserved in the merchant-native balance and not yet completed.
min: 0 · max: 1000000000000
periodStartsAtdate-time | null Optional Timestamp (ISO 8601).
periodEndsAtdate-time | null Optional Timestamp (ISO 8601).
grantIduuid | uuid Optional grant ID.
productVersionIduuid Optional Product Version ID.
subscriptionIdstring Optional subscription ID.
minLength: 1 · maxLength: 255
merchandiseIduuid Optional Internal UUID of registered merchandise in the current App and environment.
merchantTransactionIdstring | string Optional Stable merchant-native usage transaction reference used to deduplicate the fact.
operation"consume" | "reverse" Optional The operation to run; it selects the other fields.
reversalOfstring Optional Native usage transaction that this reversal undoes.
minLength: 1 · maxLength: 200
Response fields# Every successful response includes requestId (this request's ID, for support) and scope (App and environment).
HTTP 200 · application/json requestIduuid Required UUID the server generated for this HTTP request; include it when reporting a problem. It is not your business requestId.
scopeobject Required The App and environment of this response. Headers only verify scope; they cannot switch key scope.
Show child fieldsprojectIdstring Required App ID bound to the credential.
minLength: 1
environmentenum Required Separate data scope: sandbox or live.
Show allowed values"sandbox""live"
recordobject Required Receipt for the merchant event durably recorded by Longplay.
Show child fieldsiduuid Required Longplay merchant-event record UUID, retained by idempotent replays.
eventIdstring Required Event ID used for deduplication; unchanged on retries.
minLength: 1 · maxLength: 200
source"merchant" Required The merchant source marker identifying facts submitted by the merchant.
providerVerifiedfalse Required Always false: this receipt represents merchant-submitted facts without direct provider verification by Longplay.
outcomestring Required Durable event outcome containing the associated business objects and processing state.
minLength: 1 · maxLength: 100
Errors# Failures return an error object; handle them by error.code and error.recovery. The table lists the errors that follow from this operation's credential, scope and idempotency fields; depending on the request it can also return NOT_FOUND (a referenced resource doesn't exist), NOT_CONFIGURED (a required integration isn't connected) or PAYLOAD_TOO_LARGE. Some refusals, such as insufficient balance, are not errors but a reason in a successful response.
Possible errors code HTTP When recovery INVALID_REQUEST400 The request doesn't match this page's parameters. A missing or malformed protocol header returns UNSUPPORTED_PROTOCOL_VERSION or INVALID_PROTOCOL_VERSION instead. fix_requestUNAUTHENTICATED401 The credential is missing, invalid, expired or revoked. authenticateFORBIDDEN403 The credential lacks billing:write. check_permissionsSCOPE_MISMATCH403 X-Indiana-Project or X-Indiana-Environment doesn't match the credential's App and environment.check_scopeCONFLICT409 The same eventId was sent with different input (reason: IDEMPOTENCY_CONFLICT). resolve_conflictRATE_LIMITED429 Too many requests; wait for Retry-After and retry the same request. retry_same_requestSERVICE_UNAVAILABLE503 The service is temporarily unavailable; retry the same request. retry_same_requestINTERNAL_ERROR500 The outcome is unknown; read the original operation or replay the original ID and input. recover_operation
Possible errors
INVALID_REQUEST
HTTP 400
When The request doesn't match this page's parameters. A missing or malformed protocol header returns UNSUPPORTED_PROTOCOL_VERSION or INVALID_PROTOCOL_VERSION instead.
recovery fix_requestUNAUTHENTICATED
HTTP 401
When The credential is missing, invalid, expired or revoked.
recovery authenticateFORBIDDEN
HTTP 403
When The credential lacks billing:write.
recovery check_permissionsSCOPE_MISMATCH
HTTP 403
When X-Indiana-Project or X-Indiana-Environment doesn't match the credential's App and environment.
recovery check_scopeCONFLICT
HTTP 409
When The same eventId was sent with different input (reason: IDEMPOTENCY_CONFLICT).
recovery resolve_conflictRATE_LIMITED
HTTP 429
When Too many requests; wait for Retry-After and retry the same request.
recovery retry_same_requestSERVICE_UNAVAILABLE
HTTP 503
When The service is temporarily unavailable; retry the same request.
recovery retry_same_requestINTERNAL_ERROR
HTTP 500
When The outcome is unknown; read the original operation or replay the original ID and input.
recovery recover_operationRelated: Error codes and recovery · Request conventions · All operations