> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.transxact.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.transxact.io/_mcp/server.

# Create an Invoice

POST https://api.transxact.io/v1/invoices
Content-Type: application/json

Creates a draft Invoice in the key's mode. It has no number and no working `url` until you send it. The total, with tax, must be under FJD 5,000.00 (at most 499999 cents), in Test mode and Live mode alike. The `Idempotency-Key` header is required: a retry with the same key returns the original draft instead of making a second.

Reference: https://docs.transxact.io/api-reference/invoices/create

## Authentication

- `Authorization` header (bearer token, required) — Your secret key: sk_test_... in Test mode, sk_live_... in Live mode.

## Request

### Headers

- `idempotency-key` (string, required) — Client-generated key; a repeated key returns the original result instead of repeating the change.

### Body (application/json)

This endpoint expects a CreateInvoiceRequest.

- `customerName` (string, required) — Who you are billing, up to 100 characters.
- `dueDate` (string, required) — `YYYY-MM-DD`, Pacific/Fiji.
- `items` (list of InvoiceItem, required) — 1 to 50 line items, entered excluding tax.
- `customerEmail` (string, optional) — Optional until you email the Invoice from the dashboard.
- `taxLabel` (string, optional) — Label for the one optional tax line, such as `VAT`. Needs `taxPercent`.
- `taxPercent` (double, optional) — Tax as a percentage of the subtotal, up to 100 with 2 decimal places.
- `vatNumber` (string, optional) — Your VAT number, if you are registered.

## Response

### 201

Draft created, or replayed from the Idempotency-Key.

- `id` (integer, required) — Invoice identifier.
- `number` (string, required, nullable) — The Invoice number, such as `INV-0007`. Assigned when the Invoice is sent, so a draft has none; numbers are never reused.
- `status` (enum, required) — `draft` until sent and editable only from the dashboard. `sent`: the Customer can pay it. `paid`: paid in full. `void`: you voided it; it can no longer be paid.
  - Allowed values: `draft`, `sent`, `paid`, `void`
- `overdue` (boolean, required) — A sent, unpaid Invoice past its due date (Pacific/Fiji). Derived, not a status; the Customer can still pay.
- `mode` (enum, required) — `test` for an Invoice made with an `sk_test_` key, `live` for an `sk_live_` key.
  - Allowed values: `test`, `live`
- `customerName` (string, required) — Who you billed.
- `customerEmail` (string, required, nullable) — The Customer's email, if you gave one.
- `items` (list of InvoiceItem, required) — The line items, excluding tax.
- `taxLabel` (string, required, nullable) — Label of the tax line; null if none.
- `taxPercent` (double, required) — 0 when there is no tax line.
- `vatNumber` (string, required, nullable) — Your VAT number, if you gave one.
- `dueDate` (string, required) — `YYYY-MM-DD`, Pacific/Fiji.
- `subtotal` (integer, required) — Sum of the line items, in FJD cents (minor units).
- `tax` (integer, required) — The tax line, in FJD cents (minor units).
- `total` (integer, required) — Amount due; under FJD 5,000.00, in FJD cents (minor units).
- `url` (string, required) — The hosted page the Customer opens and pays on. Works once the Invoice is sent.
- `pdfUrl` (string, required, nullable) — Where to `GET` the PDF, with your secret key. Null on a draft.
- `createdAt` (integer, required) — Unix ms timestamp the draft was created.
- `sentAt` (integer, required, nullable) — Unix ms timestamp it was sent; null on a draft.
- `paidAt` (integer, required, nullable) — Unix ms timestamp it was paid; null until then.

## Errors

### 400 Bad Request Error

Invalid request (`invalid_request`), including a total of FJD 5,000.00 or more.

- `error` (ErrorError, required) — Branch on `code`; `message` is for logs.

### 401 Unauthorized Error

Invalid or missing API key.

- `error` (ErrorError, required) — Branch on `code`; `message` is for logs.

### 403 Forbidden Error

The account is not a Business account (`business_only`).

- `error` (ErrorError, required) — Branch on `code`; `message` is for logs.

## Types

### InvoiceItem

- `description` (string, required) — What it is, up to 200 characters.
- `quantity` (integer, required) — Whole units, 1 to 9999.
- `unitPrice` (integer, required) — Price of one unit, excluding tax, in FJD cents (minor units).

