Revenue Intelligence

Subscription Items

The Subscription Items API lets you create, update, and delete individual line items within a subscription in ThriveStack. Subscription items represent the specific plans and prices attached to a subscription, enabling granular MRR tracking across products, tiers, and billing intervals.

Create a subscription item

POST https://azure.dev.app.thrivestack.ai/revenue/subscription-items

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
subscription_item_idstringYesYour unique identifier for this subscription item.
subscription_idstringYesID of the parent subscription this item belongs to.
customer_idstringYesCustomer ID in your billing system.
plan_idstringYesIdentifier for the plan associated with this item (e.g. "plan_pro_monthly").
price_idstringYesIdentifier for the specific price variant of the plan.
term_unitstringYesBilling interval unit: "day", "week", "month", or "year".
term_frequencystringYesNumber of term_unit intervals per billing cycle (e.g. "1" for monthly).
start_datestringYesISO 8601 timestamp when the subscription item started.
statusstringYesItem status: "active", "cancelled", or "expired".
quantityintegerYesNumber of units for this line item.
created_datestringNoISO 8601 timestamp when the record was created.
ended_atstringNoISO 8601 timestamp when the item ended or is scheduled to end.
trial_start_datestringNoISO 8601 start of the trial period for this item.
trial_end_datestringNoISO 8601 end of the trial period for this item.
cancelled_atstring|nullNoISO 8601 timestamp when the item was cancelled, or null.
current_period_startstringNoISO 8601 start of the current billing period.
current_period_endstringNoISO 8601 end of the current billing period.
updated_datestringNoISO 8601 timestamp when the record was last updated.

Example

curl -X POST https://azure.dev.app.thrivestack.ai/revenue/subscription-items \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "subscription_item_id": "si_123",
    "subscription_id": "sub_123",
    "customer_id": "cust_123",
    "plan_id": "plan_pro_monthly",
    "price_id": "price_123",
    "term_unit": "month",
    "term_frequency": "1",
    "start_date": "2024-01-15T00:00:00Z",
    "status": "active",
    "quantity": 1,
    "created_date": "2024-01-15T00:00:00Z",
    "ended_at": "2025-01-15T00:00:00Z",
    "trial_start_date": "2024-01-01T00:00:00Z",
    "trial_end_date": "2024-01-14T23:59:59Z",
    "cancelled_at": null,
    "current_period_start": "2024-01-15T00:00:00Z",
    "current_period_end": "2024-02-14T23:59:59Z",
    "updated_date": "2024-01-15T00:00:00Z"
  }'
