diff --git a/openapi.yaml b/openapi.yaml
index f713d79..8ef5b0f 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -1942,6 +1942,109 @@ paths:
"401":
$ref: '#/components/responses/Unauthorized'
+ /relationship_categories:
+ get:
+ tags: [Beneficiaries]
+ summary: List the organisation's Relationship Categories
+ description: |
+ The kinds of relationship Contacts can have with each other in the organisation, each with
+ its two sides, e.g. School & Pupil or Mother & Son. A fixed Signup Page and a permitted
+ relationship (`POST /permitted_relationships`) use one. Any member of the organisation can
+ list them.
+ `charity_id` may be left out when the user belongs to one organisation.
+ operationId: listRelationshipCategories
+ security: [{tokenAuth: []}]
+ parameters:
+ - name: charity_id
+ in: query
+ required: false
+ schema: { type: integer }
+ - $ref: '#/components/parameters/Page'
+ - $ref: '#/components/parameters/PerPage'
+ - $ref: '#/components/parameters/LastSyncDatetime'
+ responses:
+ "200":
+ description: A page of Relationship Categories, by title
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/PaginationEnvelope'
+ - type: object
+ properties:
+ data:
+ type: array
+ items: { $ref: '#/components/schemas/RelationshipCategory' }
+ "401":
+ $ref: '#/components/responses/Unauthorized'
+ "404":
+ $ref: '#/components/responses/NotFound'
+ "422":
+ $ref: '#/components/responses/UnprocessableEntityList'
+ post:
+ tags: [Beneficiaries]
+ summary: Create a Relationship Category
+ description: |
+ Adds a kind of relationship Contacts can have with each other, as the New Relationship Type
+ page does: its two sides, e.g. Parent & Child or Client & Emergency Contact. A fixed Signup
+ Page needs at least one to connect the people it signs up.
+
+ Only organisation editors (Organisation Admins) may create them (`403` otherwise). The same
+ pair of titles can't exist twice in an organisation, whatever their case: `422` then gives
+ `existing_id`, the one already there, to reuse. List them first with
+ `GET /relationship_categories`. `charity_id` may be left out when the user belongs to one
+ organisation.
+ operationId: createRelationshipCategory
+ security: [{tokenAuth: []}]
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required: [parent_title, child_title]
+ properties:
+ charity_id:
+ type: integer
+ description: The organisation to add it to
+ parent_title:
+ type: string
+ description: The first side, e.g. Parent
+ child_title:
+ type: string
+ description: The second side, e.g. Child
+ example:
+ charity_id: 12
+ parent_title: Parent
+ child_title: Child
+ responses:
+ "201":
+ description: The Relationship Category made
+ content:
+ application/json:
+ schema: { $ref: '#/components/schemas/RelationshipCategory' }
+ "401":
+ $ref: '#/components/responses/Unauthorized'
+ "403":
+ $ref: '#/components/responses/ForbiddenError'
+ "404":
+ $ref: '#/components/responses/NotFound'
+ "422":
+ description: Validation failed, or the pair of titles already exists
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ errors:
+ type: array
+ items: { type: string }
+ existing_id:
+ type: integer
+ description: The Relationship Category with these titles already, when that is why
+ example:
+ errors: ["Already exists"]
+ existing_id: 34
/beneficiary_types:
get:
tags: [Beneficiary Types]
@@ -15015,6 +15118,20 @@ components:
type: string
enum: [Person, Organisation, Animal, Object]
+ RelationshipCategory:
+ type: object
+ description: A kind of relationship between Contacts, with its two sides
+ properties:
+ id: { type: integer }
+ parent_title:
+ type: string
+ description: The first side, e.g. School
+ child_title:
+ type: string
+ description: The second side, e.g. Pupil
+ created_at: { type: string, format: date-time }
+ updated_at: { type: string, format: date-time }
+
BeneficiaryCategory:
allOf:
- $ref: '#/components/schemas/Timestamps'
diff --git a/server.js b/server.js
index e7568ae..8142a59 100644
--- a/server.js
+++ b/server.js
@@ -1571,6 +1571,27 @@ function buildDocsPage() {
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or started by someone else" }
], "Only the user who started the move can see it.")}
+ ${endpointCard("GET", "/relationship_categories", "List the organisation's Relationship Categories", true, [
+ { name: "charity_id", in: "query", type: "integer", required: false, desc: "The organisation. Optional if you belong to only one" },
+ { name: "page", in: "query", type: "integer", required: false, desc: "Page number" },
+ { name: "per_page", in: "query", type: "integer", required: false, desc: "Default 10, max 200" },
+ { name: "last_synced_datetime", in: "query", type: "string", required: false, desc: "Only categories changed since then" }
+ ], [
+ { code: "200", cls: "response-2xx", desc: "data: each category's id, parent_title and child_title (e.g. School and Pupil), in the paginated envelope" },
+ { code: "401", cls: "response-4xx", desc: "Not authenticated" },
+ { code: "404", cls: "response-4xx", desc: "An organisation you aren't in" }
+ ], "The kinds of relationship Contacts can have with each other in the organisation. Any member of the organisation can list them.")}
+ ${endpointCard("POST", "/relationship_categories", "Create a Relationship Category", true, [
+ { name: "charity_id", in: "body", type: "integer", required: false, desc: "The organisation. Optional if you belong to only one" },
+ { name: "parent_title", in: "body", type: "string", required: true, desc: "The first side, e.g. Parent" },
+ { name: "child_title", in: "body", type: "string", required: true, desc: "The second side, e.g. Child" }
+ ], [
+ { code: "201", cls: "response-2xx", desc: "The category made: id, parent_title, child_title" },
+ { code: "401", cls: "response-4xx", desc: "Not authenticated" },
+ { code: "403", cls: "response-4xx", desc: "You aren't an organisation editor (Organisation Admin)" },
+ { code: "404", cls: "response-4xx", desc: "An organisation you aren't in" },
+ { code: "422", cls: "response-4xx", desc: "A title is missing, or the pair already exists in any case: existing_id is the one already there, to reuse" }
+ ], "New Relationship Type on the organisation's Relationship Types page, e.g. Parent & Child or Client & Emergency Contact. A fixed Signup Page needs one to connect the people it signs up. List them first and reuse one that fits.")}