Skip to content
v1.0.0
OpenAPI 3.0.3

Email Document State API

Create an email model from HTML and CSS, read and update its document state, and get the JSON Schema of the document state, all without opening the editor.

The document state is the JSON representation of the email content and styles, the same structure the editor works with. Fetch the schema from the schema method and validate your document states against it instead of relying on a fixed copy: the schema evolves together with the editor.

All methods require a plugin token with the API role. The email is identified by the ES-PLUGIN-UI-DATA header, which carries a URL-encoded JSON object with the emailId, the same value you pass in metadata on editor initialization. The schema method does not need this header.

When the Email Resources Permissions API is enabled in your plugin settings, Stripo asks your endpoint for an EMAIL permission before every email operation: READ for reading the document state and MODIFY for updating it and for creating an email. MODIFY does not imply READ.

Server:https://plugins.stripo.email

Stripo Plugin API server

Client Libraries

Methods

​

Create an email model from HTML and CSS

​

Creates the initial model of an email from HTML and CSS. The email is identified by the emailId from the ES-PLUGIN-UI-DATA header; the model is created for your plugin under this ID.

The method is idempotent: if a model with this ID already exists, the response is 200 with the same modelId, and the existing model is neither regenerated nor overwritten, even if the request carries different HTML or CSS.

The HTML and CSS are converted into the model on the server. When the email is opened in the editor for the first time, the editor may additionally normalize the model, as it does for any email. AMP content is not processed on creation the way the editor processes it. For emails with AMP content, pass the HTML and CSS through the html and css initialization parameters of the editor instead.

Creating an email does not send an Email Change Notification.

Unknown fields in the request body are rejected. Limits: request body up to 32 MiB, html up to 18 MiB, css up to 4 MiB, variables up to 8 MiB, author up to 254 bytes, utm up to 256 KiB. All limits are byte limits.

Requires the EMAIL MODIFY permission when the Email Resources Permissions API is enabled, including for repeated requests for an existing model.

Headers

  • URL-encoded JSON object with the emailId of the email, the same value you pass in metadata on editor initialization. For example, {"emailId":"123"} is sent as %7B%22emailId%22%3A%22123%22%7D. The emailId must be a non-blank string of at most 100 bytes; the encoded header is limited to 3000 bytes. Other string values of the object are passed to the Email Resources Permissions API callback as uiData.

  • Optional trace ID of your request, at most 100 bytes. Include it when contacting support.

Body·

required
application/json
  • Author recorded in the version history of the email, for example an email address. Required, non-blank, at most 254 bytes.

  • HTML of the email. Required, non-empty.

  • CSS of the email. Optional; omitted means an empty string. null is not allowed.

  • Whether buttons are exported with Outlook (VML) markup by default. Pass false to disable it for the new email. The default here is true, while the default of the corresponding supportOutlookButtonsByDefault editor initialization parameter is false.

  • UTM parameters stored with the email. Omitted or null means no UTM configuration. Standard values default to an empty string and cannot be null; each value is limited to 2 KiB.

    Properties: 6
  • Email variables (CSS custom properties) as a JSON object. Scalars, arrays and null are rejected.

    Properties: 1