const response = await fetch(
  'https://azure.dev.app.thrivestack.ai/revenue/subscription-items',
  {
    method: 'POST',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      subscription_item_id: 'si_123',
      subscription_id: 'sub_123',
      customer_id: 'cust_123',
      plan_id: 'plan_pro_monthly',
      price_id: 'price_123',
      term_unit: 'month',
      term_frequency: '1',
      start_date: '2024-01-15T00:00:00Z',
      status: 'active',
      quantity: 1,
      created_date: '2024-01-15T00:00:00Z',
      ended_at: '2025-01-15T00:00:00Z',
      trial_start_date: '2024-01-01T00:00:00Z',
      trial_end_date: '2024-01-14T23:59:59Z',
      cancelled_at: null,
      current_period_start: '2024-01-15T00:00:00Z',
      current_period_end: '2024-02-14T23:59:59Z',
      updated_date: '2024-01-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{}{
    "subscription_item_id": "si_123",
    "subscription_id":      "sub_123",
    "customer_id":          "cust_123",
    "plan_id":              "plan_pro_monthly",
    "price_id":             "price_123",
    "term_unit":            "month",
    "term_frequency":       "1",
    "start_date":           "2024-01-15T00:00:00Z",
    "status":               "active",
    "quantity":             1,
    "created_date":         "2024-01-15T00:00:00Z",
    "ended_at":             "2025-01-15T00:00:00Z",
    "trial_start_date":     "2024-01-01T00:00:00Z",
    "trial_end_date":       "2024-01-14T23:59:59Z",
    "cancelled_at":         nil,
    "current_period_start": "2024-01-15T00:00:00Z",
    "current_period_end":   "2024-02-14T23:59:59Z",
    "updated_date":         "2024-01-15T00:00:00Z",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("POST",
    "https://azure.dev.app.thrivestack.ai/revenue/subscription-items",
    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,
  "subscription_item_id": "si_123"
}

Update a subscription item

PUT https://azure.dev.app.thrivestack.ai/revenue/subscription-items

Request body

FieldTypeRequiredDescription
subscription_item_idstringYesID of the subscription item to update.
subscription_idstringNoUpdated parent subscription ID.
plan_idstringNoUpdated plan identifier.
price_idstringNoUpdated price identifier (e.g. when a price change occurs).
term_unitstringNoUpdated billing interval unit.
term_frequencystringNoUpdated billing interval frequency.
start_datestringNoUpdated ISO 8601 start date.
statusstringNoUpdated status: "active", "cancelled", or "expired".
quantityintegerNoUpdated quantity of units.
current_period_startstringNoUpdated ISO 8601 start of the current billing period.
current_period_endstringNoUpdated ISO 8601 end of the current billing period.
updated_datestringNoISO 8601 timestamp of this update.

Example

curl -X PUT https://azure.dev.app.thrivestack.ai/revenue/subscription-items \
  -H "x-api-key: <Your API Key with Revenue APIs Scope>" \
  -H "Content-Type: application/json" \
  -d '{
    "subscription_item_id": "si_123",
    "subscription_id": "sub_123",
    "plan_id": "plan_pro_monthly",
    "price_id": "price_456",
    "term_unit": "month",
    "term_frequency": "1",
    "start_date": "2024-01-15T00:00:00Z",
    "status": "active",
    "quantity": 2,
    "current_period_start": "2024-01-15T00:00:00Z",
    "current_period_end": "2024-02-14T23:59:59Z",
    "updated_date": "2024-02-01T00:00:00Z"
  }'
const response = await fetch(
  'https://azure.dev.app.thrivestack.ai/revenue/subscription-items',
  {
    method: 'PUT',
    headers: {
      'x-api-key': '<Your API Key with Revenue APIs Scope>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      subscription_item_id: 'si_123',
      subscription_id: 'sub_123',
      plan_id: 'plan_pro_monthly',
      price_id: 'price_456',
      term_unit: 'month',
      term_frequency: '1',
      start_date: '2024-01-15T00:00:00Z',
      status: 'active',
      quantity: 2,
      current_period_start: '2024-01-15T00:00:00Z',
      current_period_end: '2024-02-14T23:59:59Z',
      updated_date: '2024-02-01T00: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{}{
    "subscription_item_id": "si_123",
    "subscription_id":      "sub_123",
    "plan_id":              "plan_pro_monthly",
    "price_id":             "price_456",
    "term_unit":            "month",
    "term_frequency":       "1",
    "start_date":           "2024-01-15T00:00:00Z",
    "status":               "active",
    "quantity":             2,
    "current_period_start": "2024-01-15T00:00:00Z",
    "current_period_end":   "2024-02-14T23:59:59Z",
    "updated_date":         "2024-02-01T00:00:00Z",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("PUT",
    "https://azure.dev.app.thrivestack.ai/revenue/subscription-items",
    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,
  "subscription_item_id": "si_123"
}

Delete a subscription item

DELETE https://azure.dev.app.thrivestack.ai/revenue/subscription-items

Request body

FieldTypeRequiredDescription
subscription_item_idstringYesID of the subscription item to delete.

Example

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

  req, _ := http.NewRequest("DELETE",
    "https://azure.dev.app.thrivestack.ai/revenue/subscription-items",
    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,
  "subscription_item_id": "si_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 — subscription item ID does not exist
429Rate Limit Exceeded
500Server Error — try again later