{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://webservices.intecion.net/mail/contract/v1/schema.json", "title": "Intecion Notifications Webservice — wire contract v1", "description": "Bodies of every request and answer. Requests are closed (an unknown field is refused); answers are open (a client ignores fields it does not know).", "$defs": { "Host": { "description": "A public DNS name, lowercase, punycode for international names. No scheme, port, path or address literal.", "type": "string", "minLength": 4, "maxLength": 253, "pattern": "^(?=.{4,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])$" }, "Product": { "description": "The client product. The list is the service's.", "type": "string", "enum": [ "iapl", "iawl" ] }, "ProductVersion": { "type": "string", "minLength": 1, "maxLength": 32, "pattern": "^[0-9A-Za-z][0-9A-Za-z.+_-]*$" }, "Kind": { "type": "string", "enum": [ "form-notification", "form-confirmation", "account", "security-alert", "system", "test" ] }, "SiteState": { "type": "string", "enum": [ "pending", "active", "suspended" ] }, "Address": { "description": "A bare e-mail address. No display name, no angle brackets, no comment.", "type": "string", "minLength": 6, "maxLength": 254, "pattern": "^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z]([A-Za-z0-9-]{0,61}[A-Za-z0-9])$" }, "Nonce": { "type": "string", "pattern": "^[A-Za-z0-9_-]{32,128}$" }, "Token": { "description": "Opaque. Never logged, never shown.", "type": "string", "pattern": "^ims_[A-Za-z0-9_-]{43}$" }, "Window": { "type": "object", "required": [ "limit", "remaining" ], "properties": { "limit": { "type": "integer", "minimum": 0 }, "remaining": { "type": "integer", "minimum": 0 } } }, "Quota": { "type": "object", "required": [ "hour", "day" ], "properties": { "hour": { "$ref": "#/$defs/Window" }, "day": { "$ref": "#/$defs/Window" } } }, "EnrolRequest": { "type": "object", "additionalProperties": false, "required": [ "host", "nonce", "product", "productVersion" ], "properties": { "host": { "$ref": "#/$defs/Host" }, "nonce": { "$ref": "#/$defs/Nonce" }, "product": { "$ref": "#/$defs/Product" }, "productVersion": { "$ref": "#/$defs/ProductVersion" } }, "description": "No call-back path: the service calls the path fixed for the product (README §2)." }, "EnrolResponse": { "description": "Never carries the token: it went to the site's confirm endpoint.", "type": "object", "required": [ "ok", "state" ], "properties": { "ok": { "const": true }, "state": { "$ref": "#/$defs/SiteState" } }, "not": { "required": [ "token" ] } }, "CallbackRequest": { "description": "Sent BY the service TO the site's confirm endpoint: POST https://.", "type": "object", "additionalProperties": false, "required": [ "nonce", "token", "state" ], "properties": { "nonce": { "$ref": "#/$defs/Nonce" }, "token": { "$ref": "#/$defs/Token" }, "state": { "$ref": "#/$defs/SiteState" } } }, "CallbackResponse": { "description": "The site's answer: status 200, a body of at most 1024 bytes that is this JSON object and nothing else, within 8 seconds. confirmation = lowercase hex SHA-256 of the UTF-8 text nonce + \".\" + token.", "type": "object", "required": [ "confirmation" ], "properties": { "confirmation": { "type": "string", "pattern": "^[0-9a-f]{64}$" } } }, "Attachment": { "type": "object", "additionalProperties": false, "required": [ "filename", "contentType", "content" ], "properties": { "filename": { "type": "string", "minLength": 1, "maxLength": 255 }, "contentType": { "type": "string", "maxLength": 127, "pattern": "^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*$" }, "content": { "description": "Base64, standard alphabet, no line breaks, padded: the length is a multiple of four. The pattern states the alphabet only — a pattern that also stated the length would overflow regular-expression engines on a 10 MB file; the service checks the length.", "type": "string", "minLength": 4, "pattern": "^[A-Za-z0-9+/]+={0,2}$" } } }, "SendRequest": { "type": "object", "additionalProperties": false, "required": [ "product", "productVersion", "kind", "subject" ], "properties": { "product": { "$ref": "#/$defs/Product" }, "productVersion": { "$ref": "#/$defs/ProductVersion" }, "kind": { "$ref": "#/$defs/Kind" }, "to": { "description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).", "type": "array", "items": { "$ref": "#/$defs/Address" }, "maxItems": 50 }, "cc": { "description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).", "type": "array", "items": { "$ref": "#/$defs/Address" }, "maxItems": 50 }, "bcc": { "description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).", "type": "array", "items": { "$ref": "#/$defs/Address" }, "maxItems": 50 }, "replyTo": { "$ref": "#/$defs/Address" }, "senderName": { "description": "At most 256 characters (Unicode code points).", "type": "string", "maxLength": 256 }, "subject": { "description": "1 to 300 characters (code points). No line breaks, control characters or characters that hide or reorder text (README §3 has the exact rule and the three exceptions); must not start with the service's name in brackets.", "type": "string", "minLength": 1, "maxLength": 300 }, "text": { "type": "string", "minLength": 1 }, "html": { "type": "string", "minLength": 1 }, "attachments": { "type": "array", "items": { "$ref": "#/$defs/Attachment" }, "maxItems": 20 } }, "anyOf": [ { "required": [ "text" ] }, { "required": [ "html" ] } ], "allOf": [ { "if": { "properties": { "kind": { "const": "security-alert" } }, "required": [ "kind" ] }, "else": { "required": [ "to" ], "properties": { "to": { "minItems": 1 } } } } ] }, "SendResponse": { "type": "object", "required": [ "ok", "id", "replayed", "senderName", "warnings", "quota" ], "properties": { "ok": { "const": true }, "id": { "description": "The service's id of this message in its log.", "type": "string", "minLength": 1 }, "messageId": { "description": "The back end's id, when it gave one.", "type": "string" }, "replayed": { "description": "true when this Idempotency-Key was already sent and no second mail went out.", "type": "boolean" }, "senderName": { "description": "The name the mail left under.", "type": "string" }, "warnings": { "description": "Known today: sender-name-replaced. A client ignores a warning it does not know.", "type": "array", "items": { "type": "string" } }, "quota": { "description": "What is left for a message of the kind just sent.", "$ref": "#/$defs/Quota" } } }, "StatusResponse": { "type": "object", "required": [ "ok", "state", "host", "product", "service", "sender", "limits", "quota", "kinds", "token" ], "properties": { "ok": { "const": true }, "state": { "$ref": "#/$defs/SiteState" }, "host": { "$ref": "#/$defs/Host" }, "product": { "$ref": "#/$defs/Product" }, "service": { "type": "object", "required": [ "version", "contract" ], "properties": { "name": { "description": "The service's name, for a panel to show.", "type": "string" }, "version": { "type": "string" }, "contract": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" } } }, "sender": { "type": "object", "required": [ "address" ], "properties": { "address": { "$ref": "#/$defs/Address" } } }, "limits": { "type": "object", "required": [ "messagesPerHour", "messagesPerDay", "recipientsPerMessage", "perRecipientPerDay", "newRecipientsPerDay", "maxBodyBytes", "maxAttachmentBytes", "maxAttachments" ], "properties": { "messagesPerHour": { "type": "integer", "minimum": 0 }, "messagesPerDay": { "type": "integer", "minimum": 0 }, "recipientsPerMessage": { "type": "integer", "minimum": 1 }, "perRecipientPerDay": { "type": "integer", "minimum": 0 }, "newRecipientsPerDay": { "type": "integer", "minimum": 0 }, "maxBodyBytes": { "type": "integer", "minimum": 0 }, "maxAttachmentBytes": { "type": "integer", "minimum": 0 }, "maxAttachments": { "type": "integer", "minimum": 0 }, "serverAddresses": { "description": "Server addresses the site may send from at a time.", "type": "integer", "minimum": 1 }, "securityAlertsPerDay": { "description": "Security alerts a day: a budget of their own, outside the hour and day limits.", "type": "integer", "minimum": 0 } } }, "quota": { "$ref": "#/$defs/Quota" }, "kinds": { "type": "array", "items": { "type": "string" } }, "token": { "type": "object", "required": [ "issuedAt", "rotateAfter" ], "properties": { "issuedAt": { "type": "string", "format": "date-time" }, "rotateAfter": { "type": "string", "format": "date-time" } } }, "senderName": { "description": "The name the last mail left under, when there was one.", "type": "string" } } }, "RotateResponse": { "type": "object", "required": [ "ok", "token", "previousValidUntil" ], "properties": { "ok": { "const": true }, "token": { "$ref": "#/$defs/Token" }, "previousValidUntil": { "type": "string", "format": "date-time" } } }, "RevokeResponse": { "type": "object", "required": [ "ok" ], "properties": { "ok": { "const": true } } }, "HealthResponse": { "description": "No detail on purpose — also when it says no: the one answer that is not an Error.", "type": "object", "additionalProperties": false, "required": [ "ok" ], "properties": { "ok": { "type": "boolean" } } }, "ErrorCode": { "type": "string", "enum": [ "invalid-request", "invalid-token", "reverify", "site-pending", "site-suspended", "host-not-allowed", "enrolment-closed", "enrolment-in-progress", "callback-failed", "host-mismatch", "browser-not-allowed", "not-found", "method-not-allowed", "unsupported-media-type", "idempotency-conflict", "in-progress", "already-rotated", "too-large", "too-many-recipients", "attachment-refused", "recipient-suppressed", "rate-limited", "quota-exceeded", "backend-failed", "unavailable", "internal" ], "description": "The codes the service answers with today. The list grows with minor versions; that is why Error.code is an open string." }, "Error": { "type": "object", "required": [ "ok", "code", "message", "retryable" ], "properties": { "ok": { "const": false }, "code": { "description": "One of ErrorCode today. A client that meets a code it does not know acts on `retryable`.", "type": "string", "minLength": 1 }, "message": { "description": "For a log or an administrator. English. Never shown to a visitor.", "type": "string" }, "retryable": { "description": "true: the same request, with the same Idempotency-Key, may be sent again after a short wait.", "type": "boolean" }, "retryAfter": { "description": "Seconds.", "type": "integer", "minimum": 0 }, "field": { "description": "With invalid-request: the field at fault. With attachment-refused: which file, as attachments[n] (n from 0).", "type": "string" }, "limit": { "description": "With quota-exceeded: hour, day, alerts, recipient, new-recipients or service. With too-large: request, body or attachments.", "type": "string" }, "reason": { "description": "With callback-failed: unreachable, timeout, redirect, status or confirmation.", "type": "string" } } } } }