> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a message to an underwriting submission

> Adds one inbound message from the broker (an email today; SMS or chat in the same shape) and the documents it carries to a submission. Does not start an extraction.

Send the message either as its file or as fields. For an email, upload its `.eml` first with the upload pair and name it in `raw`: the body becomes an `Email.txt` document (part `message`) and each attachment a document (part `attachment:<n>`, from 1). `from`, `receivedAt` and `text` may then be left out; when given they must agree with the file (its From address, its Date and its body), and `documents` must be left out. Without `raw`, `text` becomes the `message` document, and `documents` are files already uploaded to this submission (`artifactId`) or small text given inline (`name` ending in `.txt` or `.md`, `text` up to 64 KiB), each part `document:<n>`. A raw file that does not parse for its channel, a disagreement with it, or a document that is not this submission's is 422 `invalid_message`. An attachment the file store refuses is listed in `rejected` and the rest are kept.

`externalId` (an email's Message-ID) makes the request safe to retry: the same `externalId` with the same body adds nothing and answers 200 with the same message; another body is 409 `idempotency_conflict`. Each document's id derives from the submission, the `externalId` and the part, so a retry finds the same documents.

Needs edit access to the submission (403 for a reader, 404 when it cannot be read). Only where the workspace has underwriting turned on (403 `feature_not_enabled`).

Alpha: this operation may change or be removed without notice.



## OpenAPI

````yaml /openapi.json post /insurance/underwriting/submissions/{submissionId}/messages
openapi: 3.0.3
info:
  title: Effective API
  version: 2.0.0
  description: The public Effective REST API. Authenticate using an Effective API key.
servers:
  - url: https://api.canary.effectiveai.app/api/v2
    description: Canary
security:
  - bearerAuth: []
paths:
  /insurance/underwriting/submissions/{submissionId}/messages:
    post:
      tags:
        - Underwriting submissions
      summary: Add a message to an underwriting submission
      description: >-
        Adds one inbound message from the broker (an email today; SMS or chat in
        the same shape) and the documents it carries to a submission. Does not
        start an extraction.


        Send the message either as its file or as fields. For an email, upload
        its `.eml` first with the upload pair and name it in `raw`: the body
        becomes an `Email.txt` document (part `message`) and each attachment a
        document (part `attachment:<n>`, from 1). `from`, `receivedAt` and
        `text` may then be left out; when given they must agree with the file
        (its From address, its Date and its body), and `documents` must be left
        out. Without `raw`, `text` becomes the `message` document, and
        `documents` are files already uploaded to this submission (`artifactId`)
        or small text given inline (`name` ending in `.txt` or `.md`, `text` up
        to 64 KiB), each part `document:<n>`. A raw file that does not parse for
        its channel, a disagreement with it, or a document that is not this
        submission's is 422 `invalid_message`. An attachment the file store
        refuses is listed in `rejected` and the rest are kept.


        `externalId` (an email's Message-ID) makes the request safe to retry:
        the same `externalId` with the same body adds nothing and answers 200
        with the same message; another body is 409 `idempotency_conflict`. Each
        document's id derives from the submission, the `externalId` and the
        part, so a retry finds the same documents.


        Needs edit access to the submission (403 for a reader, 404 when it
        cannot be read). Only where the workspace has underwriting turned on
        (403 `feature_not_enabled`).


        Alpha: this operation may change or be removed without notice.
      operationId: addUnderwritingSubmissionMessage
      parameters:
        - schema:
            type: string
            format: uuid
            description: The submission’s id.
          required: true
          description: The submission’s id.
          name: submissionId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V2AddUnderwritingSubmissionMessageRequest'
      responses:
        '200':
          description: >-
            A retry with the same externalId and body: the message as first
            added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2UnderwritingSubmissionMessage'
        '201':
          description: The message and the documents it added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2UnderwritingSubmissionMessage'
        '400':
          description: 'invalid_request: an unknown or invalid field, or submission id.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '403':
          description: >-
            feature_not_enabled: underwriting is not enabled for the workspace.
            forbidden: the caller can read the submission and not edit it, or
            the credential may not write.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '404':
          description: 'not_found: no such submission, or the caller cannot read it.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '409':
          description: >-
            idempotency_conflict: a message with this externalId was added with
            a different body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '413':
          description: 'request_too_large: the body is over 1 MiB.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '415':
          description: 'unsupported_media_type: use application/json.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '422':
          description: >-
            invalid_message: raw does not parse for its channel, the message
            disagrees with it, or a document is not this submission’s.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
      security:
        - bearerAuth: []
components:
  schemas:
    V2AddUnderwritingSubmissionMessageRequest:
      type: object
      properties:
        channel:
          type: string
          enum:
            - email
            - sms
            - chat
          description: 'How the message arrived: `email`, `sms` or `chat`.'
        externalId:
          type: string
          minLength: 1
          maxLength: 998
          description: >-
            The channel’s own id for the message, such as an email’s Message-ID.
            A retry with the same id and body adds nothing.
        threadRef:
          type: string
          minLength: 1
          maxLength: 998
          description: The channel’s thread id, kept as sent.
        from:
          type: string
          minLength: 1
          maxLength: 320
          description: 'The sender: an email address, phone number or handle.'
        receivedAt:
          type: string
          format: date-time
          description: When the message arrived.
        text:
          type: string
          minLength: 1
          maxLength: 200000
          description: The message’s text.
        raw:
          type: object
          properties:
            artifactId:
              type: string
              format: uuid
              description: >-
                The message as it arrived, uploaded to this submission first: an
                email’s `.eml`.
          required:
            - artifactId
          additionalProperties: false
        documents:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  artifactId:
                    type: string
                    format: uuid
                    description: >-
                      A document already uploaded to this submission, by its
                      artifact id.
                required:
                  - artifactId
                additionalProperties: false
              - type: object
                properties:
                  name:
                    type: string
                    minLength: 5
                    maxLength: 200
                    pattern: ^[^\\/\x00-\x1f\x7f-\x9f]+\.(?:[tT][xX][tT]|[mM][dD])$
                    description: >-
                      Filename ending in `.txt` or `.md`, such as
                      `call-notes.txt`.
                  text:
                    type: string
                    minLength: 1
                    description: >-
                      The document’s text: at most 64 KiB of UTF-8. Upload
                      larger or binary files.
                required:
                  - name
                  - text
                additionalProperties: false
          maxItems: 50
          description: >-
            Files that came with the message. With `raw`, its attachments are
            the documents.
      required:
        - channel
        - externalId
      additionalProperties: false
    V2UnderwritingSubmissionMessage:
      type: object
      properties:
        id:
          type: string
          format: uuid
        channel:
          type: string
          minLength: 1
          description: 'Extensible: `email`, `sms` or `chat`.'
        externalId:
          type: string
          minLength: 1
        threadRef:
          type: string
          nullable: true
        from:
          type: string
          nullable: true
          description: As given, else the email’s From address.
        receivedAt:
          type: string
          nullable: true
          format: date-time
          description: As given, else the email’s Date.
        documents:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
                description: Artifact id, in `listUnderwritingSubmissionDocuments`.
              name:
                type: string
                minLength: 1
                description: The filename as the message named it.
              part:
                type: string
                minLength: 1
                description: >-
                  `raw` (the file as it arrived), `message` (an email’s body,
                  `Email.txt`), `attachment:<n>` (its n-th attachment) or
                  `document:<n>` (the n-th of `documents`).
            required:
              - id
              - name
              - part
          description: Its documents, in part order.
        rejected:
          type: array
          items:
            type: object
            properties:
              part:
                type: string
                minLength: 1
              name:
                type: string
                minLength: 1
              code:
                type: string
                minLength: 1
                description: 'Extensible: `invalid_upload_content`.'
            required:
              - part
              - name
              - code
          description: Attachments the file store refused; the rest were kept.
      required:
        - id
        - channel
        - externalId
        - threadRef
        - from
        - receivedAt
        - documents
        - rejected
    V2CodedError:
      allOf:
        - $ref: '#/components/schemas/V2Error'
        - type: object
          properties:
            code:
              type: string
              minLength: 1
              description: Stable error code. Clients must tolerate unknown future codes.
            details:
              type: array
              items:
                type: object
                properties:
                  location:
                    type: string
                    enum:
                      - path
                      - query
                      - header
                      - body
                  path:
                    type: array
                    items:
                      type: string
                      maxLength: 64
                    maxItems: 12
                  code:
                    type: string
                    enum:
                      - required
                      - invalid_type
                      - invalid_value
                      - unknown_field
                  message:
                    type: string
                    minLength: 1
                    maxLength: 200
                required:
                  - location
                  - path
                  - code
                  - message
              minItems: 1
              maxItems: 20
              description: Bounded safe validation issues; may omit some invalid fields.
            requestId:
              type: string
              minLength: 1
              maxLength: 128
              description: >-
                Existing server correlation for this HTTP attempt, when
                available.
            dataset:
              type: string
              enum:
                - naic
                - osha
              description: Dataset needed for dataset_not_enabled.
            businessCode:
              type: string
              description: The rater’s own refusal code, for business_rejection.
            violations:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                    description: Authored or built-in constraint code
                  message:
                    type: string
                    description: Authored message for the failed constraint
                  path:
                    type: string
                    description: Input path of the offending value; empty for the request
                  value:
                    nullable: true
                    description: Offending input value, size-bounded by the runtime
                  constraint:
                    type: string
                    description: The constraint the value failed, as text
                  cite:
                    type: string
                    nullable: true
                    description: >-
                      Filing citation of the constraint, when the source cites
                      one
                required:
                  - code
                  - message
                  - path
                  - value
                  - constraint
                  - cite
                additionalProperties: false
              maxItems: 256
              description: >-
                Each input constraint the submission failed, for invalid_inputs
                and business_rejection.
            violationsTruncated:
              type: boolean
              description: >-
                True when the rater reported more violations than violations
                holds.
            executionId:
              type: string
              description: >-
                The recorded execution of a failed rating, for rater rating
                failures.
            accessUrl:
              type: string
              nullable: true
              format: uri
              description: Not currently returned.
          required:
            - code
    V2Error:
      type: object
      properties:
        error:
          type: string
          minLength: 1
          description: Human-readable explanation of the failure.
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Effective API key. Send Authorization: Bearer sk-eai-...'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.