Skip to content
Longplay
Docs
Browse docs / Record merchant business events
On this page

Record merchant business events

Operation
recordMerchantEvent
Server SDK
recordMerchantEvent
Python
record_merchant_event
Go
RecordMerchantEvent
POST/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.

Markdown
API v1Updated

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
request.shShell
curl -X POST "$LONGPLAY_API_URL/api/v1/merchant/events/record" \  -H "Authorization: Bearer $LONGPLAY_SERVER_KEY" \  -H "X-Indiana-Protocol: 0.10" \  -H "Content-Type: application/json" \  -d '{  "type": "purchase.closed",  "eventId": "merchant-order-123-closed",  "customerId": "8b258f8b-4228-40fa-8d24-5b16428e686d",  "occurredAt": "2026-10-03T12:00:00.000Z",  "operationId": "a8b14e0c-6576-49a4-812c-7a1587e55255",  "status": "failed"}'

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 | stringRequired

Event ID used for deduplication; unchanged on retries.

customerIduuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuid | uuidRequired

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-timeRequired

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 | uuidOptional

Business operation UUID. Subscription execution references operationId from previewAttach; balance refunds reference the original consumption.

merchantOrderIdstringOptional

Stable merchant-native order reference binding the original purchase and its replays.

minLength: 1 · maxLength: 200

paymentStatusenumOptional

Merchant-verified payment outcome: paid or no payment required.

Show allowed values

"paid""trialing""no_payment_required"

invoiceobject | null | object | null | objectOptional

Invoice.

Show child fields
merchantInvoiceIdstring | string | stringRequired

Stable merchant-native invoice reference used to verify invoice facts and replays.

reasonenum | enum | enumOptional

Rejection reason or ledger operation description; interpret with accepted and status.

currencystring | string | stringRequired

Currency code supported by the published price.

subtotalMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

discountMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

taxMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

totalMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

paidMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

periodStartsAtdate-time | null | date-time | null | date-time | nullRequired

Timestamp (ISO 8601).

periodEndsAtdate-time | null | date-time | null | date-time | nullRequired

Timestamp (ISO 8601).

linesarray | array | arrayRequired

Line items.

Show child fields
merchantLineIdstring | string | string | string | string | stringRequired

Stable merchant-native invoice line reference, unique within the invoice.

quantityinteger | integer | integer | integer | integer | integerRequired

Quantity (integer).

subtotalMinorinteger | integer | integer | integer | integer | integerRequired

Amount in the currency's minor unit, such as cents.

discountMinorinteger | integer | integer | integer | integer | integerRequired

Amount in the currency's minor unit, such as cents.

taxMinorinteger | integer | integer | integer | integer | integerRequired

Amount in the currency's minor unit, such as cents.

totalMinorinteger | integer | integer | integer | integer | integerRequired

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 | nullRequired

Timestamp (ISO 8601).

periodEndsAtdate-time | null | date-time | null | date-time | null | date-time | null | date-time | null | date-time | nullRequired

Timestamp (ISO 8601).

priceIduuid | uuid | uuidOptional

Longplay Price UUID for this invoice line, matching the original quote.

nativePriceobject | object | objectOptional

Native price reference on a renewal line, supplied in place of priceId. Confirmed operations use the quoted priceId.

Show child fields
merchantPriceIdstring | string | stringRequired

Native price identifier in the merchant catalog, resolved within the current App and environment.

productIdstring | string | stringRequired

Product ID.

kindenum | enum | enumRequired

Kind; see the allowed values.

currencystring | string | stringRequired

Currency code supported by the published price.

unitAmountMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

intervalenum | enum | enumRequired

Interval; see the allowed values.

intervalCountinteger | integer | integerRequired

Stripe Price billing interval count, at most 52.

subscriptionobject | null | object | objectOptional

Merchant-verified subscription snapshot; null for a purchase without a subscription.

Show child fields
merchantSubscriptionIdstring | string | stringRequired

Merchant-native subscription reference represented by this snapshot.

revisioninteger | integer | integerRequired

Revision of the specific versioned resource; Customer profile updates have no revision.

statusenum | enum | enumRequired

Status; see the allowed values.

periodStartsAtdate-time | date-time | date-timeRequired

Timestamp (ISO 8601).

periodEndsAtdate-time | date-time | date-timeRequired

Timestamp (ISO 8601).

cancelAtPeriodEndboolean | boolean | booleanRequired

Whether it cancels at the end of the current period.

hasDiscountsboolean | boolean | booleanRequired

Whether the merchant subscription has discounts, used to determine whether subsequent changes can use standard pricing.

itemsarray | array | arrayRequired

List items.

Show child fields
merchantItemIdstring | string | string | string | string | stringRequired

Stable merchant-native subscription item reference used to bind later changes to the original item.

quantityinteger | integer | integer | integer | integer | integerRequired

Quantity (integer).

priceIduuid | uuid | uuidOptional

Longplay Price UUID represented by this subscription item.

nativePriceobject | object | objectOptional

Native price reference on an autonomous subscription observation, supplied in place of priceId. Confirmed operations use the quoted priceId.

Show child fields
merchantPriceIdstring | string | stringRequired

Native price identifier in the merchant catalog, resolved within the current App and environment.

productIdstring | string | stringRequired

Product ID.

kindenum | enum | enumRequired

Kind; see the allowed values.

currencystring | string | stringRequired

Currency code supported by the published price.

unitAmountMinorinteger | integer | integerRequired

Amount in the currency's minor unit, such as cents.

intervalenum | enum | enumRequired

Interval; see the allowed values.