Responses

  • The model was created, or an existing model was found and left unchanged.

    • Identifier of the model in the format <pluginId>_<emailId>.

    application/json
  • Invalid header, content type or request body, or MODEL_CREATION_INVALID_REQUEST. INVALID_CONTENT_TYPE — Content-Type is not application/json. INVALID_REQUEST — invalid JSON, an unknown field, or a missing or invalid field value. MODEL_RESOLUTION_BAD_REQUEST — invalid ES-PLUGIN-UI-DATA header. INVALID_TRACE_ID — the X-Trace-ID header is too long. MODEL_CREATION_INVALID_REQUEST — the HTML or CSS could not be converted into a model.

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • Missing or invalid plugin token.

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • The token does not have the API role, or the EMAIL MODIFY permission was not granted.

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • The email with this emailId is being deleted by a Delete Email Models job (MODEL_DELETING). Wait until the deletion finishes and send the request again.

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • The request body or one of its fields exceeds the limit (PAYLOAD_TOO_LARGE).

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • The CSS cannot be parsed (MODEL_CREATION_CSS_PARSE_ERROR) or the model could not be built (PATCH_APPLICATION_HANGS). The model is not saved. For MODEL_CREATION_CSS_PARSE_ERROR, location points to the error in the CSS. PATCH_APPLICATION_HANGS means processing exceeded the time limit. Retry when retryable is true; if the error repeats, simplify the HTML or contact support.

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • Rate limit exceeded. Retry after the number of seconds in the Retry-After header.

    Headers
    Headers: 1
    text/plain
  • Internal error (PERSISTENCE_FAILED, INVALID_RESPONSE, INTERNAL).

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • A dependent service is temporarily unavailable (MODEL_RESOLUTION_UNAVAILABLE, DOWNSTREAM_UNAVAILABLE). Retry when retryable is true.

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
  • The operation timed out (REQUEST_TIMEOUT).

    • Processing step where the error occurred. For diagnostics only; the values may change.

    • Position in the CSS for parse errors.

      Properties: 4
    • Part of the request that the error relates to, when known, for example author or input-css.

    application/json
Request Example for post/coediting/v1/email/create
curl https://plugins.stripo.email/coediting/v1/email/create \
  --request POST \
  --header 'ES-PLUGIN-UI-DATA: %7B%22emailId%22%3A%22123%22%7D' \
  --header 'Content-Type: application/json' \
  --header 'ES-PLUGIN-AUTH: YOUR_SECRET_TOKEN' \
  --data '{
  "html": "<!doctype html><html><body><p>Hello</p></body></html>",
  "css": "p { color: #123456; }",
  "author": "backend@example.com"
}'
{
  "modelId": "7_123"
}

Get the current document state

​

Returns the current document state of the email. The method does not create a model for an email that has never been opened or created: such an email returns 404.

Requires the EMAIL READ permission when the Email Resources Permissions API is enabled.

Headers

  • URL-encoded JSON object with the emailId of the email, the same value you pass in metadata on editor initialization. For example, {"emailId":"123"} is sent as %7B%22emailId%22%3A%22123%22%7D. The emailId must be a non-blank string of at most 100 bytes; the encoded header is limited to 3000 bytes. Other string values of the object are passed to the Email Resources Permissions API callback as uiData.

  • Optional trace ID of your request, at most 100 bytes. Include it when contacting support.

Responses

  • The current document state of the email.

    • Document state of the email. Get the full structure from the schema method; it is not duplicated here.

      Properties: 1
    application/json
  • Invalid ES-PLUGIN-UI-DATA or X-Trace-ID header, invalid content type or JSON body, missing targetDocumentState, or a document state body over 20 MiB. Depending on the check, the body is a JSON error object with the BAD_REQUEST code or a text response with a message.

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

  • Missing or invalid plugin token.

    text/plain
  • The token does not have the API role, or the required EMAIL permission was not granted. MODIFY does not imply READ.

    text/plain
  • The email has no model yet (MODEL_NOT_FOUND).

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

    application/json
  • Rate limit exceeded. Retry after the number of seconds in the Retry-After header.

    Headers
    Headers: 1
    text/plain
  • Other errors: 404 the email has no model; 405 wrong HTTP method; 408 CANCELED; 409 REVISION_CONFLICT or STALE_DOCUMENT_STATE (the model changed while the update was being applied: read the current state and repeat); 413 the payload is too large; 422 VALIDATION_ERROR, PARSE_ERROR, SIDE_EFFECT_UNAVAILABLE, MERGE_ERROR or PATCH_APPLICATION_HANGS; 500 INTERNAL; 504 TIMEOUT. Retry only when retryable is true.

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

    application/json
