Invoices

Create

Creates an invoice.

POST /invoices
const response = await client.invoices.create(
  {
    invoice_id: 'invoice_2024_001',
    line_items: [
      {
        amount: '1000',
        currency_code: 'USD',
        description: 'Professional services for January 2026',
        product_id: 'prod_1234567890',
        type: 'payout',
        user: { id: 'user_abc123' }
      }
    ]
  }
);
Parameters
NameDescription
invoice_idstring, required

Unique ID for the invoice.

line_itemsobject[], required

Line items to create with the invoice.

tagsobject[]

Tags for the invoice.

Response
NameDescription
dataobject

Invoice object.

{
  "data": {
    "id": "inv_1234567890",
    "workspace_id": "ws_1234567890",
    "line_items": [
      {
        "id": "item_1234567890",
        "type": "payout",
        "product_id": "prod_1234567890",
        "price": {
          "amount": "1000",
          "unit_price": "1000",
          "quantity": 1
        },
        "currency_code": "USD",
        "description": "Professional services for January 2026",
        "user_id": "user_ext_456",
        "tags": [
          {
            "key": "department",
            "value": "engineering"
          }
        ]
      }
    ],
    "created": "2024-01-13T00:00:00Z",
    "modified": "2024-01-13T00:00:00Z",
    "version": 1,
    "tags": [
      {
        "key": "department",
        "value": "engineering"
      }
    ]
  }
}

List

Lists all invoices.

GET /invoices
const response = await client.invoices.list();
Response
NameDescription
dataobject[]

List of invoices.

{
  "data": [
    {
      "id": "inv_1234567890",
      "workspace_id": "ws_1234567890",
      "line_items": [
        {
          "id": "item_1234567890",
          "type": "payout",
          "product_id": "prod_1234567890",
          "price": {
            "amount": "1000",
            "unit_price": "1000",
            "quantity": 1
          },
          "currency_code": "USD",
          "description": "Professional services for January 2026",
          "user_id": "user_ext_456",
          "tags": [
            {
              "key": "department",
              "value": "engineering"
            }
          ]
        }
      ],
      "created": "2024-01-13T00:00:00Z",
      "modified": "2024-01-13T00:00:00Z",
      "version": 1,
      "tags": [
        {
          "key": "department",
          "value": "engineering"
        }
      ]
    }
  ]
}

List History

Retrieves the version history of an invoice.

GET /invoices/{id}/history
const response = await client.invoices.listHistory('inv_1234567890');
Parameters
NameDescription
idstring, required

Unique identifier for the invoice.

Response
NameDescription
dataobject[]

Version history of the invoice.

{
  "data": [
    {
      "id": "inv_1234567890",
      "workspace_id": "ws_1234567890",
      "line_items": [
        {
          "id": "item_1234567890",
          "type": "payout",
          "product_id": "prod_1234567890",
          "price": {
            "amount": "1000",
            "unit_price": "1000",
            "quantity": 1
          },
          "currency_code": "USD",
          "description": "Professional services for January 2026",
          "user_id": "user_ext_456",
          "tags": [
            {
              "key": "department",
              "value": "engineering"
            }
          ]
        }
      ],
      "created": "2024-01-13T00:00:00Z",
      "modified": "2024-01-13T00:00:00Z",
      "version": 1,
      "tags": [
        {
          "key": "department",
          "value": "engineering"
        }
      ]
    }
  ]
}

Retrieve

Retrieves an invoice.

GET /invoices/{id}
const response = await client.invoices.retrieve('inv_1234567890');
Parameters
NameDescription
idstring, required

Unique identifier for the invoice.

Response
NameDescription
dataobject

Invoice object.

{
  "data": {
    "id": "inv_1234567890",
    "workspace_id": "ws_1234567890",
    "line_items": [
      {
        "id": "item_1234567890",
        "type": "payout",
        "product_id": "prod_1234567890",
        "price": {
          "amount": "1000",
          "unit_price": "1000",
          "quantity": 1
        },
        "currency_code": "USD",
        "description": "Professional services for January 2026",
        "user_id": "user_ext_456",
        "tags": [
          {
            "key": "department",
            "value": "engineering"
          }
        ]
      }
    ],
    "created": "2024-01-13T00:00:00Z",
    "modified": "2024-01-13T00:00:00Z",
    "version": 1,
    "tags": [
      {
        "key": "department",
        "value": "engineering"
      }
    ],
    "users": [
      {
        "id": "user_ext_789",
        "external_id": "user_ext_789",
        "balances": [
          {
            "payins": {
              "expected": "10000",
              "actual": "5000",
              "remaining": "5000"
            },
            "payouts": {
              "expected": "10000",
              "actual": "5000",
              "remaining": "5000"
            },
            "net": {
              "expected": "10000",
              "actual": "5000",
              "remaining": "5000"
            },
            "currency": "USD"
          }
        ]
      }
    ],
    "balances": [
      {
        "payins": {
          "expected": "10000",
          "actual": "5000",
          "remaining": "5000"
        },
        "payouts": {
          "expected": "10000",
          "actual": "5000",
          "remaining": "5000"
        },
        "net": {
          "expected": "10000",
          "actual": "5000",
          "remaining": "5000"
        },
        "currency": "USD"
      }
    ],
    "payments": [
      {
        "amount": "150",
        "currency": "USD",
        "transaction": {
          "id": "txn_dHhuX2ZyYWdfMDAx",
          "external_id": "bank_txn_123",
          "tags": [
            {
              "key": "department",
              "value": "engineering"
            }
          ]
        },
        "type": "payin",
        "posted": "2024-01-13T00:00:00Z",
        "user": {
          "id": "user_abc123",
          "external_id": "user_ext_001"
        }
      }
    ]
  }
}

Update

Updates an invoice.

PATCH /invoices/{id}
const response = await client.invoices.update(
  'inv_1234567890',
  {
    current_invoice_version: 3,
    line_items: {
      update: [
        {
          id: 'li_1234567890',
          price: { amount: '2000' }
        }
      ]
    },
    tags: { set: [{ key: 'department', value: 'engineering' }] }
  }
);
Parameters
NameDescription
idstring, required

Unique identifier for the invoice.

current_invoice_versionnumber, required

Current version of the invoice. Must match the stored version.

tagsobject

Tag updates.

line_itemsobject

Line item updates.

Response
NameDescription
dataobject

Invoice object.

{
  "data": {
    "id": "inv_1234567890",
    "workspace_id": "ws_1234567890",
    "line_items": [
      {
        "id": "item_1234567890",
        "type": "payout",
        "product_id": "prod_1234567890",
        "price": {
          "amount": "1000",
          "unit_price": "1000",
          "quantity": 1
        },
        "currency_code": "USD",
        "description": "Professional services for January 2026",
        "user_id": "user_ext_456",
        "tags": [
          {
            "key": "department",
            "value": "engineering"
          }
        ]
      }
    ],
    "created": "2024-01-13T00:00:00Z",
    "modified": "2024-01-13T00:00:00Z",
    "version": 1,
    "tags": [
      {
        "key": "department",
        "value": "engineering"
      }
    ]
  }
}