Skip to main content
This API allows you to create and manage invoices for your account. Invoices represent billing documents sent to customers with line items for products and services.

The invoice object

id
string
Unique identifier with inv_ prefix (e.g., inv_abc123def456).
customer_id
string
The customer’s ID associated with this invoice.
subscription_id
string
The associated subscription ID. null for standalone invoices.
status
string
Invoice status: pending, paid, overdue, or canceled.
due_date
string
The invoice due date (format: YYYY-MM-DD).
total_amount
string
Total amount for the invoice.
line_items
array
Array of line items on the invoice.
created_at
string
When the invoice was created (ISO 8601).
updated_at
string
When the invoice was last updated (ISO 8601).

List invoices

GET /v1/invoices
Retrieves a paginated list of all invoices in your account.
page
integer
default:"1"
Page number for pagination. Results are returned 25 items per page.
curl https://api.gettrxn.com/v1/invoices \
  -H "Authorization: Bearer $TRXN_TOKEN"
Response
{
  "invoices": [
    {
      "id": "inv_abc123def456",
      "customer_id": "cus_xyz789",
      "subscription_id": null,
      "status": "pending",
      "due_date": "2025-02-28",
      "total_amount": "199.98",
      "created_at": "2025-01-15T12:00:00Z",
      "updated_at": "2025-01-15T12:00:00Z",
      "line_items": [
        {
          "id": "li_item123",
          "price_id": "pri_abc123",
          "product_id": "pro_xyz789",
          "product_name": "Premium Plan",
          "quantity": 2,
          "unit_amount": "99.99",
          "amount": "199.98"
        }
      ]
    }
  ],
  "pagination": {
    "page": 1,
    "pages": 3,
    "count": 67
  }
}

Get invoice

GET /v1/invoices/:id
Retrieves a specific invoice by ID with all line items.
id
string
required
The invoice’s ID (e.g., inv_abc123def456).
curl https://api.gettrxn.com/v1/invoices/inv_abc123def456 \
  -H "Authorization: Bearer $TRXN_TOKEN"
Response
{
  "id": "inv_abc123def456",
  "customer_id": "cus_xyz789",
  "subscription_id": "sub_def456",
  "status": "pending",
  "due_date": "2025-02-28",
  "total_amount": "99.99",
  "created_at": "2025-01-15T12:00:00Z",
  "updated_at": "2025-01-15T12:00:00Z",
  "line_items": [
    {
      "id": "li_item123",
      "price_id": "pri_abc123",
      "product_id": "pro_xyz789",
      "product_name": "Premium Plan",
      "quantity": 1,
      "unit_amount": "99.99",
      "amount": "99.99"
    }
  ]
}

Create invoice

POST /v1/invoices
Creates a new invoice with optional line items.
customer_id
string
required
The customer’s ID (e.g., cus_xyz789). Must belong to your account.
due_date
string
required
The invoice due date (format: YYYY-MM-DD).
status
string
default:"pending"
Invoice status. One of: pending, paid, overdue, canceled.
subscription_id
string
Associated subscription ID.
line_items
array
Array of line item objects.
curl -X POST https://api.gettrxn.com/v1/invoices \
  -H "Authorization: Bearer $TRXN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cus_xyz789",
    "due_date": "2025-02-28",
    "line_items": [
      {"price_id": "pri_abc123", "quantity": 2}
    ]
  }'
Response
{
  "id": "inv_new123invoice456",
  "customer_id": "cus_xyz789",
  "subscription_id": null,
  "status": "pending",
  "due_date": "2025-02-28",
  "total_amount": "199.98",
  "created_at": "2025-01-15T14:30:00Z",
  "updated_at": "2025-01-15T14:30:00Z",
  "line_items": [
    {
      "id": "li_new123",
      "price_id": "pri_abc123",
      "product_id": "pro_xyz789",
      "product_name": "Premium Plan",
      "quantity": 2,
      "unit_amount": "99.99",
      "amount": "199.98"
    }
  ]
}

Error responses

Customer not found
{
  "error": "Customer not found"
}
Price not found
{
  "error": "Price not found: pri_invalid123"
}

Update invoice

PATCH /v1/invoices/:id
Updates an existing invoice’s status or due date.
id
string
required
The invoice’s ID.
status
string
Invoice status. One of: pending, paid, overdue, canceled.
due_date
string
The invoice due date (format: YYYY-MM-DD).
curl -X PATCH https://api.gettrxn.com/v1/invoices/inv_abc123def456 \
  -H "Authorization: Bearer $TRXN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "paid"
  }'
Response
{
  "id": "inv_abc123def456",
  "customer_id": "cus_xyz789",
  "status": "paid",
  "due_date": "2025-02-28",
  "total_amount": "99.99",
  "created_at": "2025-01-15T12:00:00Z",
  "updated_at": "2025-01-16T10:00:00Z",
  "line_items": [...]
}

Delete invoice

DELETE /v1/invoices/:id
Deletes an invoice from your account.
id
string
required
The invoice’s ID.
curl -X DELETE https://api.gettrxn.com/v1/invoices/inv_abc123def456 \
  -H "Authorization: Bearer $TRXN_TOKEN"
Returns 204 No Content on successful deletion.

Invoice status values

StatusDescription
pendingInvoice has been created but not yet paid.
paidInvoice has been fully paid.
overdueInvoice is past its due date.
canceledInvoice has been canceled.

Usage flow

  1. Create a customer using the Customers API.
  2. Create products and prices using the Products and Prices APIs.
  3. Create an invoice with line items referencing your prices.
  4. Send the invoice to your customer (via your application).
  5. Update status to paid when payment is received.
  6. Track overdue invoices and follow up as needed.

Integration example

# 1. Create a customer
curl -X POST https://api.gettrxn.com/v1/customers \
  -H "Authorization: Bearer $TRXN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]"}'

# Response: {"id": "cus_abc123", ...}

# 2. Create an invoice for the customer
curl -X POST https://api.gettrxn.com/v1/invoices \
  -H "Authorization: Bearer $TRXN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cus_abc123",
    "due_date": "2025-02-28",
    "line_items": [
      {"price_id": "pri_monthly_plan", "quantity": 1}
    ]
  }'

# 3. Mark invoice as paid when payment received
curl -X PATCH https://api.gettrxn.com/v1/invoices/inv_xyz789 \
  -H "Authorization: Bearer $TRXN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status": "paid"}'

Sandbox support

The API respects sandbox scoping. If your API token is associated with a sandbox, you can only access invoices created in that sandbox. Invoices created in sandbox mode will be isolated from production data.