Handle Twitch Bits purchases of products that you offer through your extension.

📘

Offering products through Twitch

Use the Twitch Developer Rig to create a set of purchasable products, using the Twitch Extension Bits Monetization API.

Twitch sends a notification when users purchase products that you offer. Listening for these events lets you implement a fulfillment process. Your event-handler callback can make this call to validate, record, and broadcast the transaction.

POST Request

The bits/transaction resource handles validation and storage of bits transactions, and broadcasts the transaction to all listening GameLink clients for the current channel.

POST /v1/e/bits/transactions

The body of the POST request contains a JSON-encoded object with parameter values passed in from the event notification.

{
    "transactionReceipt": receipt,
    "displayName": string
}
ParameterValue
transactionReceiptString. The transaction receipt JWT.
displayNameString. The display name of the user who initiated the transaction.

Generally, the call to this endpoint should apply JSON.stringify() to the transaction as given from the
twitch.ext.bits.onTransactionComplete() callback. To prevent multiple submits to this endpoint,
it should be guarded to only validate if the initiator is the current user:

twitch.ext.bits.onTransactionComplete((tx) => {
  if (tx.initiator.toLowerCase() === "current_user") {
    this.sdk.signedRequest("POST", "bits/transactions", JSON.stringify(tx));
  }
});

Response

When you make this call, the server attempts to parse the transaction receipt. On success, it records the transaction; the body of the response is empty.

If parsing fails, the response body contains an error report.