> ## Documentation Index
> Fetch the complete documentation index at: https://docs2.zenskar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Reference

## Authentication reference

Every tool invocation requires two parameters. The server resolves them in this order:

1. Values passed directly in the tool call (highest priority)
2. `ZENSKAR_ORGANIZATION` environment variable
3. `ZENSKAR_AUTH_TOKEN` environment variable

**Token format detection is automatic:**

| Token format                | Header sent                     |
| --------------------------- | ------------------------------- |
| Looks like a JWT (`eyJ...`) | `Authorization: Bearer <token>` |
| Any other format            | `x-api-key: <token>`            |

No credentials are stored or logged by the server.

***

## Tool reference (103 operations)

### Customers, Contacts & Addresses

#### Customers

| Tool              | Description                                           |
| ----------------- | ----------------------------------------------------- |
| `listCustomers`   | List customers with search, filtering, and pagination |
| `getCustomerById` | Get a single customer by ID                           |
| `createCustomer`  | Create a customer with address and tax information    |
| `updateCustomer`  | Partially update customer details                     |

#### Contacts

| Tool             | Description                     |
| ---------------- | ------------------------------- |
| `listContacts`   | List contacts with pagination   |
| `getContactById` | Get a single contact by ID      |
| `createContact`  | Create a contact for a customer |
| `updateContact`  | Update a contact's details      |

#### Customer Addresses

| Tool                    | Description                         |
| ----------------------- | ----------------------------------- |
| `listCustomerAddresses` | List addresses for a customer       |
| `createCustomerAddress` | Add an address to a customer        |
| `updateCustomerAddress` | Update an existing customer address |

#### Payment Methods

| Tool                  | Description                           |
| --------------------- | ------------------------------------- |
| `listPaymentMethods`  | List payment methods for a customer   |
| `attachPaymentMethod` | Attach a payment method to a customer |

***

### Contracts

| Tool                         | Description                                                |
| ---------------------------- | ---------------------------------------------------------- |
| `listContracts`              | List contracts; filter by status, customer, and dates      |
| `getContractById`            | Get a contract with phases, pricings, and customer details |
| `createContract`             | Create a contract with phases and pricing                  |
| `updateContract`             | Update contract terms, status, pricing, or renewal policy  |
| `deleteContract`             | Delete a draft contract                                    |
| `getContractAmendments`      | Get the amendment history for a contract                   |
| `createContractPhase`        | Add a phase to a contract (add-ons, expansions)            |
| `createContractPhasePricing` | Add pricing to a contract phase                            |
| `expireContract`             | Expire an active contract                                  |
| `createContractPrompt`       | Create a contract prompt                                   |
| `extractContractFromRaw`     | Extract structured contract data from raw text using AI    |

***

### Invoices & Credit Notes

#### Invoices

| Tool                               | Description                                               |
| ---------------------------------- | --------------------------------------------------------- |
| `listInvoices`                     | List invoices; filter by customer, status, and dates      |
| `getInvoiceById`                   | Get an invoice by ID                                      |
| `getInvoiceByExternalId`           | Get an invoice by external ID                             |
| `getInvoiceGenerationStatus`       | Check the status of an async invoice generation job       |
| `downloadInvoice`                  | Download invoice data in JSON format                      |
| `getInvoiceContractJsonActuals`    | Get contract actuals associated with an invoice           |
| `getInvoicePayments`               | Get successful payments mapped to an invoice              |
| `getInvoicePaymentsById`           | Get successful payments for a specific invoice ID         |
| `getInvoicePaymentsWithoutRefunds` | Get original payment records, excluding refund rows       |
| `getInvoiceLineItems`              | Get line items and pricing details for an invoice         |
| `getInvoiceSummary`                | Get a summary view of an invoice                          |
| `getAllInvoiceTags`                | Get all available invoice tags                            |
| `generateInvoicePaymentLink`       | Generate a hosted payment link for an invoice             |
| `payInvoice`                       | Initiate payment for an invoice                           |
| `approveInvoice`                   | Approve an invoice for billing                            |
| `voidInvoice`                      | Void an approved, unpaid invoice                          |
| `generateInvoice`                  | Generate an invoice for a contract and date range         |
| `createInvoiceCreditNote`          | Create a credit note against an invoice                   |
| `createInvoiceCharge`              | Auto-charge an invoice via the configured payment gateway |

#### Credit Notes

| Tool                | Description                       |
| ------------------- | --------------------------------- |
| `listCreditNotes`   | List credit notes with pagination |
| `getCreditNoteById` | Get a credit note by ID           |

***

### Payments

