# Create An Invoice

> Solarium docs, Invoices. All requests are `POST https://api.trysolarium.com/graphql/` with `Authorization: Bearer <api key>` and a JSON body `{"query": ..., "variables": ...}`. Every query and mutation takes an `organizationId` (find it with `myOrganizations`). Index of all pages: https://trysolarium.com/llms.txt

A draft invoice. Lines are before tax. Tax is worked out from each line's sales_tax_code at the rates where the customer is, on the issue date.

### Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organizationId` | `UUID!` | Yes | Organization ID |
| `name` | `String!` | Yes | "create_invoice" |
| `params.customer_name` | `String` | No | Finds or adds the customer (or pass contact_id). On update_invoice it must match a customer you already have |
| `params.customer_email` | `String` | No | Who the invoice is emailed to: one or more emails, comma-separated. Saved on the customer, so the next invoice and reminders go there too |
| `params.customer_region` | `String` | No | The customer's province, as a code (NS) or its name. Saved on the customer. Tax follows it: a Nova Scotia customer pays Nova Scotia HST, and a customer in a GST-only province pays GST alone. Leave it out to tax at your own province's rates |
| `params.lines` | `[Object!]!` | Yes | Each: description, unit_price, quantity (default 1), revenue_account_id, sales_tax_code (one of your tax options from invoice_settings, e.g. hst in Ontario, st_ny in New York), tax_amount (needed where tax isn't worked out from a rate, like US sales tax) |
| `params.terms_days` | `Int` | No | Days to pay (default 30) |
| `params.currency` | `String` | No | CAD, USD, EUR, GBP, AUD or JPY. Default: the customer's usual currency, else your books' own |
| `params.fx_rate` | `String` | No | Other currencies: your books' currency per 1 of the invoice's (1.3684). Default: the Bank of Canada rate on the issue date |
| `params.number` | `String` | No | Only to use your own number |
| `params.trade_name` | `String` | No | The trade name this invoice leads with, instead of the one in invoice_settings. An empty string prints your legal name alone. Default: the settings' trade name. On update_invoice, use_default_trade_name: true goes back to it |
| `apply` | `Boolean` | No | true to keep it |

### Request

```graphql
mutation {
  runOp(
    organizationId: "a1b2c3d4-..."
    name: "create_invoice"
    apply: true
    params: {
      customer_name: "Milda K"
      customer_email: "milda@example.com"
      terms_days: 15
      lines: [{ description: "October retainer", unit_price: "1000.00", sales_tax_code: "hst" }]
    }
  ) { success applied result }
}
```

### Response

```json
{
  "data": {
    "runOp": {
      "success": true,
      "applied": true,
      "result": {
        "summary": "Draft Invoice For Milda K: CAD 1130.00 (Tax 130.00).",
        "data": { "invoice_id": "9f3c...", "status": "draft", "subtotal": "1000.00", "tax_total": "130.00", "total": "1130.00" }
      }
    }
  }
}
```