### ErrorError

Branch on `code`; `message` is for logs.

- `code` (string, required) — Stable machine-readable error code.
- `message` (string, required) — Human-readable detail, not contractual.

## Examples

**Request**

```json
{
  "customerName": "Mere Tuilagi",
  "dueDate": "2026-11-30",
  "items": [
    {
      "description": "Tiling, kitchen",
      "quantity": 2,
      "unitPrice": 12000
    }
  ]
}
```

**Response**

```json
{
  "id": 42,
  "number": "INV-0007",
  "status": "sent",
  "overdue": false,
  "mode": "test",
  "customerName": "Mere Tuilagi",
  "customerEmail": "mere@example.com",
  "items": [
    {
      "description": "Tiling, kitchen",
      "quantity": 2,
      "unitPrice": 12000
    }
  ],
  "taxLabel": "VAT",
  "taxPercent": 15,
  "vatNumber": null,
  "dueDate": "2026-11-30",
  "subtotal": 24000,
  "tax": 3600,
  "total": 27600,
  "url": "https://transxact.io/i/k3j2h1g0f9e8d7c6",
  "pdfUrl": "https://api.transxact.io/v1/invoices/42/pdf",
  "createdAt": 1717086400000,
  "sentAt": 1717086400000,
  "paidAt": null
}
```

**SDK Code**

```python
import requests

url = "https://api.transxact.io/v1/invoices"

payload = {
    "customerName": "Mere Tuilagi",
    "dueDate": "2026-11-30",
    "items": [
        {
            "description": "Tiling, kitchen",
            "quantity": 2,
            "unitPrice": 12000
        }
    ]
}
headers = {
    "idempotency-key": "a1b2c3d4-order-9912",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.transxact.io/v1/invoices';
const options = {
  method: 'POST',
  headers: {
    'idempotency-key': 'a1b2c3d4-order-9912',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"customerName":"Mere Tuilagi","dueDate":"2026-11-30","items":[{"description":"Tiling, kitchen","quantity":2,"unitPrice":12000}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.transxact.io/v1/invoices"

	payload := strings.NewReader("{\n  \"customerName\": \"Mere Tuilagi\",\n  \"dueDate\": \"2026-11-30\",\n  \"items\": [\n    {\n      \"description\": \"Tiling, kitchen\",\n      \"quantity\": 2,\n      \"unitPrice\": 12000\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("idempotency-key", "a1b2c3d4-order-9912")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.transxact.io/v1/invoices")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["idempotency-key"] = 'a1b2c3d4-order-9912'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"customerName\": \"Mere Tuilagi\",\n  \"dueDate\": \"2026-11-30\",\n  \"items\": [\n    {\n      \"description\": \"Tiling, kitchen\",\n      \"quantity\": 2,\n      \"unitPrice\": 12000\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.transxact.io/v1/invoices")
  .header("idempotency-key", "a1b2c3d4-order-9912")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customerName\": \"Mere Tuilagi\",\n  \"dueDate\": \"2026-11-30\",\n  \"items\": [\n    {\n      \"description\": \"Tiling, kitchen\",\n      \"quantity\": 2,\n      \"unitPrice\": 12000\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.transxact.io/v1/invoices', [
  'body' => '{
  "customerName": "Mere Tuilagi",
  "dueDate": "2026-11-30",
  "items": [
    {
      "description": "Tiling, kitchen",
      "quantity": 2,
      "unitPrice": 12000
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'idempotency-key' => 'a1b2c3d4-order-9912',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.transxact.io/v1/invoices");
var request = new RestRequest(Method.POST);
request.AddHeader("idempotency-key", "a1b2c3d4-order-9912");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customerName\": \"Mere Tuilagi\",\n  \"dueDate\": \"2026-11-30\",\n  \"items\": [\n    {\n      \"description\": \"Tiling, kitchen\",\n      \"quantity\": 2,\n      \"unitPrice\": 12000\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "idempotency-key": "a1b2c3d4-order-9912",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerName": "Mere Tuilagi",
  "dueDate": "2026-11-30",
  "items": [
    [
      "description": "Tiling, kitchen",
      "quantity": 2,
      "unitPrice": 12000
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.transxact.io/v1/invoices")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```