Request Example for get/coediting/v1/email/document-state
curl https://plugins.stripo.email/coediting/v1/email/document-state \
  --header 'ES-PLUGIN-UI-DATA: %7B%22emailId%22%3A%22123%22%7D' \
  --header 'ES-PLUGIN-AUTH: YOUR_SECRET_TOKEN'
{
  "documentStateResult": {
    "additionalProperty": "anything"
  }
}

Update the document state

​

Applies changes to the document state of the email.

targetDocumentState is the state you want the email to have. When you also pass baseDocumentState, the state you read before making your changes, only the differences between the base and the target are applied to the current model. Values that users have changed in the editor in the meantime and that your changes do not touch are preserved. When baseDocumentState is omitted, the current state of the model is used as the base. This can overwrite changes made after you read the state. To preserve those changes, pass the unchanged documentStateResult from the get method as baseDocumentState.

If a node or parent that the changes refer to no longer exists in the model, the whole update fails and nothing is applied. An empty difference succeeds without changes.

The server performs additional checks, so a state that matches the JSON Schema can still be rejected with 422 VALIDATION_ERROR; details.errors lists the invalid fields.

A successful response means the changes are saved to the model and queued for delivery to open editor sessions; it does not wait for the sessions to receive them. An update that saves changes also triggers the Email Change Notification, if configured in your plugin settings, with an empty userId. If an error response contains committed: true, part of the operation was already saved: read the current state and reconcile instead of repeating the request. Use operationId when contacting support.

The request body is limited to 20 MiB. Requires the EMAIL MODIFY permission when the Email Resources Permissions API is enabled.

Headers

  • URL-encoded JSON object with the emailId of the email, the same value you pass in metadata on editor initialization. For example, {"emailId":"123"} is sent as %7B%22emailId%22%3A%22123%22%7D. The emailId must be a non-blank string of at most 100 bytes; the encoded header is limited to 3000 bytes. Other string values of the object are passed to the Email Resources Permissions API callback as uiData.

  • Optional trace ID of your request, at most 100 bytes. Include it when contacting support.

Body

required
application/json
  • Document state of the email. Get the full structure from the schema method; it is not duplicated here.

    Properties: 1
  • Document state of the email. Get the full structure from the schema method; it is not duplicated here.

    Properties: 1

Responses

  • The differences were applied and saved.

    • Number of changes applied to the model.

    • Number of patches saved to the model history.

    application/json
  • Invalid ES-PLUGIN-UI-DATA or X-Trace-ID header, invalid content type or JSON body, missing targetDocumentState, or a document state body over 20 MiB. Depending on the check, the body is a JSON error object with the BAD_REQUEST code or a text response with a message.

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

  • Missing or invalid plugin token.

    text/plain
  • The token does not have the API role, or the required EMAIL permission was not granted. MODIFY does not imply READ.

    text/plain
  • Rate limit exceeded. Retry after the number of seconds in the Retry-After header.

    Headers
    Headers: 1
    text/plain
  • Other errors: 404 the email has no model; 405 wrong HTTP method; 408 CANCELED; 409 REVISION_CONFLICT or STALE_DOCUMENT_STATE (the model changed while the update was being applied: read the current state and repeat); 413 the payload is too large; 422 VALIDATION_ERROR, PARSE_ERROR, SIDE_EFFECT_UNAVAILABLE, MERGE_ERROR or PATCH_APPLICATION_HANGS; 500 INTERNAL; 504 TIMEOUT. Retry only when retryable is true.

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

    application/json
Request Example for put/coediting/v1/email/document-state
curl https://plugins.stripo.email/coediting/v1/email/document-state \
  --request PUT \
  --header 'ES-PLUGIN-UI-DATA: %7B%22emailId%22%3A%22123%22%7D' \
  --header 'Content-Type: application/json' \
  --header 'ES-PLUGIN-AUTH: YOUR_SECRET_TOKEN' \
  --data '{
  "targetDocumentState": {
    "additionalProperty": "anything"
  },
  "baseDocumentState": {
    "additionalProperty": "anything"
  }
}'
{
  "appliedActions": 4,
  "generatedPatchesCount": 1
}

