Moloni ON Logo WhiteGuidesAPI ReferenceExplorer
Guides

Customers

Customers are the counterparties you bill, and every sales document (invoice, receipt, credit note, etc.) is issued to a customer. Each company maintains its own customer list.

The default customer

Every company has a default customer (isDefault: true). It is used as a fallback when creating documents without a specific customer and represents generic/anonymous billing (e.g. cash sales). There is exactly one default customer per company, and it cannot be deleted.

Required fields

When creating a customer, three things are required:

FieldTypeNotes
numberString!Unique reference code within the company
countryIdInt!The customer's country
name or vatStringAt least one must be provided

Creating a customer

mutation {
  customerCreate(
    companyId: 1
    data: {
      number: "C001"
      name: "Acme Corporation"
      vat: "123456789"
      countryId: 1
      email: "billing@acme.com"
      phone: "+351 210 000 000"
      address: "Rua Exemplo, 1"
      city: "Lisboa"
      zipCode: "1000-001"
    }
  ) {
    data {
      customerId
      number
      name
      vat
    }
    errors { field msg }
  }
}

Billing defaults

You can attach billing preferences to a customer at creation or update time. When a document is created for this customer, these defaults are pre-filled:

FieldDescription
paymentMethodIdDefault payment method (cash, transfer, etc.)
maturityDateIdDefault payment terms / due date rule
deliveryMethodIdDefault delivery method
documentSetIdDefault document set (numbering series)
priceClassIdDefault price class for product pricing
discountGlobal discount percentage applied to all line items
creditLimitMaximum outstanding balance allowed
paymentDayDay of the month when payment is expected
taxesArray of default taxes to apply to this customer's documents
exemptionReasonVAT exemption reason code (required when tax-exempt)
notesOnDocsWhether to include documentNotes on every document
documentNotesText printed on every document for this customer

Getting a customer

query {
  customer(companyId: 1, customerId: 42) {
    data {
      customerId
      number
      name
      vat
      email
      phone
      address
      city
      zipCode
      balance
      creditLimit
      discount
      country { name }
      paymentMethod { name }
      maturityDate { name }
      taxes {
        tax { name value }
        cumulative
        ordering
      }
    }
    errors { field msg }
  }
}

Listing and searching customers

query {
  customers(
    companyId: 1
    options: {
      search: { field: ALL, value: "Acme" }
      pagination: { page: 1, qty: 20 }
      order: { field: name, sort: ASC }
    }
  ) {
    data {
      customerId
      number
      name
      vat
      email
      balance
    }
    options {
      pagination { page qty count }
    }
    errors { field msg }
  }
}

Search fields

You can search by a specific field or use ALL to search across all of them:

field valueSearches in
ALLName, number, VAT, email, phone, contact, address, alternate addresses
nameCustomer name
numberCustomer reference number
vatVAT / tax number
emailEmail address
addressStreet address
cityCity
zipCodePostal code
phonePhone number
contactNamePrimary contact name

Filtering

Use filter to narrow results by exact field values:

query {
  customers(
    companyId: 1
    options: {
      filter: [
        { field: countryId, comparison: EQ, value: "1" }
        { field: visible, comparison: EQ, value: "1" }
      ]
      pagination: { page: 1, qty: 20 }
    }
  ) {
    data {
      customerId
      name
    }
    options {
      pagination { page qty count }
    }
  }
}

See Filtering & Search for full details on filter syntax.

Updating a customer

Only the fields you send are updated, everything else stays unchanged. customerId is required to identify the record:

mutation {
  customerUpdate(
    companyId: 1
    data: {
      customerId: 42
      email: "new@acme.com"
      creditLimit: 5000.00
      discount: 10
    }
  ) {
    data {
      customerId
      email
      creditLimit
      discount
    }
    errors { field msg }
  }
}

Deleting customers

The customerDelete mutation accepts an array of IDs, so you can delete multiple customers in one call. It returns a summary with how many were deleted and any errors:

mutation {
  customerDelete(companyId: 1, customerId: [42, 43]) {
    status
    deletedCount
    elementsCount
    errors { field msg }
  }
}

Retrieve all documents issued to a customer with getCustomerRelatedDocuments:

query {
  getCustomerRelatedDocuments(
    companyId: 1
    customerId: 42
    options: {
      pagination: { page: 1, qty: 20 }
    }
  ) {
    data {
      documentId
      documentTypeId
      number
      date
      totalValue
      status
    }
    options {
      pagination { page qty count }
    }
  }
}

Alternate addresses

Customers can have multiple shipping/delivery addresses stored as alternateAddresses. These are returned as an array on the customer object and can be passed on individual documents to override the default billing address.

Next steps

© 2026 Moloni ON

Tax Authority Certificate No. 3075