{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/paidnice-com/json-schema/paidnice-com-contact-schema.json",
  "title": "Contact",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paidnice-com-openapi.json#/components/schemas/Contact",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "description": "Paidnice contact id. Use it with get_contact, and as contactId in list_invoices, list_notes and list_actions"
    },
    "name": {
      "type": "string",
      "description": "Contact name, as synced from the accounting system"
    },
    "accountingSystemId": {
      "type": "string",
      "description": "The contact's id in the connected accounting system (Xero or QuickBooks Online)"
    },
    "status": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "ARCHIVED"
      ],
      "description": "ACTIVE contacts are in use. ARCHIVED contacts are archived and are not counted as active"
    },
    "accountNumber": {
      "type": "string",
      "description": "Account number for the contact in the accounting system, when it has one"
    },
    "smsOptedOut": {
      "type": "boolean",
      "description": "True when the contact has opted out of receiving SMS, as recorded in Paidnice"
    },
    "contactPersons": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Contact person id. Pass it back in update_contact_persons to keep or edit this person"
          },
          "isPrimary": {
            "type": "boolean",
            "description": "True for the contact's primary person. There is exactly one primary person per contact"
          },
          "firstName": {
            "type": "string",
            "description": "Person's first name"
          },
          "lastName": {
            "type": "string",
            "description": "Person's last name"
          },
          "email": {
            "type": "string",
            "description": "Person's email address, used for reminder emails"
          },
          "mobileNumber": {
            "type": "string",
            "description": "Mobile number, used for SMS. Any country calling code is held separately in mobileNumberCountryCode"
          },
          "mobileNumberCountryCode": {
            "type": "string",
            "description": "Country calling code for mobileNumber, for example 61, when the number is stored with one"
          },
          "defaultNumber": {
            "type": "string",
            "description": "Landline or default phone number. Any country calling code is held separately in defaultNumberCountryCode"
          },
          "defaultNumberCountryCode": {
            "type": "string",
            "description": "Country calling code for defaultNumber, for example 61, when the number is stored with one"
          },
          "includeInNotifications": {
            "type": "boolean",
            "description": "True when this person receives reminder emails and SMS for the contact"
          },
          "sourceType": {
            "type": "string",
            "enum": [
              "imported",
              "local"
            ],
            "description": "imported: the person is synced from the accounting system (Xero or QuickBooks Online). local: the person exists in Paidnice only and is never synced back"
          }
        },
        "required": [
          "id",
          "isPrimary",
          "includeInNotifications",
          "sourceType"
        ]
      },
      "description": "The people at the contact who receive communications, including the primary person"
    },
    "groupId": {
      "type": "integer",
      "description": "Id of the Paidnice contact group, which decides the policies that apply to the contact"
    },
    "groupTitle": {
      "type": "string",
      "description": "Name of the contact group"
    },
    "assignedUser": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "Paidnice user id. Pass it as userId to update_invoice_assignee or update_contact_assignee"
        },
        "email": {
          "type": "string",
          "description": "The team member's email address"
        },
        "firstName": {
          "type": "string",
          "description": "First name, when set"
        },
        "lastName": {
          "type": "string",
          "description": "Last name, when set"
        }
      },
      "required": [
        "id",
        "email"
      ],
      "description": "The team member who owns the contact, null when unassigned"
    },
    "paymentPromises": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PaymentPromise"
      },
      "description": "Promises to pay across the contact's invoices, newest first. Only present with includePaymentPromises"
    },
    "invoiceQueries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InvoiceQuery"
      },
      "description": "Queries across the contact's invoices, newest first. Only present with includeInvoiceQueries"
    },
    "paymentPlans": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PaymentPlan"
      },
      "description": "Payment plans across the contact's invoices, newest first. Only present with includePaymentPlans"
    }
  },
  "required": [
    "id",
    "name",
    "accountingSystemId",
    "status",
    "smsOptedOut",
    "contactPersons",
    "groupId",
    "groupTitle",
    "assignedUser"
  ],
  "$defs": {
    "InvoiceQuery": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "description": "Paidnice invoice query id"
        },
        "invoiceId": {
          "type": "string",
          "description": "Id of the queried invoice, as used by get_invoice"
        },
        "contactId": {
          "type": "integer",
          "description": "Id of the contact who raised it, as used by get_contact"
        },
        "status": {
          "type": "string",
          "enum": [
            "open",
            "resolved"
          ],
          "description": "open until the team resolves it"
        },
        "reason": {
          "type": "string",
          "enum": [
            "pricing",
            "quantity",
            "quality",
            "not_received",
            "duplicate",
            "other"
          ],
          "description": "Why the customer queried the invoice"
        },
        "detail": {
          "type": "string",
          "description": "What the customer said, required when reason is other"
        },
        "nextAction": {
          "type": "string",
          "description": "What the team plans to do next"
        },
        "dueDate": {
          "type": "string",
          "description": "YYYY-MM-DD in the organisation's timezone, when the next action is due"
        },
        "source": {
          "type": "string",
          "enum": [
            "user",
            "portal",
            "ai_agent",
            "escalation",
            "call"
          ],
          "description": "Where the query was raised"
        },
        "resolution": {
          "type": "string",
          "enum": [
            "paid",
            "credit_note",
            "voided",
            "withdrawn",
            "written_off"
          ],
          "description": "How it was resolved, once resolved"
        },
        "createdAt": {
          "type": "string",
          "description": "When the query was raised"
        },
        "resolvedAt": {
          "type": "string",
          "description": "When it was resolved"
        }
      },
      "required": [
        "id",
        "invoiceId",
        "contactId",
        "status",
        "reason",
        "source",
        "createdAt"
      ]
    },
    "PaymentPlan": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "description": "Paidnice payment plan id"
        },
        "invoiceId": {
          "type": "string",
          "description": "Id of the invoice the plan pays off, as used by get_invoice"
        },
        "contactId": {
          "type": "integer",
          "description": "Id of the contact on the plan, as used by get_contact"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "completed"
          ],
          "description": "active while any instalment is not fully paid, completed once all are"
        },
        "originalDueAmount": {
          "type": "number",
          "description": "The invoice amount due when the plan was set up, in the invoice currency"
        },
        "surchargeAmount": {
          "type": "number",
          "description": "Fee added to the invoice for the plan, if any"
        },
        "createdAt": {
          "type": "string",
          "description": "When the plan was set up"
        },
        "instalments": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "description": "Paidnice instalment id"
              },
              "amount": {
                "type": "number",
                "description": "Amount due for this instalment"
              },
              "paidAmount": {
                "type": "number",
                "description": "Amount paid towards this instalment so far"
              },
              "dueDate": {
                "type": "string",
                "description": "YYYY-MM-DD the instalment is due"
              },
              "paidDate": {
                "type": "string",
                "description": "YYYY-MM-DD a payment was first applied to it"
              }
            },
            "required": [
              "id",
              "amount",
              "paidAmount",
              "dueDate"
            ]
          },
          "description": "In due date order. Amounts are in the invoice currency"
        }
      },
      "required": [
        "id",
        "invoiceId",
        "contactId",
        "status",
        "originalDueAmount",
        "createdAt",
        "instalments"
      ]
    },
    "PaymentPromise": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "description": "Paidnice promise to pay id"
        },
        "invoiceId": {
          "type": "string",
          "description": "Id of the invoice it is for, as used by get_invoice"
        },
        "contactId": {
          "type": "integer",
          "description": "Id of the contact who made it, as used by get_contact"
        },
        "status": {
          "type": "string",
          "enum": [
            "open",
            "kept",
            "broken",
            "cancelled"
          ],
          "description": "open until the promised date passes or the invoice is paid, then kept or broken. cancelled when withdrawn"
        },
        "promisedAmount": {
          "type": "number",
          "description": "In the invoice currency"
        },
        "promisedDate": {
          "type": "string",
          "description": "YYYY-MM-DD in the organisation's timezone"
        },
        "notes": {
          "type": "string",
          "description": "Internal notes recorded with the promise. Never shown to the customer"
        },
        "source": {
          "type": "string",
          "enum": [
            "user",
            "portal",
            "escalation",
            "call",
            "ai_agent"
          ],
          "description": "Where the promise was recorded"
        },
        "createdAt": {
          "type": "string",
          "description": "When the promise was recorded"
        },
        "resolvedAt": {
          "type": "string",
          "description": "When it became kept, broken or cancelled"
        }
      },
      "required": [
        "id",
        "invoiceId",
        "contactId",
        "status",
        "promisedAmount",
        "promisedDate",
        "source",
        "createdAt"
      ]
    }
  }
}