Skip to content
Merged
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
196 changes: 159 additions & 37 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4093,6 +4093,73 @@ paths:
schema:
$ref: '#/components/schemas/Error'

/referral_link_details/{id}/email_settings:
put:
tags: [Signup Pages]
summary: Set a Signup Page's Send Emails settings
description: |
Saves what the **Send Emails** screen saves for a Signup Page: the confirmation email each
individual (or audience) receives after the Signup Page is completed, and the email sent
to Additional Recipients. Name each individual by the `label` that
`GET /referral_link_details/{id}/definition` returns (e.g. `Individual A`); individuals left
out keep their settings. Use `{{Field name}}` merge tags in the subject line and body to
personalise an individual's email with their answers. Additional Recipients' emails aren't
personalised.

Only Organisation Editors can set these (403 otherwise), and the Organisation must have email
messaging switched on in its Preferences (422 otherwise). Everything is saved or nothing is.
Returns the new `send_emails` in the definition's shape, including when every email is off.
operationId: updateReferralLinkDetailEmailSettings
security: [{tokenAuth: []}]
parameters:
- $ref: '#/components/parameters/ResourceId'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SignupPageEmailSettingsRequest'
example:
individuals:
- label: "Individual A"
enabled: true
subject_line: "Welcome to the club, {{name}}"
message_body: "<p>Hi {{name}}, thanks for signing up.</p>"
recipient_field_ids: [4521]
include_submission_details: true
included_individuals: ["Individual A", "Individual B"]
- label: "Individual B"
enabled: false
additional_recipients:
enabled: true
recipients: ["office@example.org"]
subject_line: "New family signup"
message_body: "<p>A family has signed up.</p>"
include_submission_details: true
included_individuals: ["Individual A"]
responses:
"200":
description: The Signup Page's Send Emails settings, as saved
content:
application/json:
schema:
type: object
properties:
send_emails:
$ref: '#/components/schemas/SignupPageSendEmails'
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: You can see the Signup Page but aren't an Organisation Editor
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'

/offline_collector_definition:
get:
tags: [Signup Pages]
Expand Down Expand Up @@ -16378,47 +16445,102 @@ components:
- type: object
properties:
send_emails:
type: object
allOf: [{ $ref: '#/components/schemas/SignupPageSendEmails' }]
description: Present only when a Send Emails email is switched on

SignupPageSendEmails:
type: object
properties:
individuals:
type: array
items:
allOf:
- type: object
properties:
label:
type: string
audience:
type: object
nullable: true
properties:
id:
type: integer
name:
type: string
contact_form:
$ref: '#/components/schemas/IdName'
enabled:
type: boolean
recipient_fields:
type: array
description: The Contact Form's email fields the email is sent to. Only when enabled
items:
$ref: '#/components/schemas/IdName'
- $ref: '#/components/schemas/SignupPageEmail'
additional_recipients:
allOf:
- type: object
properties:
individuals:
enabled:
type: boolean
recipients:
type: array
items:
allOf:
- type: object
properties:
label:
type: string
audience:
type: object
nullable: true
properties:
id:
type: integer
name:
type: string
contact_form:
$ref: '#/components/schemas/IdName'
enabled:
type: boolean
recipient_fields:
type: array
description: The Contact Form's email fields the email is sent to. Only when enabled
items:
$ref: '#/components/schemas/IdName'
- $ref: '#/components/schemas/SignupPageEmail'
additional_recipients:
allOf:
- type: object
properties:
enabled:
type: boolean
recipients:
type: array
items:
type: string
format: email
- $ref: '#/components/schemas/SignupPageEmail'
type: string
format: email
- $ref: '#/components/schemas/SignupPageEmail'

SignupPageEmailSettingsRequest:
type: object
properties:
individuals:
type: array
items:
type: object
required: [label]
properties:
label:
type: string
description: The individual's label from the definition, e.g. "Individual A"
enabled:
type: boolean
subject_line:
type: string
message_body:
type: string
description: HTML. May contain {{Field name}} merge tags
recipient_field_ids:
type: array
description: Email fields on the individual's Contact Form to send to
items:
type: integer
include_submission_details:
type: boolean
included_individuals:
type: array
description: Labels of the individuals whose submitted details are added
items:
type: string
additional_recipients:
type: object
properties:
enabled:
type: boolean
recipients:
type: array
items:
type: string
format: email
subject_line:
type: string
message_body:
type: string
include_submission_details:
type: boolean
included_individuals:
type: array
items:
type: string

SignupPageEmail:
type: object
Expand Down
11 changes: 11 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,17 @@ function buildDocsPage() {
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or a Signup Page you can't see" }
], "The same document the Offline Collector uses. When any <b>Send Emails</b> email is switched on, <code>send_emails</code> gives, for each individual and for Additional Recipients, whether the email is on and, if so, its <code>subject_line</code>, <code>message_body</code>, <code>merge_tags</code> (each <code>{{Field name}}</code> tag with the matching Contact Form field's <code>id</code> and <code>field_type</code>, or <code>null</code>), the email fields or addresses it goes to, and <code>included_individuals</code> (whose submitted details are added). Without <code>send_emails</code>, no email is on.")}
${endpointCard("PUT", "/referral_link_details/{id}/email_settings", "Set a Signup Page's Send Emails settings", true, [
{ name: "id", in: "path", type: "integer", required: true, desc: "Signup Page ID" },
{ name: "individuals", in: "body", type: "object[]", required: false, desc: "One per individual: <code>label</code> (as the definition gives it, e.g. <code>Individual A</code>), <code>enabled</code>, <code>subject_line</code>, <code>message_body</code> (HTML), <code>recipient_field_ids</code> (email fields on the individual's Contact Form), <code>include_submission_details</code> and <code>included_individuals</code> (labels)" },
{ name: "additional_recipients", in: "body", type: "object", required: false, desc: "<code>enabled</code>, <code>recipients</code> (email addresses), <code>subject_line</code>, <code>message_body</code>, <code>include_submission_details</code> and <code>included_individuals</code>" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>send_emails</code> as saved, in the definition's shape" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "403", cls: "response-4xx", desc: "You can see the Signup Page but aren't an Organisation Editor" },
{ code: "404", cls: "response-4xx", desc: "Not found, or a Signup Page you can't see" },
{ code: "422", cls: "response-4xx", desc: "<code>{errors: [...]}</code>: email messaging is switched off for the Organisation, an individual isn't on the Signup Page, a field isn't an email field, or an enabled email has no subject line, body or recipient" }
], "Saves what the <b>Send Emails</b> screen saves. Personalise an individual's email with <code>{{Field name}}</code> merge tags; Additional Recipients' emails aren't personalised. Individuals left out keep their settings. Everything is saved or nothing is.")}
</div>
</section>

Expand Down
Loading