intervalCountinteger | integer | integerRequired

Stripe Price billing interval count, at most 52.

statusenum | enum | enum | enum | enum | enum | enum | enumOptional

Status; see the allowed values.

scheduledFordate-time | nullOptional

Effective timestamp of the accepted scheduled subscription change, matching its original instruction.

merchantSubscriptionIdstring | string | nullOptional

Stable merchant-native subscription reference joining subsequent observations for that subscription.

merchantInvoiceIdstring | null | stringOptional

Stable merchant-native Invoice reference identifying the refunded Invoice for a native refund without an operation, including dispute funds.

merchantRefundIdstringOptional

Stable merchant-native refund reference retained across retries of the same refund.

minLength: 1 · maxLength: 200

amountMinorintegerOptional

Amount in the currency's minor unit, such as cents.

min: 0 · max: 100000000

currencystringOptional

Currency code supported by the published price.

pattern: ^[A-Z]{3}$

merchantFulfillmentIdstringOptional

Stable merchant-native fulfilment reference.

minLength: 1 · maxLength: 200

merchantBenefitIdstring | string | stringOptional

Stable merchant-native benefit reference joining later facts for that benefit.

resourcestring | string | string | stringOptional

Merchant-native resource reference, such as a credit balance or a model.

unitstring | string | string | stringOptional

Merchant-native unit of the quantity.

quantityinteger | integer | integerOptional

Quantity (integer).

expiresAtdate-time | null | date-time | nullOptional

Expiry time (ISO 8601, UTC).

revisioninteger | integer | integer | integer | integerOptional

Revision of the specific versioned resource; Customer profile updates have no revision.

remainingQuantityinteger | nullOptional

Quantity left on the benefit, or null when the merchant cannot report it.

merchantAuthorizationIdstringOptional

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 | nullOptional

Merchant-native terms reference bound to this authorization, or null when there is none.

availableQuantityintegerOptional

Quantity currently available in the merchant-native balance.

min: 0 · max: 1000000000000

reservedQuantityintegerOptional

Quantity reserved in the merchant-native balance and not yet completed.

min: 0 · max: 1000000000000

periodStartsAtdate-time | nullOptional

Timestamp (ISO 8601).

periodEndsAtdate-time | nullOptional

Timestamp (ISO 8601).

grantIduuid | uuidOptional

grant ID.

productVersionIduuidOptional

Product Version ID.

subscriptionIdstringOptional

subscription ID.

minLength: 1 · maxLength: 255

merchandiseIduuidOptional

Internal UUID of registered merchandise in the current App and environment.

merchantTransactionIdstring | stringOptional

Stable merchant-native usage transaction reference used to deduplicate the fact.

operation"consume" | "reverse"Optional

The operation to run; it selects the other fields.

reversalOfstringOptional

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

requestIduuidRequired

UUID the server generated for this HTTP request; include it when reporting a problem. It is not your business requestId.

scopeobjectRequired

The App and environment of this response. Headers only verify scope; they cannot switch key scope.

Show child fields
projectIdstringRequired

App ID bound to the credential.

minLength: 1

environmentenumRequired

Separate data scope: sandbox or live.

Show allowed values

"sandbox""live"

recordobjectRequired

Receipt for the merchant event durably recorded by Longplay.

Show child fields
iduuidRequired

Longplay merchant-event record UUID, retained by idempotent replays.

eventIdstringRequired

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.

providerVerifiedfalseRequired

Always false: this receipt represents merchant-submitted facts without direct provider verification by Longplay.

outcomestringRequired

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
codeHTTPWhenrecovery
INVALID_REQUEST400The request doesn't match this page's parameters. A missing or malformed protocol header returns UNSUPPORTED_PROTOCOL_VERSION or INVALID_PROTOCOL_VERSION instead.fix_request
UNAUTHENTICATED401The credential is missing, invalid, expired or revoked.authenticate
FORBIDDEN403The credential lacks billing:write.check_permissions
SCOPE_MISMATCH403X-Indiana-Project or X-Indiana-Environment doesn't match the credential's App and environment.check_scope
CONFLICT409The same eventId was sent with different input (reason: IDEMPOTENCY_CONFLICT).resolve_conflict
RATE_LIMITED429Too many requests; wait for Retry-After and retry the same request.retry_same_request
SERVICE_UNAVAILABLE503The service is temporarily unavailable; retry the same request.retry_same_request
INTERNAL_ERROR500The 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_request
  • UNAUTHENTICATED

    HTTP
    401
    When
    The credential is missing, invalid, expired or revoked.
    recovery
    authenticate
  • FORBIDDEN

    HTTP
    403
    When
    The credential lacks billing:write.
    recovery
    check_permissions
  • SCOPE_MISMATCH

    HTTP
    403
    When
    X-Indiana-Project or X-Indiana-Environment doesn't match the credential's App and environment.
    recovery
    check_scope
  • CONFLICT

    HTTP
    409
    When
    The same eventId was sent with different input (reason: IDEMPOTENCY_CONFLICT).
    recovery
    resolve_conflict
  • RATE_LIMITED

    HTTP
    429
    When
    Too many requests; wait for Retry-After and retry the same request.
    recovery
    retry_same_request
  • SERVICE_UNAVAILABLE

    HTTP
    503
    When
    The service is temporarily unavailable; retry the same request.
    recovery
    retry_same_request
  • INTERNAL_ERROR

    HTTP
    500
    When
    The outcome is unknown; read the original operation or replay the original ID and input.
    recovery
    recover_operation

Related: Error codes and recovery·Request conventions·All operations