Revenue Intelligence

Transactions

The Transactions API lets you create, update, and delete payment transaction records in ThriveStack. Transactions represent individual payment events — charges or refunds — tied to customers and invoices.

Create a transaction

POST https://api.app.thrivestack.ai/revenue/transactions

Authentication

Pass your API key in the x-api-key header. Your key must have the Revenue APIs scope enabled.

x-api-key: <Your API Key with Revenue APIs Scope>

Request body

FieldTypeRequiredDescription
transaction_idstringYesYour unique identifier for this transaction.
customer_idstringYesCustomer ID in your billing system. Can be the same as group_id.
group_idstringYesGroup ID from product telemetry (links billing to product events).
customer_namestringNoDisplay name of the customer.
invoice_idstringNoID of the associated invoice.
typestringYes"payment" or "refund".
statusstringYes"paid", "cancelled", "failed", "refund", or "charged_back".
transaction_datestringYesISO 8601 timestamp when the transaction occurred.
amountnumberYesTransaction amount (e.g., 99.99).
currencystringNoISO 4217 currency code: "USD", "EUR", "GBP". Default: "USD".
payment_methodstringNo"credit_card", "paypal", or "stripe".
transaction_feenumberNoProcessing fee charged by the payment gateway.
tax_amountnumberNoTax applied to this transaction.
discount_amountnumberNoDiscount applied before billing.
term_frequencyintegerNoNumber of term_unit intervals in the billing period. Default: 1.
term_unitstringNo"day", "week", "month", or "year". Default: "month".
period_start_datestringNoISO 8601 start of the billing period.
period_end_datestringNoISO 8601 end of the billing period.
line_item_typestringYes"subscription" for recurring revenue, or "one_time" for setup or professional charges.

Example

curl -X POST https://api.app.thrivestack.ai/revenue/transactions \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_id": "txn_123",
    "customer_id": "cust_123",
    "group_id": "group_456",
    "customer_name": "John Doe",
    "invoice_id": "inv_123",
    "type": "payment",
    "status": "paid",
    "transaction_date": "2024-01-15T14:30:00Z",
    "amount": 99.99,
    "currency": "USD",
    "payment_method": "credit_card",
    "transaction_fee": 2.99,
    "tax_amount": 5.00,
    "discount_amount": 10.00,
    "term_frequency": 1,
    "term_unit": "month",
    "period_start_date": "2024-01-01T00:00:00Z",
    "period_end_date": "2024-01-31T23:59:59Z",
    "line_item_type": "subscription"
  }'
const response = await fetch(
  'https://api.app.thrivestack.ai/revenue/transactions',
  {
    method: 'POST',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      transaction_id: 'txn_123',
      customer_id: 'cust_123',
      group_id: 'group_456',
      customer_name: 'John Doe',
      invoice_id: 'inv_123',
      type: 'payment',
      status: 'paid',
      transaction_date: '2024-01-15T14:30:00Z',
      amount: 99.99,
      currency: 'USD',
      payment_method: 'credit_card',
      transaction_fee: 2.99,
      tax_amount: 5.00,
      discount_amount: 10.00,
      term_frequency: 1,
      term_unit: 'month',
      period_start_date: '2024-01-01T00:00:00Z',
      period_end_date: '2024-01-31T23:59:59Z',
      line_item_type: 'subscription'
    })
  }
);
const data = await response.json();
console.log(data);
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "io"
  "net/http"
)