Get the document state JSON Schema

​

Returns the JSON Schema that describes the document state for the current version of the editor. Use it to validate document states before sending them with the update method. The schema changes together with the editor, so fetch it rather than storing a copy.

Requires only a plugin token with the API role. The ES-PLUGIN-UI-DATA header is not needed and is ignored if sent.

Headers

  • Optional trace ID of your request, at most 100 bytes. Include it when contacting support.

Responses

  • The current document state schema.

    • Properties: 1
    application/json
  • Invalid ES-PLUGIN-UI-DATA or X-Trace-ID header, invalid content type or JSON body, missing targetDocumentState, or a document state body over 20 MiB. Depending on the check, the body is a JSON error object with the BAD_REQUEST code or a text response with a message.

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

  • Missing or invalid plugin token.

    text/plain
  • The token does not have the API role, or the required EMAIL permission was not granted. MODIFY does not imply READ.

    text/plain
  • Rate limit exceeded. Retry after the number of seconds in the Retry-After header.

    Headers
    Headers: 1
    text/plain
  • Other errors: 404 the email has no model; 405 wrong HTTP method; 408 CANCELED; 409 REVISION_CONFLICT or STALE_DOCUMENT_STATE (the model changed while the update was being applied: read the current state and repeat); 413 the payload is too large; 422 VALIDATION_ERROR, PARSE_ERROR, SIDE_EFFECT_UNAVAILABLE, MERGE_ERROR or PATCH_APPLICATION_HANGS; 500 INTERNAL; 504 TIMEOUT. Retry only when retryable is true.

    • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

    • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

      Properties: 1
    • Identifier of the operation. Include it when contacting support.

    • Processing step where the error occurred.

    application/json
Request Example for get/coediting/v1/document-state/schema
curl https://plugins.stripo.email/coediting/v1/document-state/schema \
  --header 'ES-PLUGIN-AUTH: YOUR_SECRET_TOKEN'
{
  "documentStateSchema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object"
  }
}

Models

​

Document state of the email. Get the full structure from the schema method; it is not duplicated here.

​
  • Author recorded in the version history of the email, for example an email address. Required, non-blank, at most 254 bytes.

  • HTML of the email. Required, non-empty.

  • CSS of the email. Optional; omitted means an empty string. null is not allowed.

  • Whether buttons are exported with Outlook (VML) markup by default. Pass false to disable it for the new email. The default here is true, while the default of the corresponding supportOutlookButtonsByDefault editor initialization parameter is false.

  • UTM parameters stored with the email. Omitted or null means no UTM configuration. Standard values default to an empty string and cannot be null; each value is limited to 2 KiB.

    Properties: 6
  • Email variables (CSS custom properties) as a JSON object. Scalars, arrays and null are rejected.

    Properties: 1
​

UTM parameters stored with the email. Omitted or null means no UTM configuration. Standard values default to an empty string and cannot be null; each value is limited to 2 KiB.

  • Custom UTM parameters. Names must be unique (case-sensitive) and at most 256 bytes. null is not allowed.

    Properties: 2
​
  • true when part of the update was already saved before the error. Read the current state and reconcile instead of repeating the request.

  • Bounded diagnostics, for example validation or parse errors. truncated indicates that some records were omitted. Lists contain at most 100 entries: errors for VALIDATION_ERROR (entries with path and message), parseErrors for PARSE_ERROR, and unavailableSideEffects for SIDE_EFFECT_UNAVAILABLE.

    Properties: 1
  • Identifier of the operation. Include it when contacting support.

  • Processing step where the error occurred.

​
  • Processing step where the error occurred. For diagnostics only; the values may change.

  • Position in the CSS for parse errors.

    Properties: 4
  • Part of the request that the error relates to, when known, for example author or input-css.