Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16104,6 +16104,85 @@ paths:
"422":
description: "`{error}`: it has already been reviewed"

/contact_merges:
get:
tags: [Suggested Merges]
summary: List merges that can be undone
description: |
The Contacts merged into others in an Organisation that can still be unmerged, as listed in
each Contact's Merged with box. Newest first. Organisation Admins only.
operationId: listContactMerges
security: [{tokenAuth: []}]
parameters:
- name: charity_id
in: query
required: true
schema:
type: integer
description: The Organisation (Charity) ID
- name: beneficiary_id
in: query
schema:
type: integer
description: Only merges into this Contact (the Contact that was kept)
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PerPage'
- $ref: '#/components/parameters/LastSyncDatetime'
responses:
"200":
description: Paginated list of merges
content:
application/json:
example:
page: 1
page_size: 1
page_count: 1
total_count: 1
data:
- id: 311
contact: { id: 101, name: Grace Mensah }
merged_contact: { id: 188, name: Grace Mensah }
merged_by: { id: 5, name: Asha Patel }
merged_at: "2026-11-20T10:15:00Z"
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: The user isn't an Organisation Admin of the Organisation
"404":
$ref: '#/components/responses/NotFound'
"422":
description: "`{errors}`: last_synced_datetime isn't a date and time"

/contact_merges/{id}/unmerge:
post:
tags: [Suggested Merges]
summary: Unmerge two Contacts
description: |
Undoes a merge, as Unmerge does on the Contact's profile. The merged-away Contact comes back
with its own details and Surveys. Organisation Admins only. A merge the user can't undo,
or one already undone, returns 404.
operationId: unmergeContacts
security: [{tokenAuth: []}]
parameters:
- name: id
in: path
required: true
schema:
type: integer
description: The merge ID, from GET /contact_merges
responses:
"200":
description: Unmerged
content:
application/json:
example:
contact: { id: 101, name: Grace Mensah }
restored_contact: { id: 188, name: Grace Mensah }
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'

/duplicate_contacts:
get:
tags: [Duplicate Contacts]
Expand Down
21 changes: 19 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3719,7 +3719,7 @@ function buildDocsPage() {
{ name: "id", type: "integer", required: true, in: "path", desc: "The Suggested Merge ID" },
{ name: "winner_id", type: "integer", required: false, in: "body", desc: "The Contact to keep. Default: the one created first" }
], [
{ code: "202", cls: "response-2xx", desc: "Merging has begun: <code>suggested_merge</code> (now <code>merged</code>) and <code>merge_request_ids</code>. Undo with Unmerge on the Merge Contacts page" },
{ code: "202", cls: "response-2xx", desc: "Merging has begun: <code>suggested_merge</code> (now <code>merged</code>) and <code>merge_request_ids</code>. Undo with <code>POST /contact_merges/{id}/unmerge</code>" },
{ code: "404", cls: "response-4xx", desc: "Not a suggestion you can see" },
{ code: "422", cls: "response-4xx", desc: "<code>{error}</code>: the Contact to keep isn't one of its Contacts, or it has already been reviewed" }
])}
Expand All @@ -3730,6 +3730,23 @@ function buildDocsPage() {
{ code: "404", cls: "response-4xx", desc: "Not a suggestion you can see" },
{ code: "422", cls: "response-4xx", desc: "<code>{error}</code>: it has already been reviewed" }
])}
${endpointCard("GET", "/contact_merges", "List merges that can be undone", true, [
{ name: "charity_id", type: "integer", required: true, desc: "The Organisation ID" },
{ name: "beneficiary_id", type: "integer", required: false, desc: "Only merges into this Contact" },
{ name: "page", type: "integer", required: false, desc: "Page number" },
{ name: "per_page", type: "integer", required: false, desc: "Records per page (at most 200)" },
{ name: "last_synced_datetime", type: "string", required: false, desc: "ISO 8601: merges made after this time" }
], [
{ code: "200", cls: "response-2xx", desc: "Paginated list: <code>id, contact {id, name}, merged_contact {id, name}, merged_by {id, name}, merged_at</code>, newest first" },
{ code: "403", cls: "response-4xx", desc: "You aren't an Organisation Admin of the Organisation" },
{ code: "422", cls: "response-4xx", desc: "<code>last_synced_datetime</code> isn't a date and time" }
])}
${endpointCard("POST", "/contact_merges/{id}/unmerge", "Unmerge two Contacts", true, [
{ name: "id", type: "integer", required: true, in: "path", desc: "The merge ID" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>contact</code> (kept) and <code>restored_contact</code>, both <code>{id, name}</code>" },
{ code: "404", cls: "response-4xx", desc: "Not a merge you can undo, or already undone" }
])}
${endpointCard("GET", "/merge_rules", "List an Organisation's Merge Rules", true, [
{ name: "charity_id", type: "integer", required: true, desc: "The Organisation ID" },
{ name: "page", type: "integer", required: false, desc: "Page number" },
Expand Down Expand Up @@ -3822,7 +3839,7 @@ function buildDocsPage() {
{ name: "contact_ids", type: "array", required: true, in: "body", desc: "At least two Contacts" },
{ name: "winner_id", type: "integer", required: false, in: "body", desc: "The Contact to keep. Default: the one created first" }
], [
{ code: "202", cls: "response-2xx", desc: "Merging has begun: <code>{winner_id, merge_request_ids, message}</code>. Undo with Unmerge on the Merge Contacts page" },
{ code: "202", cls: "response-2xx", desc: "Merging has begun: <code>{winner_id, merge_request_ids, message}</code>. Undo with <code>POST /contact_merges/{id}/unmerge</code>" },
{ code: "403", cls: "response-4xx", desc: "You can't merge Contacts in the Organisation" },
{ code: "422", cls: "response-4xx", desc: "<code>{error}</code>: fewer than two Contacts, one you can't merge, or a Contact to keep that isn't one of them" }
])}
Expand Down
Loading