func main() {
  payload := map[string]interface{}{
    "transaction_id":   "txn_123",
    "customer_id":      "cust_123",
    "group_id":         "group_456",
    "customer_name":    "John Doe",
    "invoice_id":       "inv_123",
    "type":             "payment",
    "status":           "paid",
    "transaction_date": "2024-01-15T14:30:00Z",
    "amount":           99.99,
    "currency":         "USD",
    "payment_method":   "credit_card",
    "transaction_fee":  2.99,
    "tax_amount":       5.00,
    "discount_amount":  10.00,
    "term_frequency":   1,
    "term_unit":        "month",
    "period_start_date": "2024-01-01T00:00:00Z",
    "period_end_date":   "2024-01-31T23:59:59Z",
    "line_item_type":   "subscription",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("POST",
    "https://api.app.thrivestack.ai/revenue/transactions",
    bytes.NewBuffer(body))
  req.Header.Set("x-api-key", "<Your API Key with Revenue APIs Scope>")
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer resp.Body.Close()
  result, _ := io.ReadAll(resp.Body)
  fmt.Println(string(result))
}

Response

{
  "success": true,
  "transaction_id": "txn_123"
}

Update a transaction

PUT https://api.app.thrivestack.ai/revenue/transactions

Request body

FieldTypeRequiredDescription
transaction_idstringYesID of the transaction to update.
statusstringNo"paid", "cancelled", "failed", "refund", or "charged_back".
typestringNo"payment" or "refund".
datestringNoISO 8601 updated transaction date.
amountnumberNoUpdated transaction amount.
currencystringNoISO 4217 currency code. Default: "USD".
payment_methodstringNo"credit_card", "paypal", or "stripe".
transaction_feenumberNoUpdated processing fee.
tax_amountnumberNoUpdated tax amount.
discount_amountnumberNoUpdated discount amount.
term_frequencyintegerNoBilling period frequency. Default: 1.
term_unitstringNo"day", "week", "month", or "year". Default: "month".
period_start_datestringNoISO 8601 start of the billing period.
period_end_datestringNoISO 8601 end of the billing period.
line_item_typestringNo"subscription" or "one_time".

Example

curl -X PUT https://api.app.thrivestack.ai/revenue/transactions \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_id": "txn_123",
    "status": "paid",
    "type": "payment",
    "date": "2024-01-20T10:30:00Z",
    "amount": 149.99,
    "currency": "USD",
    "payment_method": "credit_card",
    "transaction_fee": 3.50,
    "tax_amount": 7.50,
    "discount_amount": 15.00,
    "term_frequency": 1,
    "term_unit": "month",
    "period_start_date": "2024-01-01T00:00:00Z",
    "period_end_date": "2024-01-31T23:59:59Z",
    "line_item_type": "subscription"
  }'
const response = await fetch(
  'https://api.app.thrivestack.ai/revenue/transactions',
  {
    method: 'PUT',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      transaction_id: 'txn_123',
      status: 'paid',
      type: 'payment',
      date: '2024-01-20T10:30:00Z',
      amount: 149.99,
      currency: 'USD',
      payment_method: 'credit_card',
      transaction_fee: 3.50,
      tax_amount: 7.50,
      discount_amount: 15.00,
      term_frequency: 1,
      term_unit: 'month',
      period_start_date: '2024-01-01T00:00:00Z',
      period_end_date: '2024-01-31T23:59:59Z',
      line_item_type: 'subscription'
    })
  }
);
const data = await response.json();
console.log(data);
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "io"
  "net/http"
)

func main() {
  payload := map[string]interface{}{
    "transaction_id":   "txn_123",
    "status":           "paid",
    "type":             "payment",
    "date":             "2024-01-20T10:30:00Z",
    "amount":           149.99,
    "currency":         "USD",
    "payment_method":   "credit_card",
    "transaction_fee":  3.50,
    "tax_amount":       7.50,
    "discount_amount":  15.00,
    "term_frequency":   1,
    "term_unit":        "month",
    "period_start_date": "2024-01-01T00:00:00Z",
    "period_end_date":   "2024-01-31T23:59:59Z",
    "line_item_type":   "subscription",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("PUT",
    "https://api.app.thrivestack.ai/revenue/transactions",
    bytes.NewBuffer(body))
  req.Header.Set("x-api-key", "<Your API Key with Revenue APIs Scope>")
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer resp.Body.Close()
  result, _ := io.ReadAll(resp.Body)
  fmt.Println(string(result))
}

Response

{
  "success": true,
  "transaction_id": "txn_123"
}

Delete a transaction

DELETE https://api.app.thrivestack.ai/revenue/transactions

Request body

FieldTypeRequiredDescription
transaction_idstringYesID of the transaction to delete.

Example

curl -X DELETE https://api.app.thrivestack.ai/revenue/transactions \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_id": "txn_123"
  }'
const response = await fetch(
  'https://api.app.thrivestack.ai/revenue/transactions',
  {
    method: 'DELETE',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      transaction_id: 'txn_123'
    })
  }
);
const data = await response.json();
console.log(data);
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "io"
  "net/http"
)

func main() {
  payload := map[string]string{
    "transaction_id": "txn_123",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("DELETE",
    "https://api.app.thrivestack.ai/revenue/transactions",
    bytes.NewBuffer(body))
  req.Header.Set("x-api-key", "<Your API Key with Revenue APIs Scope>")
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer resp.Body.Close()
  result, _ := io.ReadAll(resp.Body)
  fmt.Println(string(result))
}

Response

{
  "success": true,
  "transaction_id": "txn_123"
}

Error codes

StatusMeaning
400Bad Request — invalid JSON or missing required fields
401Unauthorized — invalid or missing API key, or key lacks Revenue APIs scope
404Not Found — transaction ID does not exist
429Rate Limit Exceeded
500Server Error — try again later