{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "CustomerInput.json",
  "title": "Customer (request)",
  "description": "Body for creating or updating a customer. On update, every field is optional and only the fields you send change.",
  "type": "object",
  "properties": {
    "customerType": {
      "type": "string",
      "enum": [
        "individual",
        "company"
      ],
      "description": "individual or company. Defaults to individual on create."
    },
    "email": {
      "type": "string",
      "description": "A valid email address. Required on create."
    },
    "firstName": {
      "type": "string",
      "description": "Required for individuals."
    },
    "lastName": {
      "type": "string",
      "description": "Required for individuals."
    },
    "phone": {
      "type": "string",
      "description": "Required and must be valid for individuals. Optional for companies, but must be valid if sent."
    },
    "companyName": {
      "type": "string",
      "description": "Required for companies."
    },
    "legalName": {
      "type": "string",
      "description": "Registered legal name. Used as the billing name when set."
    },
    "address": {
      "type": "string",
      "description": "Postal address."
    },
    "taxId": {
      "type": "string",
      "description": "TIN. Another customer in the organization can't have the same one."
    },
    "vatNumber": {
      "type": "string",
      "description": "VAT registration number."
    },
    "rcNumber": {
      "type": "string",
      "description": "CAC registration (RC) number."
    },
    "externalRef": {
      "type": "string",
      "description": "Your id for the customer. At most 100 characters, unique within the organization."
    },
    "parentCustomerId": {
      "type": "integer",
      "format": "int32",
      "description": "A customer in the same organization. Can't be the customer itself, or a customer whose parent is this one."
    },
    "regulatedEntityCount": {
      "type": "integer",
      "format": "int32",
      "description": "0 or more."
    },
    "defaultCurrency": {
      "type": "string",
      "enum": [
        "NGN",
        "USD",
        "CAD",
        "EUR",
        "GBP"
      ],
      "description": "A supported currency code."
    },
    "defaultSettlementBankId": {
      "type": "integer",
      "format": "int32",
      "description": "One of the organization's bank account ids, from the Flux app."
    },
    "contacts": {
      "type": "array",
      "items": {
        "$ref": "ContactInput.json"
      },
      "description": "At most 20, each with a valid email, and at most one primary. On update, sending contacts replaces the whole list. Leave it out to keep the current contacts."
    }
  },
  "required": [
    "email"
  ],
  "examples": [
    {
      "customerType": "company",
      "companyName": "Leadway Group",
      "legalName": "Leadway Group Plc",
      "email": "finance@leadway.example",
      "phone": "+2348012345678",
      "address": "121 Funso Williams Ave, Lagos",
      "taxId": "12345678-0001",
      "vatNumber": "VAT-001",
      "rcNumber": "RC123456",
      "externalRef": "ws_42",
      "regulatedEntityCount": 3,
      "defaultCurrency": "NGN",
      "contacts": [
        {
          "name": "Finance",
          "email": "finance@leadway.example",
          "isBillingPrimary": true,
          "ccOnInvoices": false
        },
        {
          "name": "CFO",
          "email": "cfo@leadway.example",
          "isBillingPrimary": false,
          "ccOnInvoices": true
        }
      ]
    }
  ]
}