| Tool                  | Description                                                   |
| --------------------- | ------------------------------------------------------------- |
| `listAllPayments`     | List all payments with filtering, sorting, and refund records |
| `getPaymentById`      | Get a payment by ID                                           |
| `createPayment`       | Record a manual payment against an invoice                    |
| `updatePayment`       | Update a payment's invoice allocations (`payment_parts`)      |
| `deleteManualPayment` | Delete a manual payment                                       |
| `editManualPayment`   | Edit a manual payment's amount or payment method              |
| `refundPayment`       | Refund a payment in full or partially                         |

***

### Products, Plans & Quotes

#### Products

| Tool                   | Description                                      |
| ---------------------- | ------------------------------------------------ |
| `listProducts`         | List products in the catalog                     |
| `getProductById`       | Get a product by ID                              |
| `createProduct`        | Create a product                                 |
| `updateProduct`        | Update a product's details                       |
| `getProductPricings`   | Get all pricing configurations for a product     |
| `createProductPricing` | Create a new pricing configuration for a product |

#### Plans (Templates)

| Tool                  | Description                                        |
| --------------------- | -------------------------------------------------- |
| `listPlans`           | List plan templates                                |
| `getPlanById`         | Get a plan by ID, including phases and pricing     |
| `createPlan`          | Create a plan template                             |
| `addProductsToPlan`   | Add products to an existing plan                   |
| `previewPlanEstimate` | Preview estimated billing for a plan configuration |

#### Quotes

| Tool                   | Description                                 |
| ---------------------- | ------------------------------------------- |
| `createQuote`          | Create a quote or proposal                  |
| `previewQuoteEstimate` | Preview estimated billing for a quote       |
| `getQuoteById`         | Get a quote by ID                           |
| `acceptQuote`          | Accept a quote, converting it to a contract |

***

### Accounting

| Tool                 | Description                                        |
| -------------------- | -------------------------------------------------- |
| `getChartOfAccounts` | Get the full chart of accounts                     |
| `listAccounts`       | List GL accounts with filtering                    |
| `createAccount`      | Create a GL account                                |
| `listJournalEntries` | List journal entries with filtering                |
| `createJournalEntry` | Create a manual journal entry                      |
| `getJournalEntry`    | Get a journal entry by ID with all its lines       |
| `listJournalLines`   | List journal lines across all entries              |
| `getBalanceSheet`    | Get the balance sheet report                       |
| `getIncomeStatement` | Get the income statement (P\&L)                    |
| `getAccountBalance`  | Get the balance for a specific GL account          |
| `recogniseRevenue`   | Trigger revenue recognition up to a specified date |

***

### Metrics, Events & Other

#### Billable Metrics (Aggregates)

| Tool                    | Description                          |
| ----------------------- | ------------------------------------ |
| `listAggregates`        | List billable metrics with filtering |
| `getAggregateSchemas`   | Show schemas for billable metrics    |
| `getAggregateEstimates` | Get estimates for a billable metric  |
| `getAggregateById`      | Get a billable metric by ID          |
| `getAggregateLogs`      | Get logs for a billable metric       |

#### Usage Events (Raw Metrics)

| Tool                   | Description                             |
| ---------------------- | --------------------------------------- |
| `listRawMetrics`       | List usage events with filtering        |
| `createRawMetric`      | Create a usage event schema             |
| `getRawMetricById`     | Get a usage event by ID                 |
| `getRawMetricLogs`     | Get recent event rows for a usage event |
| `getRawMetricBySlug`   | Get a usage event by API slug           |
| `ingestRawMetricEvent` | Ingest a usage event into the system    |

#### Custom Attributes & Tax

| Tool                    | Description                          |
| ----------------------- | ------------------------------------ |
| `listCustomAttributes`  | List custom attribute definitions    |
| `createCustomAttribute` | Create a custom attribute definition |
| `listTaxCategories`     | List tax categories                  |
| `createTaxCategory`     | Create a tax category                |

#### Business Entities

| Tool                    | Description                 |
| ----------------------- | --------------------------- |
| `listBusinessEntities`  | List business entities      |
| `getBusinessEntityById` | Get a business entity by ID |
| `createBusinessEntity`  | Create a business entity    |
| `updateBusinessEntity`  | Update a business entity    |

#### Jobs & Utilities

| Tool                             | Description                                                     |
| -------------------------------- | --------------------------------------------------------------- |
| `listJobs`                       | List async jobs (invoice generation, revenue recognition, etc.) |
| `getJobById`                     | Get a job by ID to check its current status                     |
| `createEntitlement`              | Create an entitlement                                           |
| `getCustomerPortalConfiguration` | Get the customer portal configuration                           |
| `getCurrentDateTime`             | Get the current date and time in multiple formats               |

***
