Twinfield API Documentation

Integration with Twinfield accounting system

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:

{
    "client": {
        "company_name": "Example Company",
        "first_name": "John",
        "middle_name": "van",
        "last_name": "Doe",
        "postal_code": "1234AB",
        "city": "Anytown",
        "phone": "0612345678",
        "email": "john.doe@example.com"
    }
}

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:

{
    "supplier": {
        "supplierCode": "S12345",
        "name": "Example Supplier Inc.",
        "user": {
            "email": "contact@example.com",
            "first_name": "John",
            "last_name": "Doe",
            "street_name": "Main Street",
            "house_number": "10",
            "city": "Anytown",
            "postal_code": "12345",
            "iban": "NL12ABCD1234567890"
        }
    }
}

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:

{
    "customerCode": "CUST123",
    "lines": [
        {
            "article": "ART001",
            "quantity": 2,
            "value_excl": 100.00
        },
        {
            "article": "ART002",
            "quantity": 1,
            "value_excl": 50.50
        }
    ]
}
POST /api/twinfield/purchase-transactions Create a new purchase transaction.

JSON body with `invoiceNumber`, `supplierCode`, and a `lines` array. See example:

{
    "invoiceNumber": "INV-2025-001",
    "supplierCode": "SUPPLIER456",
    "lines": [
        {
            "article": "SERV01",
            "quantity": 10,
            "value_excl": 75.00
        }
    ]
}
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