{
  "openapi": "3.0.1",
  "info": {
    "title": "Contact Management",
    "description": "This portion of the API provides endpoints for managing contact records, including addresses, contact details, and associations between contacts.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.ezyvet.com",
      "description": "ezyVet production environment"
    },
    {
      "url": "https://api.trial.ezyvet.com",
      "description": "ezyVet trial environment"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "Address",
      "description": "Addresses associated with a contact record"
    },
    {
      "name": "Communication",
      "description": "Records of communications with a contact — email, SMS, phone call, in-person conversation or letter — including their content and delivery status."
    },
    {
      "name": "Contact",
      "description": "Manages contact records for clients, owners, or other associated individuals."
    },
    {
      "name": "Contact V2",
      "description": "An updated version of contact management with additional features or fields."
    },
    {
      "name": "Contact V4",
      "description": "Contact management for customers, vets, suppliers and businesses. Version 4.0 uses token\npagination and returns each contact's addresses, emails, phones and subscriptions as nested\nobjects.\n\nFilterable columns on `GET /v4/contact` and the shapes they accept:\n\n| Column    | Accepted value                                                  |\n|-----------|-----------------------------------------------------------------|\n| id        | scalar — exact match                                            |\n| active    | scalar — exact match (`0` or `1`)                                |\n| code      | scalar — exact match                                            |\n| name      | scalar — exact match                                            |\n| createdAt | URL-encoded JSON comparator object (`eq`/`gt`/`lt`/`gte`/`lte`) |\n| updatedAt | URL-encoded JSON comparator object (`eq`/`gt`/`lt`/`gte`/`lte`) |\n\nOnly `createdAt` and `updatedAt` accept the comparator object described in the\n[filtering guide](https://developers.ezyvet.com/guides/api-filtering.html); note that v4 date\nfilters take RFC-3339 instants (`2024-05-17T13:00:00Z`), not the Unix epoch values shown\nthere. Every other filter is scalar exact-match only — sending a comparator object for one is\nnot supported.\n"
    },
    {
      "name": "Contact Association",
      "description": "Manages relationships or associations between contacts (e.g., owner and emergency contact)."
    },
    {
      "name": "Contact Detail",
      "description": "Handles specific details for contacts, such as phone numbers or email addresses."
    },
    {
      "name": "Contact Detail V2",
      "description": "An updated version of contact detail management with enhanced functionality."
    },
    {
      "name": "Contact Detail Type",
      "description": "Defines types of contact details (e.g., home phone, work email)."
    },
    {
      "name": "Country",
      "description": "Manages country data for addresses."
    }
  ],
  "x-tagGroups": [
    {
      "name": "Contact Management",
      "tags": [
        "Address",
        "Communication",
        "Contact",
        "Contact V2",
        "Contact V4",
        "Contact Association",
        "Contact Detail",
        "Contact Detail V2",
        "Contact Detail Type",
        "Country"
      ]
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://api.ezyvet.com/v1/oauth/access_token",
            "scopes": {
              "read-address": "Read address resources",
              "read-communication": "Read communication resources",
              "read-contact": "Read contact resources",
              "read-contactassociation": "Read contact association resources",
              "read-contactdetail": "Read contact detail resources",
              "read-contactdetailtype": "Read contact detail type resources",
              "read-country": "Read country resources",
              "write-address": "Create and update address resources",
              "write-communication": "Create and update communication resources",
              "write-contact": "Create and update contact resources",
              "write-contactdetail": "Create and update contact detail resources"
            }
          }
        }
      }
    },
    "parameters": {
      "Communication-active": {
        "name": "active",
        "in": "query",
        "description": "JSON comparator object filtering on active status. Supported comparators: `eq`, `neq`. When omitted, both active and inactive records are returned, matching v2. An inactive filter matches the legacy null value as well as 0.",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":true}"
      },
      "Communication-associated_id": {
        "name": "associated_id",
        "in": "query",
        "description": "JSON comparator object filtering on the associated record id. Pair with `associated_type`, since ids are only unique within a class. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":4693248}"
      },
      "Communication-associated_type": {
        "name": "associated_type",
        "in": "query",
        "description": "JSON comparator object filtering on the associated record class. Supported comparators: `eq`, `neq`, `in`, `like`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"contact\"}"
      },
      "Communication-communicating_id": {
        "name": "communicating_id",
        "in": "query",
        "description": "JSON comparator object filtering on the communicating party id. Pair with `communicating_type`. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":1228705}"
      },
      "Communication-communicating_type": {
        "name": "communicating_type",
        "in": "query",
        "description": "JSON comparator object filtering on the communicating party class. Supported comparators: `eq`, `neq`, `in`, `like`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"animal\"}"
      },
      "Communication-contact_detail_type_id": {
        "name": "contact_detail_type_id",
        "in": "query",
        "description": "JSON comparator object filtering on the contact method. Supported comparators: `eq`, `neq`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"in\":[1,6]}"
      },
      "Communication-content_format": {
        "name": "content_format",
        "in": "query",
        "description": "JSON comparator object filtering on content format. Supported comparators: `eq`, `neq`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"Html\"}"
      },
      "Communication-created_at": {
        "name": "created_at",
        "in": "query",
        "description": "JSON comparator object filtering on creation time, in Unix epoch seconds. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"gte\":1712000000,\"lt\":1712086400}"
      },
      "Communication-destination": {
        "name": "destination",
        "in": "query",
        "description": "JSON comparator object filtering on the destination address. Supported comparators: `eq`, `neq`, `in`, `like`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"like\":\"%@ezyvet.com\"}"
      },
      "Communication-direction": {
        "name": "direction",
        "in": "query",
        "description": "JSON comparator object filtering on direction. Supported comparators: `eq`, `neq`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"Outgoing\"}"
      },
      "Communication-id": {
        "name": "id",
        "in": "query",
        "description": "JSON comparator object filtering on the communication id. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"in\":[8067581,8067582]}"
      },
      "Communication-modified_at": {
        "name": "modified_at",
        "in": "query",
        "description": "JSON comparator object filtering on last-modified time, in Unix epoch seconds. Supported comparators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"gte\":1712000000}"
      },
      "Communication-next_token": {
        "name": "next_token",
        "in": "query",
        "description": "Token for fetching the next page of results, obtained from `meta.next_token` in the previous response. Malformed or tampered values return 400 Bad Request, as does a token issued under a different sort order than the supplied filters imply. The legacy `offset` parameter is not supported and will return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "AB3e7Z2i9FJu0j7hLExLp"
      },
      "Communication-origin": {
        "name": "origin",
        "in": "query",
        "description": "JSON comparator object filtering on the originating address. Supported comparators: `eq`, `neq`, `in`, `like`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"noreply@ezyvet.com\"}"
      },
      "Communication-page_size": {
        "name": "page_size",
        "in": "query",
        "description": "Number of items per page. Default is 2000, maximum is 2000. The legacy `limit` parameter is not supported and will return a 400 error.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "integer",
          "default": 2000,
          "minimum": 1,
          "maximum": 2000
        },
        "example": 200
      },
      "Communication-sent_as_user": {
        "name": "sent_as_user",
        "in": "query",
        "description": "JSON comparator object filtering on the id of the user a send was performed as. Supported comparators: `eq`, `neq`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":100012}"
      },
      "Communication-status": {
        "name": "status",
        "in": "query",
        "description": "JSON comparator object filtering on delivery status. Supported comparators: `eq`, `neq`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"in\":[\"Pending\",\"Sending\"]}"
      },
      "Communication-subject": {
        "name": "subject",
        "in": "query",
        "description": "JSON comparator object filtering on the subject line. Supported comparators: `eq`, `neq`, `in`, `like`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"like\":\"Pre-Op%\"}"
      },
      "Communication-template": {
        "name": "template",
        "in": "query",
        "description": "JSON comparator object filtering on the id of the template the communication was generated from. Supported comparators: `eq`, `neq`, `in`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":10010}"
      },
      "Communication-uid": {
        "name": "uid",
        "in": "query",
        "description": "JSON comparator object filtering on the communication uid. Supported comparators: `eq`, `neq`, `in`, `like`.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"eq\":\"communication_JOwe9iKegeKBuVfzwInhW\"}"
      },
      "ContactV4-active": {
        "name": "active",
        "in": "query",
        "description": "Filter by active flag — **exact match** only. `1` returns active contacts; `0` returns inactive contacts (stored as `contactdata_active IS NULL` for v1 parity, so `0` matches NULL as well as any legacy literal `0`).",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "ContactV4-code": {
        "name": "code",
        "in": "query",
        "description": "Filter by contact code (`contactdata_code`) — **exact match** only.",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "ContactV4-createdAt": {
        "name": "createdAt",
        "in": "query",
        "description": "Filter by created time (`contact_time`). Value is a **URL-encoded JSON object** keyed by comparator, per the IDEXX API filtering standard. Supported comparators: `eq`, `gt`, `lt`, `gte`, `lte`. Multiple comparators may be combined in one object to express a range (e.g. `gte` + `lte`). Examples (raw JSON, before URL-encoding):\n  - exact match — `createdAt={\"eq\":\"2022-01-05T23:23:43Z\"}`\n  - one-week range — `createdAt={\"gte\":\"2024-05-17T00:00:00Z\",\"lte\":\"2024-05-24T00:00:00Z\"}`\n\nEach value must be a strict RFC-3339 instant: `YYYY-MM-DD` + `T` + `HH:MM:SS` (seconds required) + `Z` or `±HH:MM` (colon required). Lowercase `z`, compact `±HHMM`, missing seconds, fractional seconds, epoch-seconds, date-only, and bare non-JSON scalars all return **400 Bad Request**. Unknown comparator keys (`neq`, `in`, `between`, etc.) also return **400 Bad Request**.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"gte\":\"2024-05-17T13:00:00Z\",\"lte\":\"2024-05-24T00:00:00Z\"}"
      },
      "ContactV4-id": {
        "name": "id",
        "in": "query",
        "description": "Filter by contact UID (`contact_uid`) — **exact match** only.",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "ContactV4-name": {
        "name": "name",
        "in": "query",
        "description": "Filter by contact name (`contactdata_name`) — **exact match** only.",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "ContactV4-nextToken": {
        "name": "nextToken",
        "in": "query",
        "description": "Opaque Base64URL token for the next page. Embeds `lastContactId`, `pageSize`, and the supported list filters from the request that produced it (same pattern as GET /v4/species). When using `nextToken`, send only `nextToken` in the query string (no `pageSize` or list filters).",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "AB3e7Z2i9FJu0j7hLExLp"
      },
      "ContactV4-pageSize": {
        "name": "pageSize",
        "in": "query",
        "description": "Sets the number of items to be returned in each page. Default is 2000, Limit is 2000.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "integer",
          "default": 2000,
          "maximum": 2000
        },
        "example": 200
      },
      "ContactV4-updatedAt": {
        "name": "updatedAt",
        "in": "query",
        "description": "Filter by last updated time (`contactdata_time`). Value is a **URL-encoded JSON object** keyed by comparator, per the IDEXX API filtering standard. Supported comparators: `eq`, `gt`, `lt`, `gte`, `lte`. Multiple comparators may be combined in one object to express a range (e.g. `gte` + `lte`). Examples (raw JSON, before URL-encoding):\n  - exact match — `updatedAt={\"eq\":\"2022-01-05T23:23:43Z\"}`\n  - one-week range — `updatedAt={\"gte\":\"2024-05-17T00:00:00Z\",\"lte\":\"2024-05-24T00:00:00Z\"}`\n\nEach value must be a strict RFC-3339 instant: `YYYY-MM-DD` + `T` + `HH:MM:SS` (seconds required) + `Z` or `±HH:MM` (colon required). Lowercase `z`, compact `±HHMM`, missing seconds, fractional seconds, epoch-seconds, date-only, and bare non-JSON scalars all return **400 Bad Request**. Unknown comparator keys (`neq`, `in`, `between`, etc.) also return **400 Bad Request**.",
        "required": false,
        "style": "form",
        "explode": true,
        "schema": {
          "type": "string"
        },
        "example": "{\"gte\":\"2024-05-17T13:00:00Z\",\"lte\":\"2024-05-24T00:00:00Z\"}"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BadRequest"
            }
          }
        }
      },
      "Communication-BadRequest": {
        "description": "Bad Request — returned when unsupported parameters (e.g. `limit`, `offset`) are used.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Communication-ErrorResponse"
            }
          }
        }
      },
      "Communication-InternalError": {
        "description": "Internal Server Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_8LDOwZE81SSqRrMFHqDqy"
                },
                "status": {
                  "type": "string",
                  "example": "500"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Internal Server Error"
                },
                "detail": {
                  "type": "string",
                  "example": "Internal Server Error"
                }
              }
            }
          }
        }
      },
      "Communication-NotFound": {
        "description": "Not Found — also returned while the endpoint is not yet enabled for the site, so a caller mid-rollout can tell a disabled endpoint from a wrong URL.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Communication-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "success": false,
                  "errors": [
                    {
                      "title": "not found",
                      "details": "The v2.1 communication endpoint is not enabled for this site."
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "Communication-TooManyRequests": {
        "description": "Too Many Requests",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_7KCNvYD70RRpQqLEGpCpx"
                },
                "status": {
                  "type": "string",
                  "example": "429"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Too Many Requests"
                },
                "detail": {
                  "type": "string",
                  "example": "Rate limit exceeded."
                }
              }
            }
          }
        }
      },
      "Communication-Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "messages": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "level": {
                        "type": "string",
                        "example": "error"
                      },
                      "type": {
                        "type": "string",
                        "example": "InvalidRequestException"
                      },
                      "text": {
                        "type": "string",
                        "example": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \"access token\" parameter."
                      },
                      "fields": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "example": []
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Communication-UnprocessableEntity": {
        "description": "Unprocessable Entity",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "422"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                },
                "detail": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                }
              }
            }
          }
        }
      },
      "ContactV4-BadRequest": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "BadRequest"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContactV4-Forbidden": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "MissingPermissionAddEditContacts"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContactV4-InternalServerError": {
        "description": "Internal server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "InternalServerError"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContactV4-NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "ContactNotFound"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContactV4-TooManyRequests": {
        "description": "Too Many Requests",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "RateLimitExceeded"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContactV4-Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "Unauthenticated"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContactV4-UnprocessableEntity": {
        "description": "Unprocessable Entity",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ContactV4-ErrorResponse"
            },
            "examples": {
              "Example": {
                "summary": "",
                "value": {
                  "errors": [
                    {
                      "id": "8954638926413656075",
                      "code": "UnprocessableEntity"
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "ContentTooLarge": {
        "description": "Content Too Large",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Error",
                    "minItems": 1
                  }
                }
              }
            },
            "example": {
              "errors": [
                {
                  "id": "29a4d487296207197db493e4904d0186",
                  "detail": "Too many items"
                }
              ]
            }
          }
        }
      },
      "InternalError": {
        "description": "Internal error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "500"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "An internal server error occurred"
                },
                "detail": {
                  "type": "string",
                  "example": "An error occured, please contact API support with the id, status and code provided with the response."
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found",
        "content": {
          "text/html": {
            "schema": {
              "type": "string",
              "example": "No input file specified."
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "429"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Too Many Requests"
                },
                "detail": {
                  "type": "string",
                  "example": "Too Many Requests"
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "messages": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "level": {
                        "type": "string",
                        "example": "error"
                      },
                      "type": {
                        "type": "string",
                        "example": "InvalidRequestException"
                      },
                      "text": {
                        "type": "string",
                        "example": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \\\"access token\\\" parameter."
                      },
                      "fields": {
                        "type": "array",
                        "example": [],
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "Unprocessable Entity",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "422"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                },
                "detail": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "BadRequest": {
        "description": "Bad Request",
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_3YLvb0V7eXcHqgGauTjDy"
                },
                "status": {
                  "type": "string",
                  "example": "400"
                },
                "code": {
                  "type": "string",
                  "example": "100001"
                },
                "title": {
                  "type": "string",
                  "example": "The authorization grant type is not supported by the authorization server."
                },
                "detail": {
                  "type": "string",
                  "example": "The authorization grant type is not supported by the authorization server."
                }
              }
            }
          }
        }
      },
      "Communication-Communication": {
        "type": "object",
        "description": "Communication record in v2.1 format (same field set as v2).",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Legacy integer identifier for the communication.",
            "example": 8067581
          },
          "uid": {
            "type": "string",
            "description": "Stable string identifier for the communication.",
            "example": "communication_JOwe9iKegeKBuVfzwInhW"
          },
          "created_at": {
            "type": "integer",
            "description": "Unix epoch seconds at which the record was created.",
            "example": 1788314305
          },
          "modified_at": {
            "type": "integer",
            "description": "Unix epoch seconds at which the record was last modified.",
            "example": 1788314305
          },
          "active": {
            "type": "boolean",
            "description": "False once the record has been deactivated.",
            "example": true
          },
          "associated_type": {
            "type": "string",
            "nullable": true,
            "description": "Class of the record this communication belongs to.",
            "example": "consult"
          },
          "associated_id": {
            "type": "integer",
            "description": "Legacy integer id of the associated record, interpreted against `associated_type`. Integer only — the target is polymorphic across contact, animal and consult.",
            "example": 4693248
          },
          "communicating_type": {
            "type": "string",
            "description": "Class of the party communicated with.",
            "nullable": true,
            "example": "animal"
          },
          "communicating_id": {
            "type": "integer",
            "description": "Legacy integer id of the party communicated with, interpreted against `communicating_type`.",
            "nullable": true,
            "example": 1228705
          },
          "contact_detail_type_id": {
            "type": "integer",
            "description": "Contact method used — email, SMS, phone, in person, and so on. Integer only; the contact method record has no uid.",
            "nullable": true,
            "example": 6
          },
          "destination": {
            "type": "string",
            "nullable": true,
            "description": "Address the communication was sent to.",
            "example": "daryl@ezyvet.com"
          },
          "origin": {
            "type": "string",
            "description": "Address the communication was sent from.",
            "nullable": true,
            "example": ""
          },
          "direction": {
            "type": "string",
            "description": "Whether the communication was sent or received.",
            "nullable": true,
            "enum": [
              "Incoming",
              "Outgoing"
            ],
            "example": "Outgoing"
          },
          "content": {
            "type": "string",
            "nullable": true,
            "description": "Body of the communication.",
            "example": "Testing"
          },
          "content_format": {
            "type": "string",
            "nullable": true,
            "description": "Format the content is stored in. Null on legacy records that carry none.",
            "enum": [
              "SMS",
              "PlainText",
              "Html"
            ],
            "example": "PlainText"
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "Delivery status of the communication. Null on legacy records that carry none.",
            "enum": [
              "Pending",
              "Done",
              "Sending",
              "Failed"
            ],
            "example": "Done"
          },
          "subject": {
            "type": "string",
            "description": "Subject line, where the contact method carries one.",
            "nullable": true,
            "example": "Test1"
          },
          "read_at": {
            "type": "integer",
            "description": "Unix epoch seconds at which the communication was read, where the channel reports it.",
            "nullable": true,
            "example": 1788314400
          },
          "assigned_user_id": {
            "type": "integer",
            "description": "Legacy integer id of the staff member the communication is assigned to — the \"Assigned Staff Member\" shown in ezyVet. Populated on every creation path, unlike `sent_as_user`, which only the send-triggered paths set. Not available on v2.",
            "readOnly": true,
            "nullable": true,
            "example": 42
          },
          "assigned_user_uid": {
            "type": "string",
            "description": "Stable string identifier of the staff member in `assigned_user_id`.",
            "readOnly": true,
            "nullable": true,
            "example": "user_B4vrE744DdwUXqFxHntAY"
          },
          "assigned_ownership_id": {
            "type": "integer",
            "description": "Legacy integer id of the department the communication was sent from. This is the ownership of the specific resource in `assigned_user_id`; because a staff member has one resource per department, resolving the department from the user alone returns every department they belong to, while this names the one that sent it. Not available on v2.",
            "readOnly": true,
            "nullable": true,
            "example": 7
          },
          "assigned_ownership_uid": {
            "type": "string",
            "description": "Stable string identifier of the department in `assigned_ownership_id`.",
            "readOnly": true,
            "nullable": true,
            "example": "ownershipSeparation_Tpaakrzm09SClP9SPr3L0"
          },
          "sent_as_user": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Communication-CommunicationUser"
              }
            ],
            "description": "The user a send was performed as. Only the send-triggered paths set this, so it is null on most records.",
            "nullable": true
          },
          "template": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Communication-CommunicationTemplate"
              }
            ],
            "description": "Template the communication was generated from, where one was used.",
            "nullable": true
          }
        }
      },
      "Communication-CommunicationItem": {
        "type": "object",
        "description": "Envelope wrapper — each item carries the record under a `communication` key, matching v2.",
        "properties": {
          "communication": {
            "$ref": "#/components/schemas/Communication-Communication"
          }
        }
      },
      "Communication-CommunicationListResponse": {
        "type": "object",
        "description": "Standard v2-style response envelope with token-based pagination.",
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/Communication-Meta"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Communication-CommunicationItem"
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Communication-CommunicationTemplate": {
        "type": "object",
        "description": "Subset of the template record, as returned inside a communication. Integer id only — the template record has no uid.",
        "properties": {
          "id": {
            "type": "integer",
            "example": 10010
          },
          "created_at": {
            "type": "integer",
            "example": 1478823323
          },
          "modified_at": {
            "type": "integer",
            "example": 1478823323
          },
          "active": {
            "type": "boolean",
            "example": true
          },
          "name": {
            "type": "string",
            "example": "Seeded Template"
          },
          "type": {
            "type": "string",
            "nullable": true,
            "example": "POSTCARD"
          },
          "subtype": {
            "type": "string",
            "nullable": true,
            "example": null
          },
          "additional_information": {
            "type": "object",
            "description": "Free-form metadata carried on the template.",
            "nullable": true,
            "additionalProperties": true,
            "example": {
              "key": "value"
            }
          }
        }
      },
      "Communication-CommunicationUser": {
        "type": "object",
        "description": "Subset of the user record, as returned inside a communication.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Legacy integer identifier for the user.",
            "example": 100012
          },
          "uid": {
            "type": "string",
            "description": "Stable string identifier for the user.",
            "example": "user_NvPcEWcuhp7dI2laLwCZI"
          },
          "created_at": {
            "type": "integer",
            "example": 1478823200
          },
          "modified_at": {
            "type": "integer",
            "example": 1479156100
          },
          "active": {
            "type": "boolean",
            "example": true
          },
          "is_vet": {
            "type": "boolean",
            "example": false
          },
          "is_salesperson": {
            "type": "boolean",
            "example": false
          },
          "code": {
            "type": "string",
            "nullable": true,
            "example": "DEHONDEN"
          }
        }
      },
      "Communication-ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string",
                  "example": "bad request"
                },
                "details": {
                  "type": "string",
                  "example": "The \"limit\" parameter is not supported. Use \"page_size\" instead."
                }
              }
            }
          }
        }
      },
      "Communication-Meta": {
        "type": "object",
        "description": "Pagination metadata. When more pages exist, `next_token` contains the token for the next page.",
        "properties": {
          "next_token": {
            "type": "string",
            "nullable": true,
            "description": "Token for fetching the next page. Null or absent when there are no more pages.",
            "example": "AB3e7Z2i9FJu0j7hLExLp"
          }
        }
      },
      "CommunicationResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "timestamp": {
                "type": "string"
              },
              "items_page": {
                "type": "string"
              },
              "items_page_total": {
                "type": "string"
              },
              "items_page_size": {
                "type": "string"
              },
              "items_total": {
                "type": "string"
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "communication": {
                  "$ref": "#/components/schemas/Communicationv1"
                }
              }
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Communicationv1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "uid": {
            "type": "string"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "associated_type": {
            "type": "string"
          },
          "associated_id": {
            "type": "number"
          },
          "contact_detail_type_id": {
            "type": "number"
          },
          "destination": {
            "type": "string"
          },
          "origin": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": [
              "Outgoing",
              "Incoming"
            ]
          },
          "sent_as_user": {
            "$ref": "#/components/schemas/Userv1"
          },
          "content": {
            "type": "string"
          },
          "content_format": {
            "type": "string",
            "enum": [
              "SMS",
              "PlainText",
              "HTML"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Done",
              "Sending",
              "Failed"
            ]
          },
          "subject": {
            "type": "string"
          },
          "communicating_type": {
            "type": "string"
          },
          "communicating_id": {
            "type": "number"
          },
          "template": {
            "$ref": "#/components/schemas/Templatev1"
          },
          "read_at": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "ContactDetailv1": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "contact_detail_type_id": {
            "type": "string"
          },
          "preferred": {
            "type": "number",
            "default": 1
          }
        }
      },
      "Contactv1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "created_at": {
            "type": "string"
          },
          "modified_at": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "business_name": {
            "type": "string"
          },
          "is_business": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_customer": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_supplier": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_vet": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_syndicate": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_staff_member": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "website": {
            "type": "string"
          },
          "stop_credit": {
            "type": "string",
            "enum": [
              "OK",
              "WARNING",
              "STOP"
            ]
          },
          "contact_detail_list": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "address_physical": {
            "type": "string"
          },
          "address_postal": {
            "type": "string"
          },
          "date_of_birth": {
            "type": "number",
            "default": 0
          },
          "driver_license_number": {
            "type": "string",
            "nullable": true
          },
          "driver_license_issuer": {
            "type": "string",
            "nullable": true
          },
          "driver_license_expiry": {
            "type": "number",
            "nullable": true
          },
          "is_no_electronic_marketing": {
            "type": "string",
            "nullable": false
          },
          "ownership_id": {
            "type": "string"
          }
        }
      },
      "ContactV4-Address": {
        "type": "object",
        "description": "Represents an address associated with a contact. The physical/postal distinction is carried by which parent key holds the object (`addressPhysical` vs `addressPostal`), not by a field on the address itself. Includes geographic coordinates and reminder preferences.\n",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Unique address identifier",
            "example": 1
          },
          "name": {
            "type": "string",
            "description": "Address label or name",
            "example": "John Smith Home",
            "maxLength": 80
          },
          "street1": {
            "type": "string",
            "description": "Primary street address",
            "example": "123 Main Street",
            "maxLength": 100
          },
          "street2": {
            "type": "string",
            "description": "Secondary address line (apartment, suite, etc.)",
            "example": "Apt 4B",
            "maxLength": 100
          },
          "suburb": {
            "type": "string",
            "description": "Suburb or neighborhood",
            "example": "Ponsonby",
            "maxLength": 50
          },
          "city": {
            "type": "string",
            "description": "City or town",
            "example": "Auckland",
            "maxLength": 50
          },
          "region": {
            "type": "string",
            "description": "Region or area",
            "example": "Auckland Region",
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "description": "State or province",
            "example": "Auckland",
            "maxLength": 100
          },
          "postcode": {
            "type": "string",
            "description": "Postal or ZIP code",
            "example": "90210",
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "description": "Country name",
            "example": "United States"
          },
          "latitude": {
            "type": "number",
            "format": "float",
            "description": "Geographic latitude",
            "example": -36.8485
          },
          "longitude": {
            "type": "number",
            "format": "float",
            "description": "Geographic longitude",
            "example": 174.7633
          },
          "receivesReminders": {
            "type": "boolean",
            "description": "Whether this address receives reminder communications",
            "example": true
          }
        },
        "required": [
          "name",
          "street1",
          "country"
        ]
      },
      "ContactV4-Contact": {
        "type": "object",
        "description": "Represents a contact in the ezyVet system. Contacts can be customers, vets, suppliers, or businesses. Includes full contact details, addresses, emails, phones, and metadata.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique contact identifier (UID)",
            "example": "contact-abc123",
            "maxLength": 50
          },
          "legacyId": {
            "type": "integer",
            "description": "Legacy numeric contact identifier (for backwards compatibility)",
            "example": 1
          },
          "number": {
            "type": "string",
            "description": "Auto-generated contact number",
            "example": "C0000000001",
            "readOnly": true
          },
          "code": {
            "type": "string",
            "description": "Custom contact code",
            "example": "SMITH001",
            "maxLength": 25
          },
          "name": {
            "type": "string",
            "description": "Contact name (business name or full person name)",
            "example": "John Smith",
            "maxLength": 100
          },
          "title": {
            "type": "string",
            "description": "Person title (Mr, Mrs, Dr, etc.)",
            "example": "Dr",
            "maxLength": 10
          },
          "first": {
            "type": "string",
            "description": "First name (for person contacts)",
            "example": "John",
            "maxLength": 50
          },
          "last": {
            "type": "string",
            "description": "Last name (for person contacts)",
            "example": "Smith",
            "maxLength": 50
          },
          "website": {
            "type": "string",
            "description": "Contact website URL or domain (protocol optional)",
            "example": "johnsmith.com",
            "maxLength": 100
          },
          "confirmed": {
            "type": "boolean",
            "description": "Whether contact details are confirmed",
            "example": true
          },
          "notes": {
            "type": "string",
            "description": "Additional notes about the contact",
            "example": "Preferred customer with multiple pets"
          },
          "notesImportant": {
            "type": "boolean",
            "description": "Whether notes are flagged as important",
            "example": false
          },
          "noSpam": {
            "type": "boolean",
            "description": "Contact preference for marketing communications",
            "example": false
          },
          "active": {
            "type": "boolean",
            "description": "Whether contact is active",
            "example": true
          },
          "hospitalUid": {
            "type": "string",
            "description": "UID of the hospital this contact belongs to (`contactdata_hospital`). Omitted when the contact has no hospital on file. Not filterable.\n",
            "example": "hosp-9z8y7x",
            "maxLength": 50
          },
          "ownershipseparationUid": {
            "type": "string",
            "description": "UID of the `ownershipseparation` node that owns this contact (`contactdata_osr_ownership`). Omitted when the contact has no ownership node on file. Not filterable.\n",
            "example": "ownsep-1a2b3c",
            "maxLength": 50
          },
          "isBusiness": {
            "type": "boolean",
            "description": "True when the contact is a business; false when an individual.",
            "example": false
          },
          "isCustomer": {
            "type": "boolean",
            "description": "Whether the contact is flagged as a customer.",
            "example": true
          },
          "isSupplier": {
            "type": "boolean",
            "description": "Whether the contact is flagged as a supplier.",
            "example": false
          },
          "isVet": {
            "type": "boolean",
            "description": "Whether the contact is flagged as a vet.",
            "example": false
          },
          "isSyndicate": {
            "type": "boolean",
            "description": "Whether the contact is flagged as a syndicate.",
            "example": false
          },
          "isStaffMember": {
            "type": "boolean",
            "description": "Whether the contact is flagged as a staff member.",
            "example": false
          },
          "isPharmacy": {
            "type": "boolean",
            "description": "Whether the contact is flagged as a pharmacy.",
            "example": false
          },
          "driverLicenseNumber": {
            "type": "string",
            "description": "Driver license number",
            "example": "DL123456789",
            "maxLength": 50
          },
          "driverLicenseIssuer": {
            "type": "string",
            "description": "Driver license issuing authority",
            "example": "DMV California",
            "maxLength": 100
          },
          "driverLicenseExpiry": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Driver license expiry date",
            "example": "2025-12-31"
          },
          "addressPhysical": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactV4-Address"
              }
            ],
            "description": "The contact's physical address, when one is on file. Absent when not set.",
            "example": {
              "id": 1,
              "name": "John Smith Home",
              "street1": "123 Main Street",
              "city": "Los Angeles",
              "state": "California",
              "postcode": "90210",
              "country": "United States"
            }
          },
          "addressPostal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactV4-Address"
              }
            ],
            "description": "The contact's postal address, when one is on file. Absent when not set.",
            "example": {
              "id": 2,
              "name": "John Smith Mailing",
              "street1": "PO Box 1234",
              "city": "Los Angeles",
              "state": "California",
              "postcode": "90210",
              "country": "United States"
            }
          },
          "emails": {
            "type": "array",
            "description": "List of email addresses with subscription preferences",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Email"
            },
            "example": [
              {
                "emailId": "email_abc123def456",
                "legacyId": 1,
                "name": "Primary Email",
                "content": "john@example.com",
                "subscriptions": [
                  {
                    "name": "General"
                  }
                ]
              }
            ]
          },
          "phones": {
            "type": "array",
            "description": "List of phone numbers with subscription preferences",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Phone"
            },
            "example": [
              {
                "phoneId": "phone_xyz789ghi012",
                "legacyId": 1,
                "name": "Mobile Phone",
                "content": "+16502530000",
                "subscriptions": [
                  {
                    "name": "General"
                  }
                ]
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Contact creation timestamp",
            "example": "2024-01-15T10:30:00Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last update timestamp",
            "example": "2024-01-16T14:45:00Z"
          }
        }
      },
      "ContactV4-ContactBulkCreateResponse": {
        "type": "object",
        "description": "Response envelope for the bulk-create POST path. Wire shape `{ \"data\": [Contact, ...], \"errors\": [ ... ] }` — no `meta` (the bulk POST does not paginate; pagination is a list-read concern). `errors` is `[]` on success.\n",
        "required": [
          "data",
          "errors"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Contact"
            }
          },
          "errors": {
            "type": "array",
            "description": "Array of error objects. Always present; `[]` on success.",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Error"
            }
          }
        }
      },
      "ContactV4-ContactListResponse": {
        "type": "object",
        "description": "Response envelope for contact list operations. Uses token pagination. Always returns complete contact data including addresses, emails, phones, and subscriptions.",
        "required": [
          "meta",
          "data",
          "errors"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/ContactV4-Meta"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Contact"
            }
          },
          "errors": {
            "type": "array",
            "description": "Array of error objects. Always present; `[]` on success.",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Error"
            }
          }
        }
      },
      "ContactV4-ContactResponse": {
        "type": "object",
        "description": "Response envelope for the single-contact read endpoint (GET /v4/contact/{id}). Wire shape: `{ \"data\": { ... }, \"errors\": [ ... ] }`. `data` is the Contact object directly (not an array). No `meta`. `errors` is `[]` on success. The bulk-create POST uses `ContactBulkCreateResponse` (array `data`), not this schema.\n",
        "required": [
          "data",
          "errors"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ContactV4-Contact"
          },
          "errors": {
            "type": "array",
            "description": "Array of error objects. Always present; `[]` on success.",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Error"
            }
          }
        }
      },
      "ContactV4-CreateContactAddressRequest": {
        "type": "object",
        "description": "Address payload nested inside a CreateContactRequest body. The physical/postal distinction is set by which parent key (`addressPhysical` / `addressPostal`) holds the object, not by a field on the payload itself.\n",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 80
          },
          "street1": {
            "type": "string",
            "maxLength": 100
          },
          "street2": {
            "type": "string",
            "maxLength": 100
          },
          "suburb": {
            "type": "string",
            "maxLength": 50
          },
          "city": {
            "type": "string",
            "maxLength": 50
          },
          "region": {
            "type": "string",
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "maxLength": 100
          },
          "postcode": {
            "type": "string",
            "maxLength": 45
          },
          "country": {
            "type": "string",
            "description": "Country name; looked up against `country.countrydata_name`. Unknown names return 400 `InvalidCountry`.",
            "maxLength": 100
          },
          "latitude": {
            "type": "number",
            "format": "double"
          },
          "longitude": {
            "type": "number",
            "format": "double"
          },
          "receivesReminders": {
            "type": "boolean"
          }
        }
      },
      "ContactV4-CreateContactEmailRequest": {
        "type": "object",
        "required": [
          "content"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Label for the email (e.g. \"Primary\", \"Work\").",
            "maxLength": 100
          },
          "content": {
            "type": "string",
            "description": "The email address itself.",
            "maxLength": 100
          },
          "preferred": {
            "type": "boolean",
            "description": "Per-row preferred flag, persisted to `emailphonedata_preferred`. Matches v1."
          },
          "subscriptions": {
            "type": "array",
            "maxItems": 20,
            "description": "Subscription group memberships to create for this email. Each entry must be a name from the fixed subscription enum below. Unknown names return `InvalidSubscriptionGroup`.\n",
            "items": {
              "type": "string",
              "enum": [
                "Reminders",
                "Accounts",
                "General",
                "Sales",
                "Postal"
              ]
            },
            "example": [
              "General",
              "Reminders"
            ]
          }
        }
      },
      "ContactV4-CreateContactPhoneRequest": {
        "type": "object",
        "required": [
          "content"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Label for the phone (e.g. \"Mobile\", \"Home\").",
            "maxLength": 100
          },
          "content": {
            "type": "string",
            "description": "The phone number, in **E.164 format** — a leading `+`, the country code, then the national number with no spaces, dashes, or parentheses (e.g. `+6495550001`). Validated with libphonenumber; a value that is not valid E.164 returns 400 `InvalidPhoneNumber`. This is a deviation from legacy v1, which accepted free-form numbers and reformatted them server-side (see \"Breaking changes from v1\").\n",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "example": "+6495550001",
            "maxLength": 100
          },
          "phoneType": {
            "type": "string",
            "enum": [
              "Mobile",
              "Landline",
              "Fax"
            ],
            "description": "Phone subtype. Mapped to `emailphonedata_type` via a batch-resolved type-id lookup (§7.5.8). Defaults to `Mobile` when omitted. Unknown values return 400 `InvalidPhoneType`.\n"
          },
          "preferred": {
            "type": "boolean",
            "description": "Per-row preferred flag, persisted to `emailphonedata_preferred`. Matches v1."
          },
          "subscriptions": {
            "type": "array",
            "maxItems": 20,
            "description": "Subscription group memberships to create for this phone. Each entry must be a name from the fixed subscription enum below. Unknown names return `InvalidSubscriptionGroup`.\n",
            "items": {
              "type": "string",
              "enum": [
                "Reminders",
                "Accounts",
                "General",
                "Sales",
                "Postal"
              ]
            },
            "example": [
              "General"
            ]
          }
        }
      },
      "ContactV4-CreateContactRequest": {
        "type": "object",
        "description": "Request body for POST /v4/contact. Mirrors the shape of the Contact response but omits server-controlled fields (`id`, `legacyId`, `number`, `createdAt`, `updatedAt`). At least one entry across `emails` and `phones` is required.\n\nOwnership: `ownershipseparationUid` and `hospitalUid` are both REQUIRED. `ownershipseparationUid` is the source of truth for the contact's owning ownership-separation node (`contactdata_osr_ownership`); `hospitalUid` sets `contactdata_hospital`. v4 does NOT derive either from the calling user's last-active resource (a deliberate deviation from legacy v1 — see the endpoint description). The ownership must sit within the hospital's ownership branch — either an ancestor (or equal) of the hospital's business, or a descendant of that business that references this hospital. A contradicting pair is rejected with `OwnershipHospitalMismatch`.\n",
        "required": [
          "name",
          "ownershipseparationUid",
          "hospitalUid"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Contact name (business name or full person name).",
            "maxLength": 100,
            "example": "Jane Doe"
          },
          "ownershipseparationUid": {
            "type": "string",
            "description": "REQUIRED. UID of the `ownershipseparation` node that owns this contact (looked up against `ownershipseparation.ownershipseparation_uid`, active rows). Written to `contactdata_osr_ownership`. Unknown UID → 400 `InvalidOwnershipSeparation`; blank → 400 `OwnershipSeparationRequired`. Discover valid UIDs via the v1/v2 separation endpoint.\n",
            "example": "ownsep-1a2b3c"
          },
          "hospitalUid": {
            "type": "string",
            "description": "REQUIRED. UID of the hospital this contact belongs to (looked up against `hospital.hospital_uid`, active rows). Written to `contactdata_hospital`. Unknown UID → 400 `InvalidHospital`; blank → 400 `HospitalRequired`. Must be in the same ownership branch as `ownershipseparationUid` (else 400 `OwnershipHospitalMismatch`).\n",
            "example": "hosp-9z8y7x"
          },
          "code": {
            "type": "string",
            "description": "Custom contact code (unique across the practice when supplied).",
            "maxLength": 25,
            "example": "DOE001"
          },
          "first": {
            "type": "string",
            "description": "First name for person contacts.",
            "maxLength": 50
          },
          "last": {
            "type": "string",
            "description": "Last name for person contacts.",
            "maxLength": 50
          },
          "website": {
            "type": "string",
            "description": "Website URL.",
            "maxLength": 100
          },
          "notes": {
            "type": "string",
            "description": "Free-text notes attached to the contact."
          },
          "notesImportant": {
            "type": "boolean",
            "description": "Mark the notes as important (surfaced more prominently in the UI)."
          },
          "noSpam": {
            "type": "boolean",
            "description": "Exclude this contact from marketing communications."
          },
          "active": {
            "type": "boolean",
            "description": "Whether the contact is active. Defaults to true when omitted."
          },
          "isBusiness": {
            "type": "boolean"
          },
          "isCustomer": {
            "type": "boolean"
          },
          "isSupplier": {
            "type": "boolean"
          },
          "isVet": {
            "type": "boolean"
          },
          "isSyndicate": {
            "type": "boolean"
          },
          "isStaffMember": {
            "type": "boolean"
          },
          "isPharmacy": {
            "type": "boolean"
          },
          "stopCredit": {
            "type": "string",
            "enum": [
              "OK",
              "WARNING",
              "STOP"
            ],
            "description": "Credit status. Defaults to `OK` when omitted."
          },
          "driverLicenseNumber": {
            "type": "string",
            "description": "Driver's license number. Trimmed before INSERT. Inputs containing `*`, `~`, `\"`, or `'` are rejected with 400 `InvalidCharacters` — see \"Breaking changes from v1\" on the `POST /v4/contact` endpoint description. (v1 silently stripped these characters; v4 surfaces the rejection instead.)\n",
            "maxLength": 20
          },
          "driverLicenseIssuer": {
            "type": "string",
            "description": "Driver's license issuer. Trimmed before INSERT. Inputs containing `*`, `~`, or `\"` (apostrophe is permitted, unlike the other license/passport fields) are rejected with 400 `InvalidCharacters` — see \"Breaking changes from v1\".\n",
            "maxLength": 30
          },
          "driverLicenseExpiry": {
            "type": "string",
            "format": "date",
            "description": "Driver licence expiry as a calendar date (`YYYY-MM-DD`) — a timezone-less date, no time component."
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "description": "Date of birth as a calendar date (`YYYY-MM-DD`) — a timezone-less date, no time component. Strict format — strings that don't round-trip through `Y-m-d` (e.g. `2025/01/01`, `20250101`, anything with a time component) return 400 `InvalidDateOfBirth`.\n",
            "example": "1990-01-15"
          },
          "nationalIdNumber": {
            "type": "string",
            "description": "National ID number. Trimmed before INSERT. Inputs containing `*`, `~`, `\"`, or `'` are rejected with 400 `InvalidCharacters` — see \"Breaking changes from v1\".\n",
            "maxLength": 20
          },
          "passportNumber": {
            "type": "string",
            "description": "Passport number. Trimmed before INSERT. Inputs containing `*`, `~`, `\"`, or `'` are rejected with 400 `InvalidCharacters` — see \"Breaking changes from v1\".\n",
            "maxLength": 20
          },
          "titleId": {
            "type": "integer",
            "description": "FK to `contacttitle.contacttitle_id`. Persisted to `contactdata_title`."
          },
          "addressPhysical": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactV4-CreateContactAddressRequest"
              }
            ],
            "description": "Physical address. Optional; omit when the contact has no physical address."
          },
          "addressPostal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactV4-CreateContactAddressRequest"
              }
            ],
            "description": "Postal address. Optional; omit when the contact has no postal address."
          },
          "emails": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/ContactV4-CreateContactEmailRequest"
            }
          },
          "phones": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/ContactV4-CreateContactPhoneRequest"
            }
          }
        }
      },
      "ContactV4-Email": {
        "type": "object",
        "description": "Email address with subscription preferences",
        "properties": {
          "emailId": {
            "type": "string",
            "description": "Unique email identifier (UID)",
            "example": "email_abc123def456",
            "maxLength": 50
          },
          "legacyId": {
            "type": "integer",
            "description": "Legacy numeric email identifier (for backwards compatibility)",
            "example": 48
          },
          "name": {
            "type": "string",
            "description": "Email address label or name",
            "example": "Home Email",
            "maxLength": 100
          },
          "content": {
            "type": "string",
            "format": "email",
            "description": "Email address",
            "example": "vet@example.com",
            "maxLength": 255
          },
          "subscriptions": {
            "type": "array",
            "description": "List of subscription groups for this email",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Subscription"
            }
          }
        },
        "required": [
          "name",
          "content"
        ]
      },
      "ContactV4-Error": {
        "type": "object",
        "description": "Error object as defined by the VetSoft API Errors standard. Errors do not contain user-facing text; they are programmatically interpretable by the caller.\n",
        "required": [
          "id",
          "code"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "An ID that can be used to trace this error instance. Generally the DataDog trace ID.\n"
          },
          "code": {
            "type": "string",
            "description": "A unique, human-readable identifier for this type of error. Searchable in the application code base (e.g. `ContactNotFound`). Many error instances may share the same `code` but each will have a unique `id`.\n"
          },
          "target": {
            "type": "string",
            "description": "JSON pointer (RFC 6901) indicating the location in the request payload that caused the error (e.g. `/0/emails/1/content`).\n"
          }
        }
      },
      "ContactV4-ErrorResponse": {
        "type": "object",
        "description": "Error envelope per the VetSoft v4 standard. Carries `errors` only — no `data` or `meta` field on error responses.\n",
        "required": [
          "errors"
        ],
        "properties": {
          "errors": {
            "type": "array",
            "description": "Array of error objects providing detailed error information.",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Error"
            }
          }
        }
      },
      "ContactV4-Meta": {
        "type": "object",
        "description": "Response metadata. Always present on successful list responses. When another page exists, `nextToken` is included as a string. On the last page, `meta` is an empty object with no properties (no `nextToken` key).\n",
        "properties": {
          "nextToken": {
            "type": "string",
            "description": "Token for fetching the next page of results (present only when more pages exist).",
            "example": "AB3e7Z2i9FJu0j7hLExLp"
          }
        },
        "example": {
          "nextToken": "AB3e7Z2i9FJu0j7hLExLp"
        }
      },
      "ContactV4-Phone": {
        "type": "object",
        "description": "Phone number with subscription preferences",
        "properties": {
          "phoneId": {
            "type": "string",
            "description": "Unique phone identifier (UID)",
            "example": "phone_xyz789ghi012",
            "maxLength": 50
          },
          "legacyId": {
            "type": "integer",
            "description": "Legacy numeric phone identifier (for backwards compatibility)",
            "example": 46
          },
          "name": {
            "type": "string",
            "description": "Phone number label or name",
            "example": "Mobile Phone",
            "maxLength": 100
          },
          "content": {
            "type": "string",
            "description": "Phone number (international format supported)",
            "example": "+64 27 123 4567",
            "pattern": "^[+]?[0-9\\s\\-\\(\\)\\.\\/ x]{7,20}$",
            "maxLength": 20
          },
          "subscriptions": {
            "type": "array",
            "description": "List of subscription groups for this phone",
            "items": {
              "$ref": "#/components/schemas/ContactV4-Subscription"
            }
          }
        },
        "required": [
          "name",
          "content"
        ]
      },
      "ContactV4-Subscription": {
        "type": "object",
        "description": "Subscription group information",
        "properties": {
          "name": {
            "type": "string",
            "description": "Fixed system subscription group name",
            "enum": [
              "Reminders",
              "Accounts",
              "General",
              "Sales",
              "Postal"
            ],
            "example": "General"
          }
        },
        "required": [
          "name"
        ]
      },
      "CreateContactRequestv1": {
        "type": "object",
        "required": [
          "first_name",
          "last_name",
          "contact_detail_list"
        ],
        "properties": {
          "ownership_id": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "business_name": {
            "type": "string"
          },
          "is_business": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_customer": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_supplier": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_vet": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_syndicate": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_staff_member": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "is_no_electronic_marketing": {
            "description": "If true/1, the Contact does not want to receive electronic marketing.",
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string"
              }
            ]
          },
          "address_physical": {
            "type": "string",
            "description": "stringify physical address object and insert here.",
            "example": "{\"street_1\":\"1 Idexx Dr\",\"street_2\":\"physical-street-2\",\"suburb\":\"Westbrook\",\"city\":\"Portland\",\"region\":\"physical-region\",\"state\":\"Maine\",\"country_id\":\"153\",\"longitude\":\"10\",\"latitude\":\"20\"}"
          },
          "address_postal": {
            "type": "string",
            "description": "stringify postal address object and insert here.",
            "example": "{\"street_1\":\"1 Idexx Dr\",\"street_2\":\"postal-street-2\",\"suburb\":\"Westbrook\",\"city\":\"Portland\",\"region\":\"postal-region\",\"state\":\"Maine\",\"country_id\":\"153\",\"longitude\":\"10\",\"latitude\":\"20\"}"
          },
          "stop_credit": {
            "type": "string",
            "enum": [
              "OK",
              "WARNING",
              "STOP"
            ]
          },
          "date_of_birth": {
            "type": "number",
            "default": 0
          },
          "driver_license_number": {
            "type": "string",
            "nullable": true
          },
          "driver_license_issuer": {
            "type": "string",
            "nullable": true
          },
          "driver_license_expiry": {
            "type": "number",
            "nullable": true
          },
          "contact_detail_list": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactDetailv1"
            }
          }
        }
      },
      "CreateContactResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "timestamp": {
                "type": "string"
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "contact": {
                  "$ref": "#/components/schemas/Contactv1"
                }
              }
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "DeleteResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "timestamp": {
                "type": "string"
              },
              "items_matched": {
                "type": "number"
              },
              "items_processed": {
                "type": "number"
              }
            }
          },
          "items": {
            "type": "array",
            "items": {}
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Represents an error object.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The identifier of the error.",
            "anyOf": [
              {
                "description": "Trace ID",
                "pattern": "^[A-Fa-f0-9]{32}$",
                "example": "463ac35c9f6413ad48485a3953bb6124"
              },
              {
                "description": "Custom error ID",
                "pattern": "^error_[A-Za-z0-9]{21}$",
                "example": "error_5JBMuXC69QQoPpKDFoBow"
              }
            ]
          },
          "target": {
            "type": "string",
            "description": "The target of the error in the JSON Pointer syntax (e.g., \"/0\" to indicate the first item in the request array failed).",
            "example": "/0"
          },
          "detail": {
            "type": "string",
            "description": "Detailed error message.",
            "example": "Invalid associatedType"
          }
        }
      },
      "Resourcev1": {
        "type": "object",
        "description": "The [`Resource`](#resource) of the [`User`](#user) that will attached to the [`Communication`](#communication)."
      },
      "SentCommunicationRequest": {
        "type": "object",
        "required": [
          "associatedType",
          "associatedId",
          "communicationType",
          "destination",
          "direction",
          "content",
          "contentFormat",
          "userId",
          "departmentId"
        ],
        "properties": {
          "associatedType": {
            "type": "string",
            "description": "The type of entity this communication is associated with.",
            "enum": [
              "Contact",
              "Animal",
              "Consult"
            ],
            "example": "Contact"
          },
          "associatedId": {
            "type": "string",
            "description": "The unique identifier (UID) of the associated entity (contact, animal, or consult).",
            "example": "contact_HfoQJT3F4pk4DPGPn131C"
          },
          "communicationType": {
            "type": "string",
            "description": "The type of communication channel used.",
            "enum": [
              "Email",
              "Fax",
              "SnailMail",
              "SMS",
              "PhoneCallLog",
              "InPersonCommunicationNotes",
              "CalendarInvite",
              "Unknown/Other",
              "Postcard"
            ],
            "example": "Email"
          },
          "destination": {
            "type": "string",
            "description": "The destination address (email, phone number, etc.) where the communication was sent.",
            "example": "demo@demo.com"
          },
          "direction": {
            "type": "string",
            "description": "The direction of the communication.",
            "enum": [
              "Outgoing",
              "Incoming"
            ],
            "example": "Outgoing"
          },
          "content": {
            "type": "string",
            "description": "The content/body of the communication. When contentFormat is 'SMS', maximum length is 455 characters.",
            "example": "This is a reminder that Rader is due for their wellness exam."
          },
          "contentFormat": {
            "type": "string",
            "description": "The format of the content.",
            "enum": [
              "SMS",
              "PlainText",
              "Html"
            ],
            "example": "PlainText"
          },
          "subject": {
            "type": "string",
            "description": "The subject line of the communication (optional for some communication types).",
            "example": "Wellness Exam Reminder"
          },
          "userId": {
            "type": "string",
            "description": "The unique identifier (UID) of the user who sent the communication. Format: user_xxxxx",
            "example": "user_B4vrE744DdwUXqFxHntAY"
          },
          "departmentId": {
            "type": "string",
            "description": "The unique identifier (UID) of the department (ownership separation) associated with this communication. Format: ownershipSeparation_xxxxx. If a resource does not exist for this user and department combination, one will be created automatically.",
            "example": "ownershipSeparation_wQU1jqt39kjns3XvzqXqL"
          },
          "communicationTimestamp": {
            "type": "string",
            "format": "date-time",
            "description": "The timestamp when the communication was sent (ISO8601 format). If not provided, defaults to the current time.",
            "example": "2024-01-15T14:30:00Z"
          },
          "hospitalId": {
            "type": "string",
            "description": "The unique identifier (UID) of the hospital that sent the communication. If provided, this takes precedence over deriving the hospital from the userResource.",
            "example": "hospital_apJEA7ntuKKhpa0a9Hlya"
          },
          "origin": {
            "type": "string",
            "description": "The sender address (e.g., the 'from' email address or phone number) of the communication.",
            "example": "noreply@clinic.com"
          }
        }
      },
      "Templatev1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "subtype": {
            "type": "string",
            "nullable": true
          },
          "additional_information": {
            "type": "object"
          }
        }
      },
      "Userv1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "created_at": {
            "type": "number"
          },
          "modified_at": {
            "type": "number"
          },
          "active": {
            "type": "boolean"
          },
          "is_vet": {
            "type": "boolean"
          },
          "is_salesperson": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/v1/address": {
      "post": {
        "summary": "Creates a single Address",
        "operationId": "create-address",
        "description": "Creates a single [`Address`](#address).",
        "tags": [
          "Address"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-address"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "street_1": {
                    "type": "string"
                  },
                  "street_2": {
                    "type": "string"
                  },
                  "suburb": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "region": {
                    "type": "string"
                  },
                  "post_code": {
                    "type": "string"
                  },
                  "country_id": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  },
                  "longitude": {
                    "type": "string"
                  },
                  "latitude": {
                    "type": "string"
                  },
                  "for_resource": {
                    "type": "object",
                    "properties": {
                      "Contact": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "address": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              },
                              "street_1": {
                                "type": "string"
                              },
                              "street_2": {
                                "type": "string"
                              },
                              "suburb": {
                                "type": "string"
                              },
                              "city": {
                                "type": "string"
                              },
                              "region": {
                                "type": "string"
                              },
                              "post_code": {
                                "type": "string"
                              },
                              "country_id": {
                                "type": "string"
                              },
                              "state": {
                                "type": "string"
                              },
                              "longitude": {
                                "type": "string"
                              },
                              "latitude": {
                                "type": "string"
                              },
                              "for_resource": {
                                "type": "object",
                                "properties": {
                                  "Contact": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      }
                                    }
                                  }
                                }
                              },
                              "distance": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "summary": "Fetches a list containing Address(es)",
        "operationId": "get-address",
        "tags": [
          "Address"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "street_1",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "street_2",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "suburb",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "city",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "region",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "post_code",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "longitude",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "latitude",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Addresses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "address": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "street_1": {
                                "type": "string"
                              },
                              "street_2": {
                                "type": "string"
                              },
                              "suburb": {
                                "type": "string"
                              },
                              "city": {
                                "type": "string"
                              },
                              "region": {
                                "type": "string"
                              },
                              "post_code": {
                                "type": "string"
                              },
                              "country_id": {
                                "type": "string"
                              },
                              "state": {
                                "type": "string"
                              },
                              "longitude": {
                                "type": "string"
                              },
                              "latitude": {
                                "type": "string"
                              },
                              "for_resource": {
                                "type": "object",
                                "properties": {
                                  "Contact": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-address"
            ]
          }
        ]
      }
    },
    "/v1/address/{id}": {
      "patch": {
        "summary": "Update an Address",
        "operationId": "update-address",
        "tags": [
          "Address"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-address"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the address to update",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "The Address's name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "street_1",
            "in": "query",
            "description": "The Address's first street line.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "street_2",
            "in": "query",
            "description": "The Address's second street line.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "suburb",
            "in": "query",
            "description": "The Address's suburb.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "city",
            "in": "query",
            "description": "The Address's city.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "region",
            "in": "query",
            "description": "The Address's region.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "post_code",
            "in": "query",
            "description": "The Address's post code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country_id",
            "in": "query",
            "description": "The Address's Country ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "The Address's state, where applicable.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "longitude",
            "in": "query",
            "description": "The Address's longitudinal geographic coordinate (-180 to 180).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "latitude",
            "in": "query",
            "description": "The Address's latitudinal geographic coordinate (-90 to 90).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "street_1": {
                    "type": "string"
                  },
                  "street_2": {
                    "type": "string"
                  },
                  "suburb": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "region": {
                    "type": "string"
                  },
                  "post_code": {
                    "type": "string"
                  },
                  "country_id": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  },
                  "longitude": {
                    "type": "string"
                  },
                  "latitude": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Address updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "address": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "street_1": {
                                "type": "string"
                              },
                              "street_2": {
                                "type": "string"
                              },
                              "suburb": {
                                "type": "string"
                              },
                              "city": {
                                "type": "string"
                              },
                              "region": {
                                "type": "string"
                              },
                              "post_code": {
                                "type": "string"
                              },
                              "country_id": {
                                "type": "string"
                              },
                              "state": {
                                "type": "string"
                              },
                              "longitude": {
                                "type": "string"
                              },
                              "latitude": {
                                "type": "string"
                              },
                              "for_resource": {
                                "type": "object",
                                "properties": {
                                  "Contact": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      }
                                    }
                                  }
                                }
                              },
                              "distance": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "summary": "Delete an Address",
        "operationId": "delete-address",
        "security": [
          {
            "bearerAuth": [
              "write-address"
            ]
          }
        ],
        "tags": [
          "Address"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the address to delete",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "description": "Bearer token for authentication",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful deletion",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/communication": {
      "get": {
        "summary": "Get a Communication",
        "operationId": "get-communication",
        "tags": [
          "Communication"
        ],
        "security": [
          {
            "bearerAuth": [
              "read-communication"
            ]
          }
        ],
        "parameters": [
          {
            "name": "uid",
            "in": "query",
            "description": "The unique identifier of the communication",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "communication_BPSHlXlBrdLKxqyVtEtcz"
          },
          {
            "name": "associated_type",
            "in": "query",
            "description": "The name of the record type the Communication is directed at. Examples are 'Contact', 'Animal', 'Consult'.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "associated_id",
            "in": "query",
            "description": "The ID of the record the Communication is directed at.",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "content_format",
            "in": "query",
            "description": "The format of the content. This will be one of the following: SMS, PlainText, HTML.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "SMS",
                "PlainText",
                "HTML"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "The status of the Communication. This will be one of the following: Pending, Done, Sending, Failed.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Pending",
                "Done",
                "Sending",
                "Failed"
              ]
            }
          },
          {
            "name": "communicating_type",
            "in": "query",
            "description": "The name of the record type the Communication is communicating. Examples are 'Contact', 'Animal', 'Consult'.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "communicating_id",
            "in": "query",
            "description": "The ID of the record the Communication is communicating.",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Communications",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommunicationResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "summary": "Create a Communication",
        "operationId": "create-communication",
        "tags": [
          "Communication"
        ],
        "description": "Creates a single `Communication`. Please note that you must send a `Resource` ID for the user you want to be attached to the communication.\n\n Additional documentation can be found [`here`](../guides/communications)",
        "security": [
          {
            "bearerAuth": [
              "write-communication"
            ]
          }
        ],
        "requestBody": {
          "description": "Sample request: Creates a `Communication` that will be attached to a `Contact` with an ID of `1` and will be communicating about `Consult` `2`",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "associated_type": {
                    "type": "string",
                    "description": "The name of the record type the `Communication` is directed at. Examples are \"Contact\" , \"Animal\", \"Consult\"."
                  },
                  "associated_id": {
                    "type": "number",
                    "description": "The ID of the record the `Communication` is directed at."
                  },
                  "contact_detail_type_id": {
                    "type": "number",
                    "description": "The ID of `ContactDetailType` that was used to send the `Communication`. This will also help define what the format `destination` should be."
                  },
                  "destination": {
                    "type": "string",
                    "description": "The destination of the `Communication` in the format defined by the `contact_detail_type_id`."
                  },
                  "direction": {
                    "type": "string",
                    "enum": [
                      "Outgoing",
                      "Incoming"
                    ],
                    "description": "The direction of the `Communication`that was sent this will be either `Outgoing` or `Incoming`."
                  },
                  "user_resource": {
                    "$ref": "#/components/schemas/Resourcev1"
                  },
                  "content": {
                    "type": "string",
                    "description": "The message of the `Communication`."
                  },
                  "content_format": {
                    "type": "string",
                    "enum": [
                      "SMS",
                      "PlainText",
                      "HTML"
                    ],
                    "description": "The format of the content. This will be one of the following: `SMS`, `PlainText`, `HTML`."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "Pending",
                      "Done",
                      "Sending",
                      "Failed"
                    ],
                    "description": "The status of the `Communication`. This will be one of the following: `Pending`, `Done`, `Sending`, `Failed`. `Pending` status means the communication will wait till a user actions it. `Done` status means the communication was sent successfully. `Sending` status means the communication will send once it is generated. `Failed` status means the communication encountered a error."
                  },
                  "subject": {
                    "type": "string",
                    "default": "",
                    "description": "The subject of the `Communication`."
                  }
                },
                "required": [
                  "active",
                  "associated_type",
                  "associated_id",
                  "contact_detail_type_id",
                  "destination",
                  "direction",
                  "user_resource",
                  "content",
                  "content_format",
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "communication": {
                            "$ref": "#/components/schemas/Communicationv1"
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v2/communication/{id}": {
      "delete": {
        "summary": "Delete a Communication",
        "operationId": "delete-communication",
        "tags": [
          "Communication"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the communication to delete",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "description": "Bearer token for authentication",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful deletion of the communication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponsev1"
                }
              }
            }
          },
          "404": {
            "description": "Communication not found"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-communication"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update a Communication",
        "description": "Updates a Communication.",
        "operationId": "update-communication",
        "tags": [
          "Communication"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "content-type",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "application/json"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "associated_type": {
                    "type": "string"
                  },
                  "associated_id": {
                    "type": "number"
                  },
                  "contact_detail_type_id": {
                    "type": "number"
                  },
                  "destination": {
                    "type": "string"
                  },
                  "origin": {
                    "type": "string"
                  },
                  "direction": {
                    "type": "string",
                    "enum": [
                      "Outgoing",
                      "Incoming"
                    ]
                  },
                  "user_resource": {
                    "$ref": "#/components/schemas/Resourcev1"
                  },
                  "content": {
                    "type": "string"
                  },
                  "content_format": {
                    "type": "string",
                    "enum": [
                      "SMS",
                      "PlainText",
                      "HTML"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "Pending",
                      "Done",
                      "Sending",
                      "Failed"
                    ]
                  },
                  "subject": {
                    "type": "string"
                  },
                  "template": {
                    "type": "object"
                  },
                  "read_at": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "communication": {
                            "$ref": "#/components/schemas/Communicationv1"
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-communication"
            ]
          }
        ]
      }
    },
    "/v2.1/communication": {
      "get": {
        "summary": "Fetches a list containing Communication(s) — v2 format with token pagination.",
        "operationId": "get-communication-v2-1",
        "tags": [
          "Communication"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Communication-id"
          },
          {
            "$ref": "#/components/parameters/Communication-uid"
          },
          {
            "$ref": "#/components/parameters/Communication-active"
          },
          {
            "$ref": "#/components/parameters/Communication-created_at"
          },
          {
            "$ref": "#/components/parameters/Communication-modified_at"
          },
          {
            "$ref": "#/components/parameters/Communication-associated_type"
          },
          {
            "$ref": "#/components/parameters/Communication-associated_id"
          },
          {
            "$ref": "#/components/parameters/Communication-communicating_type"
          },
          {
            "$ref": "#/components/parameters/Communication-communicating_id"
          },
          {
            "$ref": "#/components/parameters/Communication-contact_detail_type_id"
          },
          {
            "$ref": "#/components/parameters/Communication-destination"
          },
          {
            "$ref": "#/components/parameters/Communication-origin"
          },
          {
            "$ref": "#/components/parameters/Communication-direction"
          },
          {
            "$ref": "#/components/parameters/Communication-sent_as_user"
          },
          {
            "$ref": "#/components/parameters/Communication-content_format"
          },
          {
            "$ref": "#/components/parameters/Communication-status"
          },
          {
            "$ref": "#/components/parameters/Communication-subject"
          },
          {
            "$ref": "#/components/parameters/Communication-template"
          },
          {
            "$ref": "#/components/parameters/Communication-page_size"
          },
          {
            "$ref": "#/components/parameters/Communication-next_token"
          }
        ],
        "responses": {
          "200": {
            "description": "List response using the standard v2-style envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Communication-CommunicationListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Communication-BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Communication-Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/Communication-NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Communication-UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/Communication-TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Communication-InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-communication"
            ]
          }
        ]
      }
    },
    "/v4/communication/sentCommunication": {
      "post": {
        "summary": "Records one or more sent communication records in bulk.",
        "operationId": "create-sent-communication",
        "tags": [
          "Communication V4"
        ],
        "description": "Accepts an array of communication records that have already been sent.\nAll communications are automatically marked as \"Done\" status and externally managed.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SentCommunicationRequest"
                },
                "minItems": 1,
                "maxItems": 500,
                "description": "Array of communication records to create"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successfully recorded communication(s)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/ContentTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-communication"
            ]
          }
        ]
      }
    },
    "/v1/contact": {
      "get": {
        "summary": "Fetches a list containing Contacts",
        "operationId": "get-contact",
        "security": [
          {
            "bearerAuth": [
              "read-contact"
            ]
          }
        ],
        "tags": [
          "Contact"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a Contact.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the Contact is active and usable in ezyVet.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the Contact was created.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the Contact was last modified.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "ownership_id",
            "in": "query",
            "description": "The ID of the ownership Separation to which this Contact belongs.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "code",
            "in": "query",
            "description": "The custom code override for the Contact.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "first_name",
            "in": "query",
            "description": "The Contact's first name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "last_name",
            "in": "query",
            "description": "The Contact's last/family name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "business_name",
            "in": "query",
            "description": "The Contact's business name, if it is a business.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_business",
            "in": "query",
            "description": "If true, the Contact is a business.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "is_customer",
            "in": "query",
            "description": "If true, the Contact is a customer.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "is_supplier",
            "in": "query",
            "description": "If true, the Contact is a supplier.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "is_vet",
            "in": "query",
            "description": "If true, the Contact is a vet.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "is_syndicate",
            "in": "query",
            "description": "If true, the Contact is a syndicate.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "is_staff_member",
            "in": "query",
            "description": "If true, the Contact is a staff member.",
            "schema": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "website",
            "in": "query",
            "description": "The Contact's website.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "address_postal",
            "in": "query",
            "description": "The unique identifier of the PostalAddress.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "stop_credit",
            "in": "query",
            "description": "Specifies if the Contact can be invoiced: OK (invoiceable), WARNING (issues a warning when invoiced), STOP (cannot be invoiced).",
            "schema": {
              "type": "string",
              "enum": [
                "OK",
                "WARNING",
                "STOP"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Sets the limit on the number of items returned (range: 1 - 50).",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ],
              "default": 10
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Specifies the page number of the result.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ],
              "default": 1
            }
          },
          {
            "name": "date_of_birth",
            "in": "query",
            "description": "The date of birth of the primary contact.",
            "schema": {
              "type": "number",
              "default": 0
            }
          },
          {
            "name": "driver_license_number",
            "in": "query",
            "description": "The driver license number of the primary contact.",
            "schema": {
              "type": "string",
              "nullable": true,
              "default": null
            }
          },
          {
            "name": "driver_license_issuer",
            "in": "query",
            "description": "The issuer of the driver license of the primary contact.",
            "schema": {
              "type": "string",
              "nullable": true,
              "default": null
            }
          },
          {
            "name": "driver_license_expiry",
            "in": "query",
            "description": "The expiry date of the driver license of the primary contact.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string",
                  "nullable": true,
                  "default": null
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Contacts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contact": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "code": {
                                "type": "string"
                              },
                              "first_name": {
                                "type": "string"
                              },
                              "last_name": {
                                "type": "string"
                              },
                              "business_name": {
                                "type": "string"
                              },
                              "is_business": {
                                "type": "string"
                              },
                              "is_customer": {
                                "type": "string"
                              },
                              "is_supplier": {
                                "type": "string"
                              },
                              "is_vet": {
                                "type": "string"
                              },
                              "is_syndicate": {
                                "type": "string"
                              },
                              "is_staff_member": {
                                "type": "string"
                              },
                              "website": {
                                "type": "string"
                              },
                              "stop_credit": {
                                "type": "string"
                              },
                              "contact_detail_list": {
                                "type": "array",
                                "items": {
                                  "type": "number"
                                }
                              },
                              "address_physical": {
                                "type": "string"
                              },
                              "address_postal": {
                                "type": "string"
                              },
                              "date_of_birth": {
                                "type": "number"
                              },
                              "driver_license_number": {
                                "type": "string"
                              },
                              "driver_license_issuer": {
                                "type": "string"
                              },
                              "driver_license_expiry": {
                                "type": "number"
                              },
                              "ownership_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "summary": "Creates a single Contact",
        "operationId": "create-contact",
        "tags": [
          "Contact"
        ],
        "description": "Creates a single `Contact`.",
        "security": [
          {
            "bearerAuth": [
              "write-contact"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContactRequestv1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON object containing the created Contact",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateContactResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/contact/{id}": {
      "patch": {
        "summary": "Update a Contact",
        "operationId": "update-contact",
        "security": [
          {
            "bearerAuth": [
              "write-contact"
            ]
          }
        ],
        "tags": [
          "Contact"
        ],
        "description": "Update a single Contact.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "number"
            },
            "description": "The ID of the contact to update."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "last_name": {
                    "type": "string"
                  },
                  "is_no_electronic_marketing": {
                    "type": "string",
                    "nullable": false
                  },
                  "address_physical": {
                    "type": "object",
                    "properties": {
                      "street_1": {
                        "type": "string"
                      },
                      "street_2": {
                        "type": "string"
                      },
                      "suburb": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "region": {
                        "type": "string"
                      },
                      "post_code": {
                        "type": "string"
                      },
                      "country_id": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "number"
                      },
                      "latitude": {
                        "type": "number"
                      }
                    }
                  },
                  "contact_detail_list": {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "value": {
                              "type": "string"
                            },
                            "contact_detail_type_id": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "number"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "stop_credit": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contact": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "code": {
                                "type": "string"
                              },
                              "first_name": {
                                "type": "string"
                              },
                              "last_name": {
                                "type": "string"
                              },
                              "business_name": {
                                "type": "string"
                              },
                              "is_business": {
                                "type": "string"
                              },
                              "is_customer": {
                                "type": "string"
                              },
                              "is_supplier": {
                                "type": "string"
                              },
                              "is_vet": {
                                "type": "string"
                              },
                              "is_syndicate": {
                                "type": "string"
                              },
                              "is_staff_member": {
                                "type": "string"
                              },
                              "website": {
                                "type": "string"
                              },
                              "stop_credit": {
                                "type": "string"
                              },
                              "contact_detail_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "address_physical": {
                                "type": "string"
                              },
                              "address_postal": {
                                "type": "string"
                              },
                              "primary_contact_date_of_birth": {
                                "type": "string"
                              },
                              "driver_license_number": {
                                "type": "string"
                              },
                              "driver_license_issuer": {
                                "type": "string"
                              },
                              "driver_license_expiry": {
                                "type": "number"
                              },
                              "is_no_electronic_marketing": {
                                "type": "string"
                              },
                              "ownership_id": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "summary": "Deletes a Contact",
        "operationId": "delete-contact",
        "tags": [
          "Contact"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the contact to delete",
            "required": true,
            "schema": {
              "type": "number"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": [
              "write-contact"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Contact deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/contactassociation": {
      "get": {
        "summary": "Fetch a list of contact associations",
        "operationId": "get-contactassociation",
        "tags": [
          "Contact Association"
        ],
        "description": "Fetches a list of ContactAssociations.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a ContactAssociation.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "description": "The Contact to fetch the associated contact ids for",
            "schema": {
              "type": "string",
              "default": "61"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ContactAssociation is active and usable in ezyVet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the ContactAssociation was created.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the ContactAssociation was last modified.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Limits the number of items returned.",
            "schema": {
              "type": "number",
              "default": 10
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Specifies the page number of the result.",
            "schema": {
              "type": "number",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of ContactAssociations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "items_page": {
                          "type": "number"
                        },
                        "items_page_total": {
                          "type": "number"
                        },
                        "items_page_size": {
                          "type": "number"
                        },
                        "items_total": {
                          "type": "number"
                        },
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactassociation": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "contact_id": {
                                "type": "number"
                              },
                              "associatedcontact_id": {
                                "type": "number"
                              },
                              "associationclass": {
                                "type": "string",
                                "enum": [
                                  "Family",
                                  "Other"
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-contactassociation"
            ]
          }
        ]
      }
    },
    "/v1/contactdetail": {
      "get": {
        "summary": "Fetch a ContactDetail list",
        "operationId": "get-contactdetail",
        "tags": [
          "Contact Detail"
        ],
        "description": "Fetches a list containing [`ContactDetail`](#contactdetail)(s). (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a [`ContactDetail`](#contactdetail)."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            },
            "description": "If **true**, the [`ContactDetail`](#contactdetail) is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the [`ContactDetail`](#contactdetail) was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the [`ContactDetail`](#contactdetail) was last modified."
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the [`ContactDetail`](#contactdetail), such as \"Home Phone\" or \"Business E-mail\"."
          },
          {
            "name": "value",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The value of the [`ContactDetail`](#contactdetail), such as the number, or the email (depending on its [`ContactDetailType`](#contactdetailtype))."
          },
          {
            "name": "value_cleaned",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The value of the [`ContactDetail`](#contactdetail) record which has been cleaned of all special characters and prefixed with the country code. This filter can be used for phone or fax numbers but it should not be used for email addresses."
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID of the [`Contact`](#contact) to whom this [`ContactDetail`](#contactdetail) is assigned."
          },
          {
            "name": "contact_detail_type_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID of the [`ContactDetailType`](#contactdetailtype) of this [`ContactDetail`](#contactdetail)."
          },
          {
            "name": "preferred",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "If **true**, this [`ContactDetail`](#contactdetail) is a preferred contact method for the related [`Contact`](#contact)."
          },
          {
            "name": "subscription_groups",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "A list of subscription groups that this [`ContactDetail`](#contactdetail) is subscribed to (General, Reminders, Accounts)."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactdetail": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "boolean",
                                "default": true
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "string"
                              },
                              "value_cleaned": {
                                "type": "string"
                              },
                              "contact_detail_type_id": {
                                "type": "string"
                              },
                              "preferred": {
                                "type": "boolean",
                                "default": false
                              },
                              "subscription_groups": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-contactdetail"
            ]
          }
        ]
      },
      "post": {
        "summary": "Creates a single ContactDetail record",
        "operationId": "create-contactdetail",
        "tags": [
          "Contact Detail"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  },
                  "contact_id": {
                    "type": "string"
                  },
                  "contact_detail_type_id": {
                    "type": "string"
                  },
                  "preferred": {
                    "type": "boolean",
                    "default": false
                  },
                  "subscription_groups": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ContactDetail created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactdetail": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "value_cleaned": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "string"
                              },
                              "contact_detail_type_id": {
                                "type": "string"
                              },
                              "preferred": {
                                "type": "boolean"
                              },
                              "subscription_groups": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-contactdetail"
            ]
          }
        ]
      }
    },
    "/v1/contactdetail/{id}": {
      "patch": {
        "summary": "Updates an existing ContactDetail record",
        "operationId": "update-contactdetail",
        "tags": [
          "Contact Detail"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-contactdetail"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ContactDetail is active and usable in ezyVet.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "The name of the ContactDetail, such as 'Home Phone' or 'Business E-mail'.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "value",
            "in": "query",
            "description": "The value of the ContactDetail, such as the number, or the email (depending on its ContactDetailType).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "description": "The ID of the Contact to whom this ContactDetail is assigned.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_detail_type_id",
            "in": "query",
            "description": "The ID of the ContactDetailType of this ContactDetail.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "preferred",
            "in": "query",
            "description": "If true, this ContactDetail is a preferred contact method for the related Contact.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "subscription_groups",
            "in": "query",
            "description": "A list of subscription groups that this ContactDetail is subscribed to (General, Reminders, Accounts).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  },
                  "contact_id": {
                    "type": "string"
                  },
                  "contact_detail_type_id": {
                    "type": "string"
                  },
                  "subscription_groups": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactdetail": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "value_cleaned": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "string"
                              },
                              "contact_detail_type_id": {
                                "type": "string"
                              },
                              "preferred": {
                                "type": "boolean"
                              },
                              "subscription_groups": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/contactdetailtype": {
      "get": {
        "summary": "Fetch a ContactDetailType list",
        "operationId": "get-contactdetailtype",
        "tags": [
          "Contact Detail Type"
        ],
        "description": "Fetches a list containing `ContactDetailType`(s). (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify an `ContactDetailType`.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If `true`, the `ContactDetailType` is active and usable in ezyVet.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the `ContactDetailType` was created.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the `ContactDetailType` was last modified.",
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "The name of the `ContactDetailType`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "procedure": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-contactdetailtype"
            ]
          }
        ]
      }
    },
    "/v1/country": {
      "get": {
        "summary": "Fetch a Country list",
        "operationId": "get-country",
        "tags": [
          "Country"
        ],
        "description": "Fetches a list containing Country(s). (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a Country."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "If true, the Country is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the Country was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the Country was last modified."
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the Country."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 10
            },
            "description": "Limits the number of items returned."
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 1
            },
            "description": "Specifies the page number of the result."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of countries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "country": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-country"
            ]
          }
        ]
      }
    },
    "/v2/contact": {
      "get": {
        "summary": "Fetches a list containing Contacts",
        "operationId": "get-contactv2",
        "tags": [
          "Contact V2"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a Contact.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "uid",
            "in": "query",
            "description": "The globally unique identifier to identify a Contact.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the Contact was created.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the Contact was last modified.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the Contact is active and usable in ezyVet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code",
            "in": "query",
            "description": "The custom code override for the Contact.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "first_name",
            "in": "query",
            "description": "The Contact's first name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "last_name",
            "in": "query",
            "description": "The Contact's last/family name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "business_name",
            "in": "query",
            "description": "The Contact's business name, if it is a business.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_customer",
            "in": "query",
            "description": "If true, the Contact is a customer.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_vet",
            "in": "query",
            "description": "If true, the Contact is a vet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_supplier",
            "in": "query",
            "description": "If true, the Contact is a supplier.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_syndicate",
            "in": "query",
            "description": "If true, the Contact is a syndicate.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_staff_member",
            "in": "query",
            "description": "If true, the Contact is a staff member.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stop_credit",
            "in": "query",
            "description": "Specifies if the Contact can be invoiced: OK (invoiceable), WARNING (issues a warning when invoiced), STOP (cannot be invoiced).",
            "schema": {
              "type": "string",
              "enum": [
                "OK",
                "WARNING",
                "STOP"
              ]
            }
          },
          {
            "name": "website",
            "in": "query",
            "description": "The Contact's website.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "address_physical",
            "in": "query",
            "description": "The unique identifier of the PhysicalAddress.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "address_postal",
            "in": "query",
            "description": "The unique identifier of the PostalAddress.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contact": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "uid": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "code": {
                                "type": "string"
                              },
                              "first_name": {
                                "type": "string"
                              },
                              "last_name": {
                                "type": "string"
                              },
                              "business_name": {
                                "type": "string"
                              },
                              "is_customer": {
                                "type": "boolean"
                              },
                              "is_business": {
                                "type": "boolean"
                              },
                              "is_vet": {
                                "type": "boolean"
                              },
                              "is_supplier": {
                                "type": "boolean"
                              },
                              "is_syndicate": {
                                "type": "boolean"
                              },
                              "is_staff_member": {
                                "type": "boolean"
                              },
                              "stop_credit": {
                                "type": "string"
                              },
                              "website": {
                                "type": "string"
                              },
                              "address_physical": {
                                "type": "number"
                              },
                              "address_postal": {
                                "type": "number"
                              },
                              "contact_detail_list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "number"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "type_id": {
                                      "type": "number"
                                    },
                                    "preferred": {
                                      "type": "boolean"
                                    },
                                    "value": {
                                      "type": "string"
                                    },
                                    "value_cleaned": {
                                      "type": "string"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-contact"
            ]
          }
        ]
      }
    },
    "/v4/contact": {
      "get": {
        "summary": "List all contacts",
        "description": "Retrieve a paginated list of all contacts with optional filtering.\n\nReturns complete contact data including addresses, emails, phones, and subscriptions (same as individual contact endpoints). Successful responses include `meta` (with `nextToken` when another page exists).\n\n**Pagination (same pattern as GET /v4/species):** On the first page, send `pageSize` and any list filters as query parameters. The `nextToken` value is a Base64URL-encoded JSON object that embeds `lastContactId`, `pageSize`, and a snapshot of the supported filters (`id`, `active`, `createdAt`, `updatedAt`, `code`, `name`). For the next page, send **only** `nextToken` (plus optional infrastructure keys such as `_ezyhost`); do not repeat `pageSize` or list filters in the query string.\n",
        "operationId": "get-contact-v4",
        "tags": [
          "Contact V4"
        ],
        "security": [
          {
            "bearerAuth": [
              "read-contact"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ContactV4-pageSize"
          },
          {
            "$ref": "#/components/parameters/ContactV4-nextToken"
          },
          {
            "$ref": "#/components/parameters/ContactV4-id"
          },
          {
            "$ref": "#/components/parameters/ContactV4-active"
          },
          {
            "$ref": "#/components/parameters/ContactV4-createdAt"
          },
          {
            "$ref": "#/components/parameters/ContactV4-updatedAt"
          },
          {
            "$ref": "#/components/parameters/ContactV4-code"
          },
          {
            "$ref": "#/components/parameters/ContactV4-name"
          }
        ],
        "responses": {
          "200": {
            "description": "Contacts retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactV4-ContactListResponse"
                },
                "examples": {
                  "contact_list_response": {
                    "summary": "Contact list response with full contact details",
                    "value": {
                      "meta": {
                        "nextToken": "AB3e7Z2i9FJu0j7hLExLp"
                      },
                      "data": [
                        {
                          "id": "contact-abc123",
                          "legacyId": 1,
                          "code": "CUST001",
                          "name": "John Smith",
                          "title": "Mr",
                          "first": "John",
                          "last": "Smith",
                          "website": "https://johnsmith.com",
                          "confirmed": true,
                          "notes": "Preferred customer",
                          "active": true,
                          "hospitalUid": "hosp-9z8y7x",
                          "ownershipseparationUid": "ownsep-1a2b3c",
                          "isBusiness": false,
                          "isCustomer": true,
                          "isSupplier": false,
                          "isVet": false,
                          "isSyndicate": false,
                          "isStaffMember": false,
                          "isPharmacy": false,
                          "createdAt": "2024-01-15T10:30:00Z",
                          "updatedAt": "2024-01-16T14:45:00Z",
                          "addressPhysical": {
                            "id": 1,
                            "name": "John Smith Home",
                            "street1": "123 Main Street",
                            "city": "Los Angeles",
                            "state": "California",
                            "postcode": "90210",
                            "country": "United States"
                          },
                          "emails": [
                            {
                              "emailId": "email_abc123def456",
                              "legacyId": 1,
                              "name": "Primary Email",
                              "content": "john@example.com",
                              "subscriptions": [
                                {
                                  "name": "General"
                                }
                              ]
                            }
                          ],
                          "phones": [
                            {
                              "phoneId": "phone_xyz789ghi012",
                              "legacyId": 1,
                              "name": "Mobile Phone",
                              "content": "+16502530000",
                              "subscriptions": [
                                {
                                  "name": "General"
                                }
                              ]
                            }
                          ]
                        }
                      ],
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ContactV4-BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ContactV4-Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ContactV4-NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ContactV4-UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/ContactV4-TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ContactV4-InternalServerError"
          }
        }
      },
      "post": {
        "summary": "Create one or more contacts",
        "description": "Create one or more contacts in the ezyVet system.\n\n## Request shape\n\nSend a JSON **array** of 1-100 contact objects. To create a single contact, pass a one-element array. There is no single-object body shape — the wire contract is uniform regardless of how many contacts the caller is creating.\n\nThe response is always the array envelope (`{ \"data\": [Contact, ...], \"errors\": [ ... ] }`) — no `meta`, no `Location` header. Creates do not paginate. The 100-item cap may be raised in a future release.\n\n## Validation rules (per item)\n\n- `name` is required.\n- `ownershipseparationUid` and `hospitalUid` are both required (see \"Ownership\" below).\n- At least one entry across `emails` and `phones` is required so the contact is reachable (preserved from the legacy v1 rule).\n- `addressPhysical` and `addressPostal` are independent optional objects. Either, both, or neither may be supplied.\n- `stopCredit`, when supplied, must be one of `OK`, `WARNING`, `STOP`.\n\n## Ownership (deviation from legacy v1)\n\nv4 requires the caller to state the owning ownership-separation node explicitly via `ownershipseparationUid`; it is written verbatim to `contactdata_osr_ownership`. This is a deliberate deviation from legacy v1, which derived the owner from the acting user's last-active resource — a value that is empty/ambiguous for API and system callers and could silently produce orphaned or mis-scoped contacts. Consequences:\n\n- Omitting `ownershipseparationUid` (or sending it blank) → 400 `OwnershipSeparationRequired`.\n- An unknown ownership UID → 400 `InvalidOwnershipSeparation`.\n- `hospitalUid` is also required (blank/missing → 400 `HospitalRequired`; unknown → 400 `InvalidHospital`). It must be in the same ownership branch as `ownershipseparationUid` — an ancestor (or equal) of the hospital's business, or a descendant of that business that references this hospital. A contradicting pair → 400 `OwnershipHospitalMismatch`.\n- `emails[].subscriptions` and `phones[].subscriptions`, when supplied, must contain only names from the fixed subscription enum (`Reminders`, `Accounts`, `General`, `Sales`, `Postal`) — the same set the legacy framework defines in `SubscriptionGroupConstants`. Unknown names return `InvalidSubscriptionGroup`.\n\nValidation errors are collected across **every** item in the batch and returned together in the `errors` array. If any validation error is present, **no rows are written** — creates are atomic.\n\n## Idempotency\n\n`code` is a regular UNIQUE field, not an idempotency key. Duplicates within a single batch return 400 `DuplicateContactCodeInRequest`; duplicates against an existing DB row return 400 `DuplicateContactCode`. Optional retry-safe idempotency via an `Idempotency-Key` HTTP header is planned for a future release.\n\n## Notes\n\nSubscription group memberships are accepted on `emails[].subscriptions` and `phones[].subscriptions`. Names must come from the fixed subscription enum (`Reminders`, `Accounts`, `General`, `Sales`, `Postal`) — the same set the legacy framework defines in `SubscriptionGroupConstants`. Unknown names return `InvalidSubscriptionGroup`.\n\n## Breaking changes from v1\n\nv4 deliberately diverges from legacy v1 behaviour for a small set of fields. Callers migrating from `/api/v1/contact` should review these before integrating:\n\n- **`driverLicenseNumber`, `driverLicenseIssuer`, `nationalIdNumber`, `passportNumber` — restricted characters.** v1 silently stripped `*~\"'` (and `*~\"` for `driverLicenseIssuer`) from the supplied value before INSERT. v4 rejects with a 400 `InvalidCharacters` error; the JSON pointer `target` identifies the offending field. Whitespace trimming is unchanged — clean inputs still write byte-identical rows to v1.\n- **`phones[].content` — E.164 required.** v1 accepted free-form phone numbers and reformatted them to international format server-side. v4 requires each phone number in E.164 format (`+<countrycode><number>`, no spaces/dashes/parentheses, e.g. `+6495550001`) and rejects anything else with a 400 `InvalidPhoneNumber` error; the JSON pointer `target` identifies the offending entry. Because E.164 carries its own country code, no default-country/region is inferred.\n",
        "operationId": "create-contact-v4",
        "tags": [
          "Contact V4"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-contact"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "minItems": 1,
                "maxItems": 100,
                "items": {
                  "$ref": "#/components/schemas/ContactV4-CreateContactRequest"
                }
              },
              "examples": {
                "single_contact": {
                  "summary": "Single contact (one-element array)",
                  "value": [
                    {
                      "name": "Jane Doe",
                      "ownershipseparationUid": "ownsep-1a2b3c",
                      "hospitalUid": "hosp-9z8y7x",
                      "isCustomer": true,
                      "emails": [
                        {
                          "content": "jane@example.com"
                        }
                      ]
                    }
                  ]
                },
                "full_single_contact": {
                  "summary": "Full single contact (one-element array) with addresses, emails, phones",
                  "value": [
                    {
                      "name": "Acme Veterinary Supplies",
                      "ownershipseparationUid": "ownsep-1a2b3c",
                      "hospitalUid": "hosp-9z8y7x",
                      "code": "ACME001",
                      "isBusiness": true,
                      "isSupplier": true,
                      "stopCredit": "OK",
                      "notes": "Preferred vaccine supplier",
                      "addressPhysical": {
                        "name": "Acme HQ",
                        "street1": "12 Oak St",
                        "city": "Auckland",
                        "postcode": "1010",
                        "country": "New Zealand"
                      },
                      "emails": [
                        {
                          "name": "Sales",
                          "content": "sales@acme.example",
                          "subscriptions": [
                            "General",
                            "Sales"
                          ]
                        }
                      ],
                      "phones": [
                        {
                          "name": "Main",
                          "content": "+6495550001",
                          "subscriptions": [
                            "General"
                          ]
                        }
                      ]
                    }
                  ]
                },
                "bulk_contacts": {
                  "summary": "Bulk create (multi-element array)",
                  "value": [
                    {
                      "name": "Jane Doe",
                      "ownershipseparationUid": "ownsep-1a2b3c",
                      "hospitalUid": "hosp-9z8y7x",
                      "isCustomer": true,
                      "emails": [
                        {
                          "content": "jane@example.com"
                        }
                      ]
                    },
                    {
                      "name": "John Smith",
                      "ownershipseparationUid": "ownsep-4d5e6f",
                      "hospitalUid": "hosp-9z8y7x",
                      "isCustomer": true,
                      "emails": [
                        {
                          "content": "john@example.com"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Returned when the request was processed and every contact was inserted. The response always carries the array envelope `{ data: [Contact, ...], errors: [] }` — single-contact clients pass a one-element array and receive a one-element array back.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactV4-ContactBulkCreateResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ContactV4-BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ContactV4-Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/ContactV4-Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/ContactV4-NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ContactV4-UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/ContactV4-TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ContactV4-InternalServerError"
          }
        }
      }
    },
    "/v4/contact/{id}": {
      "get": {
        "summary": "Get a specific contact by ID",
        "description": "Retrieve detailed information for a specific contact by ID (UID) including full physical and postal address details.\n",
        "operationId": "get-contact-by-id-v4",
        "tags": [
          "Contact V4"
        ],
        "security": [
          {
            "bearerAuth": [
              "read-contact"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Contact ID (UID)",
            "schema": {
              "type": "string",
              "maxLength": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A single Contact wrapped in the standard envelope. Wire shape: `{ \"data\": { ... } }` — `data` is the Contact object directly, not an array. No `meta`. `errors` is omitted when empty.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactV4-ContactResponse"
                },
                "examples": {
                  "Example": {
                    "summary": "",
                    "value": {
                      "data": {
                        "id": "contact-abc123",
                        "legacyId": 1,
                        "number": "C0000000001",
                        "code": "SMITH001",
                        "name": "John Smith",
                        "title": "Mr",
                        "first": "John",
                        "last": "Smith",
                        "website": "https://johnsmith.com",
                        "confirmed": true,
                        "notes": "Preferred customer with multiple pets. Regular visitor.",
                        "notesImportant": true,
                        "noSpam": false,
                        "active": true,
                        "hospitalUid": "hosp-9z8y7x",
                        "ownershipseparationUid": "ownsep-1a2b3c",
                        "isBusiness": false,
                        "isCustomer": true,
                        "isSupplier": false,
                        "isVet": false,
                        "isSyndicate": false,
                        "isStaffMember": false,
                        "isPharmacy": false,
                        "driverLicenseNumber": "DL123456789",
                        "driverLicenseIssuer": "DMV California",
                        "driverLicenseExpiry": "2025-12-31",
                        "addressPhysical": {
                          "id": 1,
                          "name": "John Smith Home",
                          "street1": "123 Main Street",
                          "street2": "Apt 4B",
                          "suburb": "Downtown",
                          "city": "Los Angeles",
                          "region": "Los Angeles County",
                          "state": "California",
                          "postcode": "90210",
                          "country": "United States",
                          "latitude": 34.0522,
                          "longitude": -118.2437,
                          "receivesReminders": true
                        },
                        "addressPostal": {
                          "id": 2,
                          "name": "John Smith Mailing",
                          "street1": "PO Box 1234",
                          "city": "Los Angeles",
                          "state": "California",
                          "postcode": "90210",
                          "country": "United States",
                          "receivesReminders": false
                        },
                        "emails": [
                          {
                            "emailId": "email_abc123def456",
                            "legacyId": 1,
                            "name": "Primary Email",
                            "content": "john@example.com",
                            "subscriptions": [
                              {
                                "name": "General"
                              },
                              {
                                "name": "Reminders"
                              }
                            ]
                          },
                          {
                            "emailId": "email_def456ghi789",
                            "legacyId": 2,
                            "name": "Work Email",
                            "content": "john.smith@company.com",
                            "subscriptions": [
                              {
                                "name": "General"
                              }
                            ]
                          }
                        ],
                        "phones": [
                          {
                            "phoneId": "phone_xyz789ghi012",
                            "legacyId": 1,
                            "name": "Mobile Phone",
                            "content": "+16502530000",
                            "subscriptions": [
                              {
                                "name": "General"
                              },
                              {
                                "name": "Reminders"
                              }
                            ]
                          },
                          {
                            "phoneId": "phone_abc456jkl345",
                            "legacyId": 2,
                            "name": "Home Phone",
                            "content": "+14155552671",
                            "subscriptions": [
                              {
                                "name": "General"
                              }
                            ]
                          }
                        ],
                        "createdAt": "2024-01-15T10:30:00Z",
                        "updatedAt": "2024-01-16T14:45:00Z"
                      },
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ContactV4-BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ContactV4-Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ContactV4-NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ContactV4-UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/ContactV4-TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ContactV4-InternalServerError"
          }
        }
      }
    },
    "/v2/contactdetail": {
      "post": {
        "summary": "Creates a single ContactDetail record",
        "operationId": "create-contactdetailv2",
        "tags": [
          "Contact Detail V2"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  },
                  "contact_id": {
                    "type": "number"
                  },
                  "contact_uid": {
                    "type": "string"
                  },
                  "type_id": {
                    "type": "string"
                  },
                  "preferred": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "name",
                  "value",
                  "contact_id",
                  "contact_uid",
                  "type_id"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "ContactDetail created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactdetail": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "uid": {
                                "type": "string"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "number"
                              },
                              "contact_uid": {
                                "type": "string"
                              },
                              "value_cleaned": {
                                "type": "string"
                              },
                              "type_id": {
                                "type": "string"
                              },
                              "preferred": {
                                "type": "boolean",
                                "default": false
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-contactdetail"
            ]
          }
        ]
      },
      "get": {
        "summary": "Fetch a ContactDetail list",
        "operationId": "get-contactdetailv2",
        "tags": [
          "Contact Detail V2"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify a ContactDetail.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the ContactDetail is active and usable in ezyVet.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the ContactDetail was created.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the ContactDetail was last modified.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "The name of the ContactDetail, such as 'Home Phone' or 'Business E-mail'.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "value",
            "in": "query",
            "description": "The value of the ContactDetail, such as the number, or the email (depending on its ContactDetailType).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "value_cleaned",
            "in": "query",
            "description": "The value of the ContactDetail record which has been cleaned of all special characters and prefixed with the country code. This filter can be used for phone or fax numbers but it should not be used for email addresses.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "description": "The ID of the Contact to whom this ContactDetail is assigned.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "type_id",
            "in": "query",
            "description": "The ID of the ContactDetailType of this ContactDetail.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "preferred",
            "in": "query",
            "description": "If true, this ContactDetail is a preferred contact method for the related Contact.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of ContactDetails",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactdetail": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "number"
                              },
                              "uid": {
                                "type": "string"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "modified_at": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "number"
                              },
                              "contact_uid": {
                                "type": "string"
                              },
                              "value_cleaned": {
                                "type": "string"
                              },
                              "type_id": {
                                "type": "string"
                              },
                              "preferred": {
                                "type": "boolean",
                                "default": false
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-contactdetail"
            ]
          }
        ]
      }
    }
  }
}
