Revenue Intelligence

Invoices

The Invoices API lets you create, update, and delete billing invoices in ThriveStack. Invoices are linked to customers and can be associated with subscriptions and transactions for full revenue tracking.

Create an invoice

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

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
invoice_idstringYesYour unique identifier for this invoice.
customer_idstringYesCustomer ID in your billing system.
group_idstringYesGroup ID from product telemetry (links billing to product events).
issue_datestringYesISO 8601 timestamp when the invoice was issued.
amountnumberYesTotal invoice amount (e.g., 299.99).
currencystringNoISO 4217 currency code: "USD", "EUR", "GBP". Default: "USD".
due_datestringNoISO 8601 timestamp when payment is due.

Example

curl -X POST https://api.app.thrivestack.ai/revenue/invoices \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_id": "inv_123",
    "customer_id": "cust_123",
    "group_id": "group_123",
    "issue_date": "2024-01-15T00:00:00Z",
    "amount": 299.99,
    "currency": "USD",
    "due_date": "2024-02-15T00:00:00Z"
  }'
const response = await fetch(
  'https://api.app.thrivestack.ai/revenue/invoices',
  {
    method: 'POST',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      invoice_id: 'inv_123',
      customer_id: 'cust_123',
      group_id: 'group_123',
      issue_date: '2024-01-15T00:00:00Z',
      amount: 299.99,
      currency: 'USD',
      due_date: '2024-02-15T00:00:00Z'
    })
  }
);
const data = await response.json();
console.log(data);
package main

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

func main() {
  payload := map[string]interface{}{
    "invoice_id":  "inv_123",
    "customer_id": "cust_123",
    "group_id":    "group_123",
    "issue_date":  "2024-01-15T00:00:00Z",
    "amount":      299.99,
    "currency":    "USD",
    "due_date":    "2024-02-15T00:00:00Z",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("POST",
    "https://api.app.thrivestack.ai/revenue/invoices",
    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,
  "invoice_id": "inv_123"
}

Update an invoice

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

Request body

FieldTypeRequiredDescription
invoice_idstringYesID of the invoice to update.
issue_datestringNoUpdated ISO 8601 issue date.
amountnumberNoUpdated invoice amount.
currencystringNoISO 4217 currency code. Default: "USD".
due_datestringNoUpdated ISO 8601 due date.

Example

curl -X PUT https://api.app.thrivestack.ai/revenue/invoices \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_id": "inv_123",
    "issue_date": "2024-01-15T00:00:00Z",
    "amount": 349.99,
    "currency": "USD",
    "due_date": "2024-02-15T00:00:00Z"
  }'
const response = await fetch(
  'https://api.app.thrivestack.ai/revenue/invoices',
  {
    method: 'PUT',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      invoice_id: 'inv_123',
      issue_date: '2024-01-15T00:00:00Z',
      amount: 349.99,
      currency: 'USD',
      due_date: '2024-02-15T00:00:00Z'
    })
  }
);
const data = await response.json();
console.log(data);
package main

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

func main() {
  payload := map[string]interface{}{
    "invoice_id": "inv_123",
    "issue_date": "2024-01-15T00:00:00Z",
    "amount":     349.99,
    "currency":   "USD",
    "due_date":   "2024-02-15T00:00:00Z",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("PUT",
    "https://api.app.thrivestack.ai/revenue/invoices",
    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,
  "invoice_id": "inv_123"
}

Delete an invoice

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

Request body

FieldTypeRequiredDescription
invoice_idstringYesID of the invoice to delete.

Example

curl -X DELETE https://api.app.thrivestack.ai/revenue/invoices \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_id": "inv_123"
  }'
const response = await fetch(
  'https://api.app.thrivestack.ai/revenue/invoices',
  {
    method: 'DELETE',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      invoice_id: 'inv_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{
    "invoice_id": "inv_123",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("DELETE",
    "https://api.app.thrivestack.ai/revenue/invoices",
    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,
  "invoice_id": "inv_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 — invoice ID does not exist
429Rate Limit Exceeded
500Server Error — try again later