| Method | Endpoint | Description | Requirements |
|---|---|---|---|
| Authentication | |||
| GET | /api/twinfield/redirect | Redirect to Twinfield to start the OAuth 2.0 flow. | None |
| GET | /api/twinfield/callback | Handles the OAuth callback from Twinfield. | `code` query parameter from Twinfield. |
| Customers | |||
| POST | /api/twinfield/customers | Create a new customer. |
JSON body with a `client` object. See example payload:
Note: `company_name` is optional. If not provided, the full name will be used. |
| GET | /api/twinfield/customers/{id} | Get a specific customer by ID. | `id` in URL. |
| Suppliers | |||
| POST | /api/twinfield/suppliers | Create a new supplier. |
JSON body with a `supplier` object. See example payload:
Note: The `iban` field within the `user` object is optional. |
| Transactions | |||
| POST | /api/twinfield/sales-transactions | Create a new sales transaction. |
JSON body with `customerCode` and a `lines` array. See example:
|
| POST | /api/twinfield/purchase-transactions | Create a new purchase transaction. |
JSON body with `invoiceNumber`, `supplierCode`, and a `lines` array. See example:
|
| GET | /api/twinfield/purchase-transactions | Get a list of all purchase transactions. | None |
| GET | /api/twinfield/purchase-transactions/last | Get the last created purchase transaction. | None |