{"openapi":"3.1.0","info":{"title":"CRM Manager API","version":"0.1.0","description":"Event-sourced registry of the parties a tenant deals with, shaped like a storefront's: people (customers, unique per tenant by email) and companies (B2B customers and suppliers, with locations and contacts). Other services name parties by id only; the identifying details of a person are sealed in this service's journal under a per-person key and erased by destroying that key, so a right-to-erasure request is honoured without rewriting history."},"paths":{"/people":{"get":{"tags":["people"],"operationId":"people.list","parameters":[{"name":"q","in":"query","schema":{"type":"string","maxLength":120},"required":false,"example":"raman"},{"name":"email","in":"query","schema":{"type":"string"},"required":false},{"name":"status","in":"query","schema":{"type":"string"},"required":false},{"name":"role","in":"query","schema":{"type":"string"},"required":false,"example":"customer"},{"name":"tag","in":"query","schema":{"$ref":"#/components/schemas/Tag"},"required":false},{"name":"companyId","in":"query","schema":{"$ref":"#/components/schemas/CmpId"},"required":false},{"name":"sort","in":"query","schema":{"$ref":"#/components/schemas/PersonSortKey"},"required":false,"example":"name"},{"name":"order","in":"query","schema":{"$ref":"#/components/schemas/SortOrder"},"required":false,"example":"asc"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PersonPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonPageEncoded"},"examples":{"contract":{"summary":"people.list","value":{"items":[{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","status":"active","tags":["trade"],"roles":["customer"],"taxExempt":false,"emailMarketing":"subscribed","smsMarketing":"not-subscribed","profile":{"email":"priya.raman@harbourceramics.example","firstName":"Priya","lastName":"Raman","phone":"+61 400 555 014","locale":"en-AU","addresses":[{"id":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01","firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160","retired":false}]},"createdAt":"2026-10-20T09:00:00.000Z","updatedAt":"2026-10-20T09:00:00.000Z"}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the tenant's people (the customers), newest first. `q` narrows by name, email or phone (case-insensitive substring), `email` is an exact match after normalisation (the lookup a checkout or an import does), `status` a comma-separated set (active by default; `erased` lists the tombstones), `role` any of `customer`/`supplier`, `tag` one tag, `companyId` the contacts of one company; `sort`/`order` pick the column and direction. `total` counts every match regardless of the page; `limit` defaults to 100 and is capped at 1000 (an over-cap request is clamped); page with `offset`. An erased person answers with `profile: null` and the placeholder name — nothing identifying survives erasure.\n\nRequires `customers:read`.","x-mcp-tool":{"name":"crm_list_people","title":"CRM: List people","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read"],"x-example-source":{"origin":"contract"}},"post":{"tags":["people"],"operationId":"people.create","parameters":[],"security":[{"bearer":[]}],"responses":{"201":{"description":"Person","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonEncoded"},"examples":{"contract":{"summary":"people.create","value":{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","status":"active","tags":["trade"],"roles":["customer"],"taxExempt":false,"emailMarketing":"subscribed","smsMarketing":"not-subscribed","profile":{"email":"priya.raman@harbourceramics.example","firstName":"Priya","lastName":"Raman","phone":"+61 400 555 014","locale":"en-AU","addresses":[{"id":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01","firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160","retired":false}]},"createdAt":"2026-10-20T09:00:00.000Z","updatedAt":"2026-10-20T09:00:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"PersonEmailConflict | PersonPhoneConflict | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PersonEmailConflictEncoded"},{"$ref":"#/components/schemas/PersonPhoneConflictEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Register a person. Email (required) and phone are each unique per tenant once normalised: a second person with either is refused with 409 `PersonEmailConflict` / `PersonPhoneConflict` naming the holder. The identifying details are sealed under a key minted for this person before the fact is written, so the journal carries only an opaque profile and the email's digest. Appends `crm.person-created`. `reference` (the caller's own key for the act — an import row, a checkout, a minted id) is required and is the idempotency key: a retry with the same reference returns the person already registered and appends nothing.\n\nRequires `customers:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePersonEncoded"},"example":{"reference":"checkout:5521","email":"Priya.Raman@harbourceramics.example","firstName":"Priya","lastName":"Raman","phone":"+61 400 555 014","locale":"en-AU","addresses":[{"firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"}],"tags":["trade"],"roles":["customer"],"emailMarketing":"subscribed"}}},"required":true},"x-mcp-tool":{"name":"crm_create_person","title":"CRM: Create person","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:write"],"x-example-source":{"origin":"contract"}}},"/people/{personId}":{"get":{"tags":["people"],"operationId":"people.get","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Person","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonEncoded"},"examples":{"contract":{"summary":"people.get","value":{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","status":"active","tags":["trade"],"roles":["customer"],"taxExempt":false,"emailMarketing":"subscribed","smsMarketing":"not-subscribed","profile":{"email":"priya.raman@harbourceramics.example","firstName":"Priya","lastName":"Raman","phone":"+61 400 555 014","locale":"en-AU","addresses":[{"id":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01","firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160","retired":false}]},"createdAt":"2026-10-20T09:00:00.000Z","updatedAt":"2026-10-20T09:00:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"One person by id — profile, saved addresses, tags, tax and marketing settings. An erased person still answers (their id is referenced elsewhere) with `status: erased` and `profile: null`.\n\nRequires `customers:read`.","x-mcp-tool":{"name":"crm_get_person","title":"CRM: Get person","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read"],"x-example-source":{"origin":"contract"}},"put":{"tags":["people"],"operationId":"people.update","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Person","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonEncoded"},"examples":{"contract":{"summary":"people.update","value":{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","status":"active","tags":["trade"],"roles":["customer"],"taxExempt":false,"emailMarketing":"subscribed","smsMarketing":"not-subscribed","profile":{"email":"priya.raman@harbourceramics.example","firstName":"Priya","lastName":"Raman","phone":"+61 400 555 015","locale":"en-AU","addresses":[{"id":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01","firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160","retired":false}]},"createdAt":"2026-10-20T09:00:00.000Z","updatedAt":"2026-10-20T09:12:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"PersonErased | PersonEmailConflict | PersonPhoneConflict | AddressNotFound | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PersonErasedEncoded"},{"$ref":"#/components/schemas/PersonEmailConflictEncoded"},{"$ref":"#/components/schemas/PersonPhoneConflictEncoded"},{"$ref":"#/components/schemas/AddressNotFoundEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Change what is known about a person. Every field is optional; a field sent replaces what was there (`addresses` is the whole set afterwards — an address without an `id` is new; one with an id not on the person is refused with 409 `AddressNotFound`; one sent with different details **retires that version and mints a new id**, since addresses are immutable so that what an order pinned never changes; an active address left out is retired), `null` clears an optional detail, and a changed email or phone is held to the same uniqueness rule as creation. An erased person cannot be changed (409 `PersonErased`). Appends `crm.person-updated` carrying the whole record, sealed, alongside `changed` — the names of the fields that actually moved, in the clear, so a timeline can say what happened without holding the key. Idempotent by content: a retry that says what the record already says appends nothing.\n\nRequires `customers:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePersonEncoded"},"example":{"phone":"+61 400 555 015"}}},"required":true},"x-mcp-tool":{"name":"crm_update_person","title":"CRM: Update person","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:write"],"x-example-source":{"origin":"contract"}}},"/people/{personId}/notes":{"get":{"tags":["people"],"operationId":"people.notes","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"20"},{"name":"before","in":"query","schema":{"$ref":"#/components/schemas/NoteId"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PartyNotePage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartyNotePageEncoded"},"examples":{"contract":{"summary":"people.notes","value":{"items":[{"id":"note_01a1588b-3e50-7f61-8a72-9b8c7d6e5f40","subjectId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","body":"Prefers deliveries before 10am. Dock is round the back.","by":{"_tag":"user","id":"usr_01a15889-fa80-7b11-8c22-3d4e5f6a7b8c"},"postedAt":"2026-10-20T09:20:00.000Z"}]}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the notes staff have posted about this person, newest first — the dated entries a timeline shows, as opposed to the standing `note` on the profile, which is one field that gets rewritten. Paged by cursor, back to the first note: `limit` is 1–100 (20 when omitted), and a page carries `next` while older notes remain — pass it as `before`. A note whose words did not survive erasure answers with `body: null`: the fact that someone wrote at that moment is not itself personal data.\n\nRequires `customers:read`.","x-mcp-tool":{"name":"crm_person_notes","title":"CRM: Person notes","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read"],"x-example-source":{"origin":"contract"}},"post":{"tags":["people"],"operationId":"people.postNote","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"201":{"description":"PartyNote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartyNoteEncoded"},"examples":{"contract":{"summary":"people.postNote","value":{"id":"note_01a1588b-3e50-7f61-8a72-9b8c7d6e5f40","subjectId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","body":"Prefers deliveries before 10am. Dock is round the back.","by":{"_tag":"user","id":"usr_01a15889-fa80-7b11-8c22-3d4e5f6a7b8c"},"postedAt":"2026-10-20T09:20:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"PersonErased | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PersonErasedEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Post a note about a person — a dated remark on their timeline, never edited afterwards. The body is sealed under the person's own key before the fact is written, because staff commentary about someone is personal data about them: erasing the person destroys the key and the note's words with it, leaving the entry readable as \"a note was posted\" and nothing more. An erased person takes no new notes (409 `PersonErased`). Appends `crm.note-posted`. `reference` (the caller's own key for the act — the composer mints one per submission) is required and is the idempotency key: a retry with the same reference returns the note already posted and appends nothing.\n\nRequires `customers:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostNoteEncoded"},"example":{"reference":"note:7f3a2c","body":"Prefers deliveries before 10am. Dock is round the back."}}},"required":true},"x-mcp-tool":{"name":"crm_post_person_note","title":"CRM: Post person note","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:write"],"x-example-source":{"origin":"contract"}}},"/people/{personId}/addresses/retired":{"get":{"tags":["people"],"operationId":"people.retiredAddresses","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"RetiredAddressPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetiredAddressPageEncoded"},"examples":{"contract":{"summary":"people.retiredAddresses","value":{"items":[{"id":"adr_01a15889-fb10-7c3d-8e4f-5a6b7c8d9e0f","personId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","address":{"firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"3 Wharf Road","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"retiredAt":"2026-10-20T10:05:00.000Z"}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the address versions this person's edits and removals retired, most recently retired first — off the record, which carries the active addresses only, and kept because an order may have pinned one. Each names the version that `supersededBy` it, if any. An erased person's versions answer with `address: null`. `limit` is 1–200 (50 when omitted); page with `offset`.\n\nRequires `customers:read`.","x-mcp-tool":{"name":"crm_person_retired_addresses","title":"CRM: Person retired addresses","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read"],"x-example-source":{"origin":"contract"}}},"/people/{personId}/contacts":{"get":{"tags":["people"],"operationId":"people.companies","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"CompanyContactPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyContactPageEncoded"},"examples":{"contract":{"summary":"people.companies","value":{"items":[{"companyId":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","personId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","title":"Purchasing manager","main":true}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the companies this person acts for — one contact row per company, with their title there and whether they are its main contact — company-id ordered. `limit` is 1–200 (50 when omitted); page with `offset`.\n\nRequires `customers:read`.","x-mcp-tool":{"name":"crm_person_companies","title":"CRM: Person companies","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read"],"x-example-source":{"origin":"contract"}}},"/people/{personId}/erase":{"post":{"tags":["people"],"operationId":"people.erase","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Person","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonEncoded"},"examples":{"contract":{"summary":"people.erase","value":{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","status":"erased","tags":[],"roles":["customer"],"taxExempt":false,"emailMarketing":"unsubscribed","smsMarketing":"unsubscribed","profile":null,"createdAt":"2026-10-20T09:00:00.000Z","updatedAt":"2026-10-20T11:30:00.000Z","erasedAt":"2026-10-20T11:30:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Erase a person's personal data — a channel's customer redaction, and the platform's answer to a right-to-erasure request. The key that sealed every profile this person ever had is destroyed in the same transaction the fact is written in: the journal keeps its events (replay stays total, every document that named the `psn_` id still resolves, every count still adds up) but nothing in them can be read again, and the projection row becomes a tombstone — `status: erased`, `profile: null`, tags dropped, marketing unsubscribed — named \"Erased person\" wherever it appears. The email is released: the same address may register a new person afterwards, who shares nothing with the old one. Appends `crm.person-erased`. Idempotent by state: the person's own `status` is the key — a retry, or any erase of a person already `erased`, is acknowledged and appends nothing. `reference` (the request being honoured — a ticket number, a minted key) is required and is recorded on the fact, not spent as a single-use token: one DSAR ticket may name several subjects, so the same reference erases each of them. Requires the `admin` job.\n\nRequires `privacy:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErasePersonEncoded"},"example":{"reference":"DSAR-2026-0187","reason":"Customer asked for their data to be erased"}}},"required":true},"x-mcp-tool":{"name":"crm_erase_person","title":"CRM: Erase person","toolset":"crm","readOnlyHint":false,"destructiveHint":true,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["privacy:write"],"x-example-source":{"origin":"contract"}}},"/people/{personId}/account-rep":{"put":{"tags":["people"],"operationId":"people.setAccountRep","parameters":[{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Person","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonEncoded"},"examples":{"contract":{"summary":"people.setAccountRep","value":{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","status":"active","tags":["trade"],"roles":["customer"],"taxExempt":false,"emailMarketing":"subscribed","smsMarketing":"not-subscribed","profile":{"email":"priya.raman@harbourceramics.example","firstName":"Priya","lastName":"Raman","phone":"+61 400 555 014","locale":"en-AU","addresses":[{"id":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01","firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160","retired":false}]},"createdAt":"2026-10-20T09:00:00.000Z","updatedAt":"2026-10-29T09:00:00.000Z","accountRepId":"usr_019e5a10-51b0-7a42-8c1d-0e9f3a6b2c71"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Name the member who manages a customer's account, or `null` for nobody (`docs/commissions.md`). The order form offers them as the order's rep, and in `account-manager` mode they earn the commission on the customer's orders placed from now on (a company's account rep comes first). Not personal data: kept through erasure. Appends `crm.person-account-rep-set`. Idempotent by content: a retry naming the same member is acknowledged and appends nothing.\n\nRequires `customers:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetAccountRepEncoded"},"example":{"accountRepId":"usr_019e5a10-51b0-7a42-8c1d-0e9f3a6b2c71"}}},"required":true},"x-mcp-tool":{"name":"crm_set_person_account_rep","title":"CRM: Set person account rep","toolset":"commissions","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:write"],"x-example-source":{"origin":"contract"}}},"/companies":{"get":{"tags":["companies"],"operationId":"companies.list","parameters":[{"name":"q","in":"query","schema":{"type":"string","maxLength":120},"required":false,"example":"harbour"},{"name":"status","in":"query","schema":{"type":"string"},"required":false,"example":"active"},{"name":"role","in":"query","schema":{"type":"string"},"required":false,"example":"customer"},{"name":"tag","in":"query","schema":{"$ref":"#/components/schemas/Tag"},"required":false},{"name":"personId","in":"query","schema":{"$ref":"#/components/schemas/PsnId"},"required":false},{"name":"sort","in":"query","schema":{"$ref":"#/components/schemas/CompanySortKey"},"required":false},{"name":"order","in":"query","schema":{"$ref":"#/components/schemas/SortOrder"},"required":false},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"CompanyPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyPageEncoded"},"examples":{"contract":{"summary":"companies.list","value":{"items":[{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T09:06:00.000Z"}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the tenant's companies (the B2B customers and suppliers), newest first. `q` narrows by name or external id (case-insensitive substring), `status` a comma-separated set (active by default), `role` any of `customer`/`supplier`, `tag` one tag, `personId` the companies one person is a contact of; `sort`/`order` pick the column and direction. `total` counts every match regardless of the page; `limit` defaults to 100 and is capped at 1000 (an over-cap request is clamped); page with `offset`.\n\nRequires `companies:read`.","x-mcp-tool":{"name":"crm_list_companies","title":"CRM: List companies","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:read"],"x-example-source":{"origin":"contract"}},"post":{"tags":["companies"],"operationId":"companies.create","parameters":[],"security":[{"bearer":[]}],"responses":{"201":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.create","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"contactCount":0,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T09:05:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"PersonNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Register a company: a name, optionally an external id, note, tags, roles (`customer` by default; `supplier` makes it pickable on a purchase order), tax id, payment terms, optionally the channel catalogs it buys from (`catalogIds` — an order for the company is priced from the merged set, each SKU at the lowest price any of them lists; the set must share one currency; empty, the company buys from the tenant's `Default`), its locations (a billing and a shipping address under a name each) and its contacts (people already registered — an unknown one is a 404 `PersonNotFound`; at most one is the main contact). Appends `crm.company-created`. `reference` is required and is the idempotency key: a retry with the same reference returns the company already registered and appends nothing.\n\nRequires `companies:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCompanyEncoded"},"example":{"reference":"onboarding:harbour-ceramics","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000"}]}}},"required":true},"x-mcp-tool":{"name":"crm_create_company","title":"CRM: Create company","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}}},"/companies/{companyId}":{"get":{"tags":["companies"],"operationId":"companies.get","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.get","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T09:06:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"One company (a supplier or a customer) by its `cmp_` id: its roles, tags, tax id, payment terms, catalogs, locations and main contact. 404 `CompanyNotFound`. Read-only.\n\nRequires `companies:read`.","x-mcp-tool":{"name":"crm_get_company","title":"CRM: Get company","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:read"],"x-example-source":{"origin":"contract"}},"put":{"tags":["companies"],"operationId":"companies.update","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.update","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":45,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T10:00:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"CompanyArchived | CompanyLocationNotFound | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/CompanyArchivedEncoded"},{"$ref":"#/components/schemas/CompanyLocationNotFoundEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Change a company's details. Every field is optional; a field sent replaces what was there (`locations` is the whole set afterwards — a location without an `id` is new; one with an id not on the company is refused with 409 `CompanyLocationNotFound`; one sent with different details retires that version and mints a new id, since locations are immutable so that what an order pinned never changes; an active location left out is retired), `null` clears an optional detail, and `catalogIds: []` detaches the company from its catalogs, back to the tenant's `Default`. An archived company cannot be changed (409 `CompanyArchived`). Appends `crm.company-updated` carrying the whole detail set. Idempotent by content: a retry that says what the record already says appends nothing.\n\nRequires `companies:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCompanyEncoded"},"example":{"paymentTermsDays":45}}},"required":true},"x-mcp-tool":{"name":"crm_update_company","title":"CRM: Update company","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}},"delete":{"tags":["companies"],"operationId":"companies.archive","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.archive","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"archived","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T10:30:00.000Z","archivedAt":"2026-10-20T10:30:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Archive a company: it leaves the default listings and every picker, keeps its id, history and contacts, and can be restored. Appends `crm.company-archived`. Idempotent: a retry on a company already archived appends nothing.\n\nRequires `companies:write`.","x-mcp-tool":{"name":"crm_archive_company","title":"CRM: Archive company","toolset":"crm","readOnlyHint":false,"destructiveHint":true,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}}},"/companies/{companyId}/contacts":{"get":{"tags":["companies"],"operationId":"companies.contacts","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"CompanyContactPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyContactPageEncoded"},"examples":{"contract":{"summary":"companies.contacts","value":{"items":[{"companyId":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","personId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","title":"Purchasing manager","main":true}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the people who act for this company — each with their title and whether they are the main contact — main contact first, then person-id ordered. The company record carries only `mainContactId` and `contactCount`: a B2B customer's headcount is not a list to return with every read. `limit` is 1–200 (50 when omitted); page with `offset`. 404 `CompanyNotFound`.\n\nRequires `companies:read`.","x-mcp-tool":{"name":"crm_company_contacts","title":"CRM: Company contacts","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:read"],"x-example-source":{"origin":"contract"}}},"/companies/{companyId}/locations/retired":{"get":{"tags":["companies"],"operationId":"companies.retiredLocations","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"50"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"RetiredLocationPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetiredLocationPageEncoded"},"examples":{"contract":{"summary":"companies.retiredLocations","value":{"items":[{"id":"cloc_01a15889-fc20-7d4e-9f50-6b7c8d9e0f1a","companyId":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","location":{"id":"cloc_01a15889-fc20-7d4e-9f50-6b7c8d9e0f1a","name":"Old Fremantle depot","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":true},"retiredAt":"2026-10-20T10:15:00.000Z"}],"total":1,"limit":50,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"A page of the location versions this company's edits and removals retired, most recently retired first — off the record, which carries the active locations only, and kept because an order may have pinned one. `limit` is 1–200 (50 when omitted); page with `offset`. 404 `CompanyNotFound`.\n\nRequires `companies:read`.","x-mcp-tool":{"name":"crm_company_retired_locations","title":"CRM: Company retired locations","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:read"],"x-example-source":{"origin":"contract"}}},"/companies/{companyId}/contacts/{personId}":{"put":{"tags":["companies"],"operationId":"companies.setContact","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"},{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.setContact","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T09:06:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound | PersonNotFound","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/CompanyNotFoundEncoded"},{"$ref":"#/components/schemas/PersonNotFoundEncoded"}]}}}},"409":{"description":"CompanyArchived | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/CompanyArchivedEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Make a person a contact of the company, or change their title or main-contact flag. `main: true` displaces the previous main contact — there is at most one. The person must exist (404 `PersonNotFound`); the company must be active. Appends `crm.company-contact-set`. Idempotent by content: a retry that says what the contact already says appends nothing.\n\nRequires `companies:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetCompanyContactEncoded"},"example":{"personId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","title":"Purchasing manager","main":true}}},"required":true},"x-mcp-tool":{"name":"crm_set_company_contact","title":"CRM: Set company contact","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}},"delete":{"tags":["companies"],"operationId":"companies.removeContact","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"},{"name":"personId","in":"path","schema":{"$ref":"#/components/schemas/PsnId"},"required":true,"example":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.removeContact","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"contactCount":0,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T10:45:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"CompanyArchived | MirroredFromSource","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/CompanyArchivedEncoded"},{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}]}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Remove a person from the company's contacts. Appends `crm.company-contact-removed`. Idempotent: a retry for a person who is no longer a contact appends nothing.\n\nRequires `companies:write`.","x-mcp-tool":{"name":"crm_remove_company_contact","title":"CRM: Remove company contact","toolset":"crm","readOnlyHint":false,"destructiveHint":true,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}}},"/companies/{companyId}/account-rep":{"put":{"tags":["companies"],"operationId":"companies.setAccountRep","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.setAccountRep","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-29T09:00:00.000Z","accountRepId":"usr_019e5a10-51b0-7a42-8c1d-0e9f3a6b2c71"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Name the member who manages a company's account, or `null` for nobody (`docs/commissions.md`). The order form offers them as the order's rep, and in `account-manager` mode they earn the commission on the company's orders placed from now on. Appends `crm.company-account-rep-set`. Idempotent by content: a retry naming the same member is acknowledged and appends nothing.\n\nRequires `companies:write`.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetAccountRepEncoded"},"example":{"accountRepId":"usr_019e5a10-51b0-7a42-8c1d-0e9f3a6b2c71"}}},"required":true},"x-mcp-tool":{"name":"crm_set_company_account_rep","title":"CRM: Set company account rep","toolset":"commissions","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}}},"/companies/{companyId}/restore":{"post":{"tags":["companies"],"operationId":"companies.restore","parameters":[{"name":"companyId","in":"path","schema":{"$ref":"#/components/schemas/CmpId"},"required":true,"example":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyEncoded"},"examples":{"contract":{"summary":"companies.restore","value":{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","status":"active","name":"Harbour Ceramics Pty Ltd","externalId":"HC-0042","tags":["wholesale"],"roles":["customer"],"taxNumber":"51 824 753 556","taxExempt":false,"paymentTermsDays":30,"catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"],"locations":[{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","name":"Fremantle warehouse","shippingAddress":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"phone":"+61 8 9430 0000","catalogIds":[],"retired":false}],"mainContactId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","contactCount":1,"createdAt":"2026-10-20T09:05:00.000Z","updatedAt":"2026-10-20T10:40:00.000Z"}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"404":{"description":"CompanyNotFound","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyNotFoundEncoded"}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Restore an archived company to active. Appends `crm.company-restored`. Idempotent: a retry on a company already active appends nothing.\n\nRequires `companies:write`.","x-mcp-tool":{"name":"crm_restore_company","title":"CRM: Restore company","toolset":"crm","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["companies:write"],"x-example-source":{"origin":"contract"}}},"/parties":{"get":{"tags":["parties"],"operationId":"parties.list","parameters":[{"name":"q","in":"query","schema":{"type":"string","maxLength":120},"required":false,"example":"harbour"},{"name":"ids","in":"query","schema":{"type":"string"},"required":false},{"name":"kind","in":"query","schema":{"type":"string"},"required":false,"example":"person,company"},{"name":"role","in":"query","schema":{"type":"string"},"required":false,"example":"customer"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"20"},{"name":"offset","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"PartyPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartyPageEncoded"},"examples":{"contract":{"summary":"parties.list","value":{"items":[{"id":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","kind":"company","name":"Harbour Ceramics Pty Ltd","roles":["customer"],"status":"active","catalogIds":["cat_01a15880-2a10-7b2c-8d3e-4f5a6b7c8d9e"]},{"id":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","kind":"person","name":"Priya Raman","email":"priya.raman@harbourceramics.example","roles":["customer"],"status":"active","catalogIds":[]}],"total":2,"limit":20,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"People and companies as one list of pickable rows — id, kind, display name, roles, status — the shape every picker searches and every document resolves its party ids through. `q` narrows by name or email (case-insensitive substring), `kind` and `role` to comma-separated sets; by default only active rows are listed, name-ordered. `ids` resolves exactly those ids (comma-separated, up to 200) in any status, so a purchase order that named a company since archived, or an order whose customer was erased, still renders — the latter as \"Erased person\". `total` counts every match; `limit` defaults to 100 and is capped at 1000; page with `offset`.\n\nRequires `customers:read` or `companies:read`.","x-mcp-tool":{"name":"crm_list_parties","title":"CRM: List parties","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read","companies:read"],"x-example-source":{"origin":"contract"}}},"/addresses":{"get":{"tags":["parties"],"operationId":"parties.addresses","parameters":[{"name":"ids","in":"query","schema":{"type":"string"},"required":true,"example":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01,cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"AddressPage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddressPageEncoded"},"examples":{"contract":{"summary":"parties.addresses","value":{"items":[{"id":"adr_01a1588a-0c41-7d2e-9a10-4c6d7e8f9a01","ownerKind":"person","ownerId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","ownerName":"Priya Raman","address":{"firstName":"Priya","lastName":"Raman","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"retired":false},{"id":"cloc_01a1588a-1f02-7a3b-8c4d-6f7a8b9c0d1e","ownerKind":"company","ownerId":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","ownerName":"Harbour Ceramics Pty Ltd","label":"Fremantle warehouse","address":{"firstName":"Receiving","lastName":"Dock","company":"Harbour Ceramics","address1":"14 Kiln Street","city":"Fremantle","province":"Western Australia","provinceCode":"WA","country":"Australia","countryCode":"AU","zip":"6160"},"billingAddress":{"company":"Harbour Ceramics Pty Ltd","address1":"PO Box 412","city":"Fremantle","provinceCode":"WA","countryCode":"AU","zip":"6959"},"retired":false}],"total":2,"limit":200,"offset":0}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Resolve address versions a document pinned — a person's `adr_` addresses or a company's `cloc_` locations, comma-separated, up to 200 — to the postal address exactly as it read when pinned. Addresses are immutable: editing one in the CRM retires the version (`retired: true`, `supersededBy` naming its replacement) and mints a new id, so an order keeps showing what it was placed with and can tell that the customer has since changed it. A version of an erased person resolves with `address: null`; an unknown id is simply absent from the page.\n\nRequires `customers:read` or `companies:read`.","x-mcp-tool":{"name":"crm_list_addresses","title":"CRM: List addresses","toolset":"crm","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false},"x-required-scopes":["customers:read","companies:read"],"x-example-source":{"origin":"contract"}}},"/events":{"get":{"tags":["events"],"operationId":"events.list","parameters":[{"name":"since","in":"query","schema":{"type":"string"},"required":false,"example":"41"},{"name":"limit","in":"query","schema":{"type":"string"},"required":false,"example":"500"},{"name":"upTo","in":"query","schema":{"type":"string"},"required":false}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"anyOf":[{"$ref":"#/components/schemas/crm.person-createdEncoded"},{"$ref":"#/components/schemas/crm.person-updatedEncoded"},{"$ref":"#/components/schemas/crm.person-erasedEncoded"},{"$ref":"#/components/schemas/crm.note-postedEncoded"},{"$ref":"#/components/schemas/crm.company-createdEncoded"},{"$ref":"#/components/schemas/crm.company-updatedEncoded"},{"$ref":"#/components/schemas/crm.company-contact-setEncoded"},{"$ref":"#/components/schemas/crm.company-contact-removedEncoded"},{"$ref":"#/components/schemas/crm.company-archivedEncoded"},{"$ref":"#/components/schemas/crm.company-restoredEncoded"},{"$ref":"#/components/schemas/crm.person-account-rep-setEncoded"},{"$ref":"#/components/schemas/crm.company-account-rep-setEncoded"}]}},"examples":{"contract":{"summary":"events.list","value":[{"_tag":"crm.person-created","eventId":"evt_01a1588a-0c41-7d2e-9a10-000000000041","txId":"tx_01a1588a-0c41-7d2e-9a10-000000000041","tenantId":"org_01a1586e-f9f6-7a8b-9c7d-6e5f4a3b2c1d","sequence":41,"occurredAt":"2026-10-20T09:00:00.000Z","source":"crm-manager","version":1,"actor":{"_tag":"user","id":"usr_01a15889-fa80-7b11-8c22-3d4e5f6a7b8c"},"correlationId":"req_01a1588a-0c41-7d2e-9a10-000000000041","payload":{"reference":"checkout:5521","personId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","emailKey":"593c82fc1f2944d758cdd3ba99d3846467ec3417f394e5f47c7410b939a0a83c","profile":"v1.QmFzZTY0IGNpcGhlcnRleHQgb2YgdGhlIHByb2ZpbGU=","tags":["trade"],"roles":["customer"],"taxExempt":false,"emailMarketing":"subscribed","smsMarketing":"not-subscribed"}},{"_tag":"crm.company-contact-set","eventId":"evt_01a1588a-0c41-7d2e-9a10-000000000042","txId":"tx_01a1588a-0c41-7d2e-9a10-000000000042","tenantId":"org_01a1586e-f9f6-7a8b-9c7d-6e5f4a3b2c1d","sequence":42,"occurredAt":"2026-10-20T09:06:00.000Z","source":"crm-manager","version":1,"actor":{"_tag":"user","id":"usr_01a15889-fa80-7b11-8c22-3d4e5f6a7b8c"},"correlationId":"req_01a1588a-0c41-7d2e-9a10-000000000042","payload":{"companyId":"cmp_01a1588a-1f02-7a3b-8c4d-5e6f7a8b9c0d","personId":"psn_01a1588a-0c41-7d2e-9a10-3b5c6d7e8f90","title":"Purchasing manager","main":true}}]}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"Replay committed CRM events at-or-after `since` (a journal sequence number), oldest first — exactly as the journal holds them, so a person's profile is the sealed string, never the details (read those from `/people`). One response is a page: `limit` defaults to 500 and is capped at 5000 (an over-cap request is clamped). Pages are `sequence`-ordered and the boundary is stable — repeat with `since=<last event's sequence + 1>` until a page comes back smaller than `limit` to replay the journal exactly once. `upTo` (inclusive) ends the replay at a sequence instead of the journal's head — with `GET /events/head` it replays the journal as it stood at a moment. Appends nothing: a read of facts already journalled.\n\nRequires `customers:read` or `companies:read`.","x-mcp-withheld":"The journal replay a consumer pages through to build its projection; agents read the projections the list and get tools serve, and the audit trail (`audit_trail`) for history.","x-required-scopes":["customers:read","companies:read"],"x-example-source":{"origin":"contract"}}},"/events/head":{"get":{"tags":["events"],"operationId":"events.head","parameters":[{"name":"at","in":"query","schema":{"type":"string"},"required":true,"example":"2026-10-20T12:00:00.000Z"}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Where a tenant's journal stood at a moment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JournalHead"},"examples":{"contract":{"summary":"events.head","value":{"at":"2026-10-20T12:00:00.000Z","sequence":42}}}}}},"401":{"description":"Unauthorized | TokenAlreadyUsed","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/UnauthorizedEncoded"},{"$ref":"#/components/schemas/TokenAlreadyUsedEncoded"}]}}}},"402":{"description":"SubscriptionRequired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequiredEncoded"}}}},"403":{"description":"TenantRequired | ScopeRequired | PlatformAdminRequired","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/TenantRequiredEncoded"},{"$ref":"#/components/schemas/ScopeRequiredEncoded"},{"$ref":"#/components/schemas/PlatformAdminRequiredEncoded"}]}}}},"409":{"description":"MirroredFromSource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MirroredFromSourceEncoded"}}}},"503":{"description":"RequestLogUnavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLogUnavailableEncoded"}}}}},"description":"The journal's position at a moment: the last `sequence` the database had recorded for this tenant at `at` (absent when it held nothing yet), by the database's own clock rather than the service's. Replaying with `upTo=<sequence>` then gives the journal exactly as it stood then; a set of heads taken at one `at` is a consistent cut across journals. Appends nothing: a read of facts already journalled.\n\nRequires `customers:read` or `companies:read`.","x-mcp-withheld":"Where a journal stood at a moment, for a consumer cutting journals to replay them as of then; agents read history through the audit trail (`audit_trail`).","x-required-scopes":["customers:read","companies:read"],"x-example-source":{"origin":"contract"}}}},"components":{"schemas":{"Tag":{"type":"string","pattern":"^\\S[\\s\\S]*\\S$|^\\S$|^$","minLength":1,"maxLength":256,"description":"one tag: trimmed, 1–256 characters; matched case-insensitively"},"CmpId":{"type":"string","pattern":"^cmp_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cmp-prefixed uuid, e.g. cmp_9f8c1c2e-0000-4000-8000-000000000000"},"PersonSortKey":{"type":"string","enum":["name","email","createdAt","updatedAt"],"description":"The column the people list is ordered by"},"SortOrder":{"type":"string","enum":["asc","desc"],"description":"The direction a list is ordered in: `asc` (ascending) or `desc` (descending)"},"PsnId":{"type":"string","pattern":"^psn_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A psn-prefixed uuid, e.g. psn_9f8c1c2e-0000-4000-8000-000000000000"},"EmailKey":{"type":"string","pattern":"^[0-9a-f]{64}$","description":"hex SHA-256 of the trimmed, lower-cased email"},"PersonStatus":{"type":"string","enum":["active","erased"],"description":"`active` — the record holds the person's details; `erased` — erased on request, only the id remains"},"Tags":{"type":"array","items":{"$ref":"#/components/schemas/Tag"}},"PartyRole":{"type":"string","enum":["customer","supplier"],"description":"What the tenant does with a party: sells to it (`customer`), buys from it (`supplier`), or both"},"MarketingConsent":{"type":"string","enum":["not-subscribed","subscribed","unsubscribed"],"description":"A person's marketing consent on a channel: `not-subscribed` — never asked or never agreed; `subscribed` — opted in; `unsubscribed` — opted out after opting in"},"UsrId":{"type":"string","pattern":"^usr_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A usr-prefixed uuid, e.g. usr_9f8c1c2e-0000-4000-8000-000000000000"},"EmailEncoded":{"type":"string"},"AdrId":{"type":"string","pattern":"^adr_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A adr-prefixed uuid, e.g. adr_9f8c1c2e-0000-4000-8000-000000000000"},"PadId":{"type":"string","pattern":"^pad_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A platform address: a pad-prefixed uuid"},"Address":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/AdrId"},"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId"},"retired":{"type":"boolean"},"supersededBy":{"type":"string"}},"required":["id"],"additionalProperties":false},"PersonProfile":{"type":"object","properties":{"email":{"$ref":"#/components/schemas/EmailEncoded"},"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"phone":{"type":"string","maxLength":40},"note":{"type":"string","maxLength":5000},"locale":{"type":"string","maxLength":20},"addresses":{"type":"array","items":{"$ref":"#/components/schemas/Address"}},"defaultAddressId":{"$ref":"#/components/schemas/AdrId"}},"required":["email"],"additionalProperties":false},"PersonEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/PsnId"},"emailKey":{"$ref":"#/components/schemas/EmailKey"},"status":{"$ref":"#/components/schemas/PersonStatus"},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxExempt":{"type":"boolean"},"emailMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"smsMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"accountRepId":{"$ref":"#/components/schemas/UsrId"},"profile":{"anyOf":[{"$ref":"#/components/schemas/PersonProfile"},{"type":"null"}]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"erasedAt":{"type":"string"}},"required":["id","emailKey","status","profile","createdAt","updatedAt"],"additionalProperties":false},"PersonPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PersonEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"UnauthorizedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["Unauthorized"]},"reason":{"type":"string"}},"required":["_tag","reason"],"additionalProperties":false},"TokenAlreadyUsedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["TokenAlreadyUsed"]},"tokenId":{"type":"string"}},"required":["_tag","tokenId"],"additionalProperties":false},"RequestLogUnavailableEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["RequestLogUnavailable"]},"tokenId":{"type":"string"},"reason":{"type":"string"}},"required":["_tag","tokenId","reason"],"additionalProperties":false},"TenantRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["TenantRequired"]},"userId":{"type":"string"}},"required":["_tag","userId"],"additionalProperties":false},"ScopeRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["ScopeRequired"]},"required":{"type":"array","items":{"type":"string"}}},"required":["_tag","required"],"additionalProperties":false},"PlatformAdminRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PlatformAdminRequired"]},"userId":{"type":"string"}},"required":["_tag","userId"],"additionalProperties":false},"SubscriptionRequiredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["SubscriptionRequired"]},"status":{"type":"string"}},"required":["_tag","status"],"additionalProperties":false},"MirroredFromSourceEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["MirroredFromSource"]},"source":{"type":"string"}},"required":["_tag","source"],"additionalProperties":false},"PersonNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PersonNotFound"]},"personId":{"type":"string"}},"required":["_tag","personId"],"additionalProperties":false},"AdrId_1":{"type":"string","pattern":"^adr_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A adr-prefixed uuid, e.g. adr_9f8c1c2e-0000-4000-8000-000000000000"},"PadId_1":{"type":"string","pattern":"^pad_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A platform address: a pad-prefixed uuid"},"AddressInput":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/AdrId_1"},"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId_1"}},"additionalProperties":false},"CreatePersonEncoded":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"email":{"$ref":"#/components/schemas/EmailEncoded"},"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"phone":{"type":"string","maxLength":40},"note":{"type":"string","maxLength":5000},"locale":{"type":"string","maxLength":20},"addresses":{"type":"array","items":{"$ref":"#/components/schemas/AddressInput"}},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxExempt":{"type":"boolean"},"emailMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"smsMarketing":{"$ref":"#/components/schemas/MarketingConsent"}},"required":["reference","email"],"additionalProperties":false},"PersonEmailConflictEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PersonEmailConflict"]},"personId":{"$ref":"#/components/schemas/PsnId"}},"required":["_tag","personId"],"additionalProperties":false},"PersonPhoneConflictEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PersonPhoneConflict"]},"personId":{"$ref":"#/components/schemas/PsnId"}},"required":["_tag","personId"],"additionalProperties":false},"Tags_1":{"type":"array","items":{"$ref":"#/components/schemas/Tag"}},"UpdatePersonEncoded":{"type":"object","properties":{"email":{"type":"string"},"firstName":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}]},"lastName":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}]},"phone":{"anyOf":[{"type":"string","maxLength":40},{"type":"null"}]},"note":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}]},"locale":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}]},"addresses":{"type":"array","items":{"$ref":"#/components/schemas/AddressInput"}},"defaultAddressId":{"anyOf":[{"$ref":"#/components/schemas/AdrId"},{"type":"null"}]},"tags":{"$ref":"#/components/schemas/Tags_1"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxExempt":{"type":"boolean"},"emailMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"smsMarketing":{"$ref":"#/components/schemas/MarketingConsent"}},"additionalProperties":false},"PersonErasedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["PersonErased"]},"personId":{"$ref":"#/components/schemas/PsnId"}},"required":["_tag","personId"],"additionalProperties":false},"AddressNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["AddressNotFound"]},"personId":{"$ref":"#/components/schemas/PsnId"},"addressId":{"type":"string"}},"required":["_tag","personId","addressId"],"additionalProperties":false},"NoteId":{"type":"string","pattern":"^note_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A note-prefixed uuid, e.g. note_9f8c1c2e-0000-4000-8000-000000000000"},"PartyId":{"anyOf":[{"$ref":"#/components/schemas/PsnId"},{"$ref":"#/components/schemas/CmpId"}]},"NoteBody":{"type":"string","pattern":"^\\S[\\s\\S]*\\S$|^\\S$|^$","minLength":1,"maxLength":5000},"AppId":{"type":"string","pattern":"^app_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A app-prefixed uuid, e.g. app_9f8c1c2e-0000-4000-8000-000000000000"},"InsId":{"type":"string","pattern":"^ins_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A ins-prefixed uuid, e.g. ins_9f8c1c2e-0000-4000-8000-000000000000"},"CplId":{"type":"string","pattern":"^cpl_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cpl-prefixed uuid, e.g. cpl_9f8c1c2e-0000-4000-8000-000000000000"},"Actor":{"anyOf":[{"type":"object","properties":{"_tag":{"type":"string","enum":["user"]},"id":{"$ref":"#/components/schemas/UsrId"},"impersonatedBy":{"type":"string","minLength":1},"viaPartner":{"type":"string","minLength":1}},"required":["_tag","id"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["system"]},"id":{"type":"string","minLength":1}},"required":["_tag","id"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["app"]},"id":{"$ref":"#/components/schemas/AppId"},"installationId":{"$ref":"#/components/schemas/InsId"}},"required":["_tag","id","installationId"],"additionalProperties":false},{"type":"object","properties":{"_tag":{"type":"string","enum":["customer"]},"id":{"$ref":"#/components/schemas/CplId"}},"required":["_tag","id"],"additionalProperties":false}]},"PartyNoteEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/NoteId"},"subjectId":{"$ref":"#/components/schemas/PartyId"},"body":{"anyOf":[{"$ref":"#/components/schemas/NoteBody"},{"type":"null"}]},"by":{"$ref":"#/components/schemas/Actor"},"postedAt":{"type":"string"}},"required":["id","subjectId","body","by","postedAt"],"additionalProperties":false},"PartyNotePageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PartyNoteEncoded"}},"next":{"$ref":"#/components/schemas/NoteId"}},"required":["items"],"additionalProperties":false},"PostalAddress":{"type":"object","properties":{"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId"}},"additionalProperties":false},"RetiredAddressEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/AdrId"},"personId":{"$ref":"#/components/schemas/PsnId"},"address":{"anyOf":[{"$ref":"#/components/schemas/PostalAddress"},{"type":"null"}]},"supersededBy":{"type":"string"},"retiredAt":{"type":"string"}},"required":["id","personId","address","retiredAt"],"additionalProperties":false},"RetiredAddressPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RetiredAddressEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"CompanyContactLinkEncoded":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"},"personId":{"$ref":"#/components/schemas/PsnId"},"title":{"type":"string","maxLength":500},"main":{"type":"boolean"}},"required":["companyId","personId","main"],"additionalProperties":false},"CompanyContactPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/CompanyContactLinkEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"PostNoteEncoded":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"body":{"$ref":"#/components/schemas/NoteBody"}},"required":["reference","body"],"additionalProperties":false},"ErasePersonEncoded":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"reason":{"type":"string","maxLength":500}},"required":["reference"],"additionalProperties":false},"SetAccountRepEncoded":{"type":"object","properties":{"accountRepId":{"anyOf":[{"$ref":"#/components/schemas/UsrId"},{"type":"null"}]}},"required":["accountRepId"],"additionalProperties":false},"CompanySortKey":{"type":"string","enum":["name","createdAt","updatedAt"],"description":"The column the companies list is ordered by"},"CompanyStatus":{"type":"string","enum":["active","archived"],"description":"`active` — in use; `archived` — put away, kept for the documents that name it"},"TaxNumber":{"type":"string","minLength":1,"maxLength":60,"pattern":"^\\S(?:.*\\S)?$","description":"A tax registration number (ABN, NZ GST number, VAT number) as the business writes it, up to 60 characters"},"CatId":{"type":"string","pattern":"^cat_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cat-prefixed uuid, e.g. cat_9f8c1c2e-0000-4000-8000-000000000000"},"ClocId":{"type":"string","pattern":"^cloc_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cloc-prefixed uuid, e.g. cloc_9f8c1c2e-0000-4000-8000-000000000000"},"PostalAddress_1":{"type":"object","properties":{"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId_1"}},"additionalProperties":false},"CompanyLocation":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/ClocId"},"name":{"type":"string","minLength":1,"maxLength":120},"shippingAddress":{"$ref":"#/components/schemas/PostalAddress_1"},"billingAddress":{"$ref":"#/components/schemas/PostalAddress_1"},"phone":{"type":"string","maxLength":40},"taxNumber":{"$ref":"#/components/schemas/TaxNumber"},"note":{"type":"string","maxLength":5000},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}},"retired":{"type":"boolean"},"supersededBy":{"type":"string"}},"required":["id","name"],"additionalProperties":false},"CompanyEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/CmpId"},"status":{"$ref":"#/components/schemas/CompanyStatus"},"name":{"type":"string","minLength":1,"maxLength":200},"externalId":{"type":"string","maxLength":120},"note":{"type":"string","maxLength":5000},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxNumber":{"$ref":"#/components/schemas/TaxNumber"},"taxExempt":{"type":"boolean"},"paymentTermsDays":{"type":"integer","minimum":0},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}},"locations":{"type":"array","items":{"$ref":"#/components/schemas/CompanyLocation"}},"mainContactId":{"$ref":"#/components/schemas/PsnId"},"accountRepId":{"$ref":"#/components/schemas/UsrId"},"contactCount":{"type":"integer","minimum":0},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"archivedAt":{"type":"string"}},"required":["id","status","name","contactCount","createdAt","updatedAt"],"additionalProperties":false},"CompanyPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/CompanyEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"CompanyNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["CompanyNotFound"]},"companyId":{"type":"string"}},"required":["_tag","companyId"],"additionalProperties":false},"RetiredLocationEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/ClocId"},"companyId":{"$ref":"#/components/schemas/CmpId"},"location":{"$ref":"#/components/schemas/CompanyLocation"},"retiredAt":{"type":"string"}},"required":["id","companyId","location","retiredAt"],"additionalProperties":false},"RetiredLocationPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RetiredLocationEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"ClocId_1":{"type":"string","pattern":"^cloc_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A cloc-prefixed uuid, e.g. cloc_9f8c1c2e-0000-4000-8000-000000000000"},"PostalAddress_2":{"type":"object","properties":{"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId_1"}},"additionalProperties":false},"PostalAddress_3":{"type":"object","properties":{"firstName":{"type":"string","maxLength":500},"lastName":{"type":"string","maxLength":500},"company":{"type":"string","maxLength":500},"address1":{"type":"string","maxLength":500},"address2":{"type":"string","maxLength":500},"city":{"type":"string","maxLength":500},"province":{"type":"string","maxLength":500},"provinceCode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":500},"countryCode":{"type":"string","allOf":[{"minLength":2},{"maxLength":2}]},"zip":{"type":"string","maxLength":20},"phone":{"type":"string","maxLength":40},"verifiedAddressId":{"$ref":"#/components/schemas/PadId_1"}},"additionalProperties":false},"TaxNumber_1":{"type":"string","minLength":1,"maxLength":60,"pattern":"^\\S(?:.*\\S)?$","description":"A tax registration number (ABN, NZ GST number, VAT number) as the business writes it, up to 60 characters"},"CompanyLocationInput":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/ClocId_1"},"name":{"type":"string","minLength":1,"maxLength":120},"shippingAddress":{"$ref":"#/components/schemas/PostalAddress_2"},"billingAddress":{"$ref":"#/components/schemas/PostalAddress_3"},"phone":{"type":"string","maxLength":40},"taxNumber":{"$ref":"#/components/schemas/TaxNumber_1"},"note":{"type":"string","maxLength":5000},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}}},"required":["name"],"additionalProperties":false},"CompanyContact":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"title":{"type":"string","maxLength":500},"main":{"type":"boolean"}},"required":["personId"],"additionalProperties":false},"CreateCompanyEncoded":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":200},"externalId":{"type":"string","maxLength":120},"note":{"type":"string","maxLength":5000},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxNumber":{"$ref":"#/components/schemas/TaxNumber"},"taxExempt":{"type":"boolean"},"paymentTermsDays":{"type":"integer","minimum":0},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}},"locations":{"type":"array","items":{"$ref":"#/components/schemas/CompanyLocationInput"}},"contacts":{"type":"array","items":{"$ref":"#/components/schemas/CompanyContact"}}},"required":["reference","name"],"additionalProperties":false},"UpdateCompanyEncoded":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"externalId":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}]},"note":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}]},"tags":{"$ref":"#/components/schemas/Tags_1"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxNumber":{"anyOf":[{"$ref":"#/components/schemas/TaxNumber"},{"type":"null"}]},"taxExempt":{"type":"boolean"},"paymentTermsDays":{"anyOf":[{"type":"integer","minimum":0},{"type":"null"}]},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}},"locations":{"type":"array","items":{"$ref":"#/components/schemas/CompanyLocationInput"}}},"additionalProperties":false},"CompanyArchivedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["CompanyArchived"]},"companyId":{"$ref":"#/components/schemas/CmpId"}},"required":["_tag","companyId"],"additionalProperties":false},"CompanyLocationNotFoundEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["CompanyLocationNotFound"]},"companyId":{"$ref":"#/components/schemas/CmpId"},"locationId":{"type":"string"}},"required":["_tag","companyId","locationId"],"additionalProperties":false},"SetCompanyContactEncoded":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"title":{"type":"string","maxLength":500},"main":{"type":"boolean"}},"required":["personId"],"additionalProperties":false},"PartyKind":{"type":"string","enum":["person","company"],"description":"Which kind of party a record is: a natural `person` or a `company`"},"PartyEncoded":{"type":"object","properties":{"id":{"$ref":"#/components/schemas/PartyId"},"kind":{"$ref":"#/components/schemas/PartyKind"},"name":{"type":"string"},"email":{"type":"string"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"status":{"anyOf":[{"$ref":"#/components/schemas/PersonStatus"},{"$ref":"#/components/schemas/CompanyStatus"}]},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}}},"required":["id","kind","name","roles","status"],"additionalProperties":false},"PartyPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PartyEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"ResolvedAddressEncoded":{"type":"object","properties":{"id":{"anyOf":[{"$ref":"#/components/schemas/AdrId"},{"$ref":"#/components/schemas/ClocId"}]},"ownerKind":{"$ref":"#/components/schemas/PartyKind"},"ownerId":{"$ref":"#/components/schemas/PartyId"},"ownerName":{"type":"string"},"label":{"type":"string"},"address":{"anyOf":[{"$ref":"#/components/schemas/PostalAddress"},{"type":"null"}]},"billingAddress":{"$ref":"#/components/schemas/PostalAddress_1"},"retired":{"type":"boolean"},"supersededBy":{"type":"string"}},"required":["id","ownerKind","ownerId","ownerName","address","retired"],"additionalProperties":false},"AddressPageEncoded":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ResolvedAddressEncoded"}},"total":{"type":"integer","minimum":0},"limit":{"type":"integer","exclusiveMinimum":0},"offset":{"type":"integer","minimum":0}},"required":["items","total","offset"],"additionalProperties":false},"EvtId":{"type":"string","pattern":"^evt_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A evt-prefixed uuid, e.g. evt_9f8c1c2e-0000-4000-8000-000000000000"},"TxId":{"type":"string","pattern":"^tx_[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"A tx-prefixed uuid, e.g. tx_9f8c1c2e-0000-4000-8000-000000000000"},"TenantId":{"type":"string","pattern":"^org_(test_)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$","description":"An org-prefixed uuid, e.g. org_9f8c1c2e-0000-4000-8000-000000000000; a sandbox tenant is org_test_<uuid>"},"SealedProfile":{"type":"string","pattern":"^v1\\.[A-Za-z0-9+/]+=*$"},"crm.person-createdEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.person-created"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"personId":{"$ref":"#/components/schemas/PsnId"},"emailKey":{"$ref":"#/components/schemas/EmailKey"},"profile":{"anyOf":[{"$ref":"#/components/schemas/PersonProfile"},{"$ref":"#/components/schemas/SealedProfile"}]},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxExempt":{"type":"boolean"},"emailMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"smsMarketing":{"$ref":"#/components/schemas/MarketingConsent"}},"required":["reference","personId","emailKey","profile","tags","roles","taxExempt","emailMarketing","smsMarketing"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"PersonField":{"type":"string","enum":["email","firstName","lastName","phone","note","locale","addresses","defaultAddressId","tags","roles","taxExempt","emailMarketing","smsMarketing"],"description":"A field of a person's record — what a person-updated fact says `changed`"},"crm.person-updatedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.person-updated"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"emailKey":{"$ref":"#/components/schemas/EmailKey"},"profile":{"anyOf":[{"$ref":"#/components/schemas/PersonProfile"},{"$ref":"#/components/schemas/SealedProfile"}]},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxExempt":{"type":"boolean"},"emailMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"smsMarketing":{"$ref":"#/components/schemas/MarketingConsent"},"changed":{"type":"array","items":{"$ref":"#/components/schemas/PersonField"}}},"required":["personId","emailKey","profile","tags","roles","taxExempt","emailMarketing","smsMarketing"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.person-erasedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.person-erased"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"reference":{"type":"string","minLength":1},"reason":{"type":"string","maxLength":500}},"required":["personId","reference"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"NoteContent":{"type":"object","properties":{"body":{"$ref":"#/components/schemas/NoteBody"}},"required":["body"],"additionalProperties":false},"SealedNote":{"type":"string","pattern":"^v1\\.[A-Za-z0-9+/]+=*$"},"crm.note-postedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.note-posted"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"noteId":{"$ref":"#/components/schemas/NoteId"},"personId":{"$ref":"#/components/schemas/PsnId"},"reference":{"type":"string","minLength":1},"content":{"anyOf":[{"$ref":"#/components/schemas/NoteContent"},{"$ref":"#/components/schemas/SealedNote"}]}},"required":["noteId","personId","reference","content"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"CompanyContact_1":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"title":{"type":"string","maxLength":500},"main":{"type":"boolean"}},"required":["personId"],"additionalProperties":false},"crm.company-createdEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-created"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"reference":{"type":"string","minLength":1},"companyId":{"$ref":"#/components/schemas/CmpId"},"name":{"type":"string","minLength":1,"maxLength":200},"externalId":{"type":"string","maxLength":120},"note":{"type":"string","maxLength":5000},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxNumber":{"$ref":"#/components/schemas/TaxNumber"},"taxExempt":{"type":"boolean"},"paymentTermsDays":{"type":"integer","minimum":0},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}},"locations":{"type":"array","items":{"$ref":"#/components/schemas/CompanyLocation"}},"contacts":{"type":"array","items":{"$ref":"#/components/schemas/CompanyContact_1"}}},"required":["reference","companyId","name","tags","roles","locations","contacts"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.company-updatedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-updated"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"},"name":{"type":"string","minLength":1,"maxLength":200},"externalId":{"type":"string","maxLength":120},"note":{"type":"string","maxLength":5000},"tags":{"$ref":"#/components/schemas/Tags"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/PartyRole"},"minItems":1},"taxNumber":{"$ref":"#/components/schemas/TaxNumber"},"taxExempt":{"type":"boolean"},"paymentTermsDays":{"type":"integer","minimum":0},"catalogIds":{"type":"array","items":{"$ref":"#/components/schemas/CatId"}},"locations":{"type":"array","items":{"$ref":"#/components/schemas/CompanyLocation"}}},"required":["companyId","name","tags","roles","locations"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.company-contact-setEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-contact-set"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"},"personId":{"$ref":"#/components/schemas/PsnId"},"title":{"type":"string","maxLength":500},"main":{"type":"boolean"}},"required":["companyId","personId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.company-contact-removedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-contact-removed"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"},"personId":{"$ref":"#/components/schemas/PsnId"}},"required":["companyId","personId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.company-archivedEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-archived"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"}},"required":["companyId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.company-restoredEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-restored"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"}},"required":["companyId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.person-account-rep-setEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.person-account-rep-set"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"personId":{"$ref":"#/components/schemas/PsnId"},"accountRepId":{"anyOf":[{"$ref":"#/components/schemas/UsrId"},{"type":"null"}]}},"required":["personId","accountRepId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"crm.company-account-rep-setEncoded":{"type":"object","properties":{"_tag":{"type":"string","enum":["crm.company-account-rep-set"]},"eventId":{"$ref":"#/components/schemas/EvtId"},"txId":{"$ref":"#/components/schemas/TxId"},"tenantId":{"$ref":"#/components/schemas/TenantId"},"sequence":{"type":"integer","minimum":0},"occurredAt":{"type":"string"},"source":{"type":"string","minLength":1},"version":{"type":"number","enum":[1]},"actor":{"$ref":"#/components/schemas/Actor"},"correlationId":{"type":"string","minLength":1},"causationId":{"type":"string","minLength":1},"payload":{"type":"object","properties":{"companyId":{"$ref":"#/components/schemas/CmpId"},"accountRepId":{"anyOf":[{"$ref":"#/components/schemas/UsrId"},{"type":"null"}]}},"required":["companyId","accountRepId"],"additionalProperties":false}},"required":["_tag","eventId","txId","tenantId","sequence","occurredAt","source","version","actor","correlationId","payload"],"additionalProperties":false},"JournalHead":{"type":"object","properties":{"at":{"type":"string"},"sequence":{"type":"integer","minimum":0}},"required":["at"],"additionalProperties":false,"description":"Where a tenant's journal stood at a moment."}},"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"A tenant JWT: sign in through the auth service, choose the organization, then `GET /api/auth/token`. Tokens last 15 minutes."}}},"security":[],"tags":[{"name":"people","description":"People: the natural persons a tenant deals with — customers, contacts at companies, sole traders it buys from. Unique per tenant by email. Identifying details live sealed in the journal and can be erased without touching a single event."},{"name":"companies","description":"Companies: the businesses a tenant deals with — B2B customers, suppliers, or both — with their locations and the people who act for them."},{"name":"parties","description":"The parties a document may name, and the address versions it may pin, resolvable by id."},{"name":"events","description":"The CRM append-only event log."}],"servers":[{"url":"https://crm.getmanifold.io","description":"Production"}]}