Raw schema
{
"type": "object",
"properties": {
"idempotency_key": {
"type": "string",
"description": "Optional idempotency key to make retries safe."
},
"body": {
"$ref": "#/$defs/AutomationUpsertRequest",
"type": "object",
"description": "The exact JSON request body defined by the Mailrith public API contract."
}
},
"required": [
"body"
],
"additionalProperties": false,
"$defs": {
"AutomationUpsertRequest": {
"type": "object",
"required": [
"name",
"definition"
],
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"definition": {
"$ref": "#/$defs/AutomationDefinition"
}
}
},
"AutomationDefinition": {
"type": "object",
"additionalProperties": false,
"required": [
"steps"
],
"properties": {
"version": {
"type": "integer",
"enum": [
2
]
},
"trigger": {
"anyOf": [
{
"$ref": "#/$defs/AutomationTrigger"
},
{
"type": "null"
}
]
},
"triggers": {
"type": "array",
"items": {
"$ref": "#/$defs/AutomationTrigger"
}
},
"entryPoints": {
"type": "array",
"items": {
"$ref": "#/$defs/AutomationEntryPoint"
}
},
"steps": {
"type": "array",
"maxItems": 256,
"items": {
"$ref": "#/$defs/AutomationStep"
}
}
},
"example": {
"version": 2,
"trigger": {
"type": "tag_added",
"tagIds": [
"tag_welcome"
]
},
"steps": [
{
"id": "send-welcome-email",
"kind": "action",
"type": "send_email",
"config": {
"subject": "Welcome",
"previewText": "Thanks for joining",
"bodyDocument": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Welcome to Mailrith."
}
]
}
]
},
"replyToEmail": "",
"trackOpens": true,
"trackClicks": true,
"utmSource": "",
"utmMedium": "",
"utmCampaign": "",
"utmTerm": "",
"utmContent": ""
}
}
]
},
"examples": [
{
"version": 2,
"trigger": {
"type": "tag_added",
"tagIds": [
"tag_welcome"
]
},
"steps": [
{
"id": "send-welcome-email",
"kind": "action",
"type": "send_email",
"config": {
"subject": "Welcome",
"previewText": "Thanks for joining",
"bodyDocument": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Welcome to Mailrith."
}
]
}
]
},
"replyToEmail": "",
"trackOpens": true,
"trackClicks": true,
"utmSource": "",
"utmMedium": "",
"utmCampaign": "",
"utmTerm": "",
"utmContent": ""
}
}
]
}
]
},
"AutomationTrigger": {
"type": "object",
"additionalProperties": false,
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"tag_added",
"tag_removed",
"magic_link_clicked",
"subscriber_status"
]
},
"tagId": {
"type": [
"string",
"null"
]
},
"tagIds": {
"type": "array",
"items": {
"type": "string"
}
},
"magicLinkId": {
"type": [
"string",
"null"
]
},
"magicLinkIds": {
"type": "array",
"items": {
"type": "string"
}
},
"operator": {
"type": "string",
"enum": [
"is",
"is_not"
]
},
"statuses": {
"type": "array",
"items": {
"type": "string",
"enum": [
"Active",
"Unconfirmed",
"Unsubscribed",
"Complained",
"Bounced",
"Blocked"
]
}
}
}
},
"AutomationEntryPoint": {
"type": "object",
"additionalProperties": false,
"required": [
"id",
"trigger"
],
"properties": {
"id": {
"type": "string"
},
"trigger": {
"$ref": "#/$defs/AutomationTrigger"
},
"name": {
"type": [
"string",
"null"
]
},
"description": {
"type": [
"string",
"null"
]
}
}
},
"AutomationStep": {
"type": "object",
"additionalProperties": false,
"required": [
"id",
"kind",
"type"
],
"properties": {
"id": {
"type": "string"
},
"kind": {
"type": "string",
"enum": [
"event",
"action",
"condition"
]
},
"type": {
"type": "string",
"enum": [
"tag_added",
"tag_removed",
"magic_link_clicked",
"sequence_completed",
"add_tag",
"remove_tag",
"add_to_sequence",
"remove_from_sequence",
"change_subscriber_status",
"wait",
"update_custom_field",
"send_email",
"send_internal_notification",
"start_automation",
"remove_from_automation",
"webhook",
"end_automation",
"has_tag",
"custom_field_match",
"sequence_membership",
"subscriber_status",
"email_opened",
"email_clicked"
]
},
"config": {
"$ref": "#/$defs/AutomationStepConfig"
},
"stats": {
"$ref": "#/$defs/EmailEngagementStats"
},
"note": {
"type": [
"string",
"null"
]
},
"nextStepId": {
"type": [
"string",
"null"
]
},
"branches": {
"type": "object",
"additionalProperties": {
"type": [
"string",
"null"
]
}
},
"paths": {
"type": "array",
"items": {
"$ref": "#/$defs/AutomationPath"
}
}
}
},
"AutomationStepConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"tagId": {
"type": "string"
},
"sequenceId": {
"type": "string"
},
"magicLinkId": {
"type": "string"
},
"customFieldId": {
"type": "string"
},
"automationId": {
"type": "string"
},
"emailId": {
"type": "string"
},
"status": {
"type": "string"
},
"statuses": {
"type": "array",
"items": {
"type": "string"
}
},
"operation": {
"type": "string",
"enum": [
"set",
"clear",
"increment",
"decrement",
"set_today",
"add_choices",
"remove_choices",
"set_true",
"set_false",
"toggle"
]
},
"operator": {
"type": "string",
"enum": [
"equals",
"not_equals",
"contains",
"not_contains",
"starts_with",
"ends_with",
"exists",
"missing",
"greater_than",
"greater_than_or_equal",
"less_than",
"less_than_or_equal",
"on",
"not_on",
"before",
"on_or_before",
"after",
"on_or_after",
"contains_any",
"contains_all",
"does_not_contain_any",
"is_checked",
"is_not_checked"
]
},
"value": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"mode": {
"type": "string",
"enum": [
"duration",
"until_custom_date",
"until_custom_field_date"
]
},
"waitMode": {
"type": "string",
"enum": [
"duration",
"custom_date"
]
},
"dateSource": {
"type": "string",
"enum": [
"custom_field",
"fixed_date"
]
},
"date": {
"type": "string",
"format": "date"
},
"timeOfDay": {
"type": "string",
"pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
},
"durationValue": {
"type": "number",
"minimum": 0
},
"durationUnit": {
"type": "string",
"enum": [
"minute",
"hour",
"day",
"week"
]
},
"waitForCompletion": {
"type": "boolean"
},
"waitUntilComplete": {
"type": "boolean"
},
"exitNextStepId": {
"type": [
"string",
"null"
]
},
"lookbackDays": {
"type": "integer",
"minimum": 1
},
"recipientEmail": {
"type": "string",
"format": "email"
},
"subject": {
"type": "string"
},
"previewText": {
"type": "string"
},
"bodyDocument": {
"$ref": "#/$defs/BroadcastEmailDocument"
},
"replyToEmail": {
"type": "string"
},
"trackOpens": {
"type": "boolean"
},
"trackClicks": {
"type": "boolean"
},
"utmSource": {
"type": "string"
},
"utmMedium": {
"type": "string"
},
"utmCampaign": {
"type": "string"
},
"utmTerm": {
"type": "string"
},
"utmContent": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
},
"method": {
"type": "string",
"enum": [
"POST",
"PUT",
"PATCH"
]
},
"authType": {
"type": "string",
"enum": [
"none",
"bearer"
]
},
"bearerToken": {
"type": "string",
"writeOnly": true
},
"bearerTokenConfigured": {
"type": "boolean",
"description": "True when Mailrith has a saved webhook bearer token. Send this unchanged during an update to preserve the saved value. The token value is never returned."
},
"headers": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string",
"writeOnly": true,
"description": "A secret header value accepted on writes and never returned."
},
"configured": {
"type": "boolean",
"description": "True when Mailrith has a saved value for this header. Send this unchanged during an update to preserve the saved value."
}
}
}
},
"includeSubscriber": {
"type": "boolean"
},
"includeTags": {
"type": "boolean"
},
"includeCustomFields": {
"type": "boolean"
}
}
},
"BroadcastEmailDocument": {
"allOf": [
{
"$ref": "#/$defs/BroadcastEmailNode"
}
],
"description": "A structured email document. The root node must use type `doc` and contain supported block nodes.",
"example": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Hello from Mailrith."
}
]
}
]
},
"examples": [
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Hello from Mailrith."
}
]
}
]
}
]
},
"BroadcastEmailNode": {
"type": "object",
"additionalProperties": false,
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"doc",
"paragraph",
"heading",
"text",
"hardBreak",
"bulletList",
"orderedList",
"listItem",
"blockquote",
"emailSection",
"emailSectionColumn",
"emailButton",
"image",
"horizontalRule"
]
},
"attrs": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
},
"level": {
"type": "integer",
"enum": [
1,
2,
3
]
},
"textAlign": {
"type": "string",
"enum": [
"left",
"center",
"right",
"justify"
]
},
"columns": {
"type": "integer",
"enum": [
1,
2,
3
]
},
"width": {
"type": "string",
"enum": [
"default",
"large",
"full",
"fit"
]
},
"backgroundColor": {
"type": "string"
},
"blockquoteBorderColor": {
"type": "string"
},
"linkColor": {
"type": "string"
},
"layoutAlignment": {
"type": "string",
"enum": [
"left",
"center"
]
},
"backgroundImageUrl": {
"type": "string"
},
"margin": {
"type": "string",
"enum": [
"none",
"normal",
"large"
]
},
"padding": {
"type": "string",
"enum": [
"none",
"normal",
"large"
]
},
"borderColor": {
"type": "string"
},
"borderWidth": {
"type": "string",
"enum": [
"none",
"normal",
"large"
]
},
"borderRadius": {
"type": "string",
"enum": [
"none",
"normal",
"small",
"large",
"full"
]
},
"verticalAlign": {
"type": "string",
"enum": [
"top",
"middle",
"bottom"
]
},
"href": {
"type": "string"
},
"textColor": {
"type": "string"
},
"size": {
"type": "string",
"enum": [
"small",
"medium",
"large"
]
},
"align": {
"type": "string",
"enum": [
"left",
"center",
"right"
]
},
"label": {
"type": "string"
},
"src": {
"type": "string"
},
"alt": {
"type": "string"
},
"title": {
"type": "string"
},
"caption": {
"type": "string"
},
"source": {
"type": "string",
"enum": [
"unsplash"
]
},
"unsplash": {
"type": "object",
"additionalProperties": false,
"required": [
"photographerName"
],
"properties": {
"photoId": {
"type": "string"
},
"photographerName": {
"type": "string"
},
"photographerUsername": {
"type": "string"
},
"photographerUrl": {
"type": "string"
},
"unsplashUrl": {
"type": "string"
}
}
},
"widthPercent": {
"type": "number",
"minimum": 1,
"maximum": 100
},
"crop": {
"type": "string",
"enum": [
"none",
"square",
"circle"
]
},
"fillColumn": {
"type": "boolean"
}
}
},
"content": {
"type": "array",
"items": {
"$ref": "#/$defs/BroadcastEmailNode"
}
},
"text": {
"type": "string"
},
"marks": {
"type": "array",
"items": {
"$ref": "#/$defs/BroadcastEmailMark"
}
}
}
},
"BroadcastEmailMark": {
"type": "object",
"additionalProperties": false,
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"bold",
"italic",
"strike",
"underline",
"link",
"textStyle",
"highlight"
]
},
"attrs": {
"type": "object",
"additionalProperties": false,
"properties": {
"href": {
"type": "string"
},
"color": {
"type": "string"
},
"fontSize": {
"type": "string"
}
}
}
}
},
"EmailEngagementStats": {
"type": "object",
"additionalProperties": false,
"required": [
"recipientCount",
"openedCount",
"clickedCount",
"unsubscribedCount"
],
"properties": {
"recipientCount": {
"type": "integer",
"minimum": 0
},
"engagedCount": {
"type": "integer",
"minimum": 0
},
"openedCount": {
"type": "integer",
"minimum": 0
},
"clickedCount": {
"type": "integer",
"minimum": 0
},
"clickedSubscriberCount": {
"type": "integer",
"minimum": 0
},
"unsubscribedCount": {
"type": "integer",
"minimum": 0
},
"bouncedCount": {
"type": "integer",
"minimum": 0
},
"complainedCount": {
"type": "integer",
"minimum": 0
},
"sentCountsByDay": {
"type": "object",
"additionalProperties": {
"type": "integer",
"minimum": 0
}
}
}
},
"AutomationPath": {
"type": "object",
"additionalProperties": false,
"required": [
"id",
"label"
],
"properties": {
"id": {
"type": "string"
},
"label": {
"type": "string"
},
"nextStepId": {
"type": [
"string",
"null"
]
},
"weight": {
"type": [
"number",
"null"
]
}
}
}
}
}