Skip to content

Report delivered messages as spam

POST
/mail/mailboxes/{mailbox}/messages/spam
curl --request POST \
--url https://mail.work.optidata.cloud/api/mail/mailboxes/78/messages/spam \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "message_ids": [ "4186" ] }'

Move messages that reached the inbox into Junk and, when spam training is enabled for the tenant, report them to the filtering service so future messages like them are caught earlier.

The response separates what was asked from what actually happened: junk_moved counts the messages moved, trained the ones the filter accepted as training samples, and train_attempted says whether training was tried at all. Training is best-effort — the move succeeds even when it does not.

mailbox
required
integer

Id of the mailbox. Every mailbox the caller may use is listed in their account.

Media typeapplication/json
object
message_ids
required

Ids of the messages to act on.

Array<string>
>= 1 items
Examples
Examplereport
{
"message_ids": [
"4186"
]
}

The outcome of the report.

Media typeapplication/json
object
requested

How many messages were submitted.

integer
junk_moved

How many were moved to Junk.

integer
trained

How many were accepted as training samples.

integer
train_attempted

Whether training was attempted.

boolean
Examples
Examplereported
{
"requested": 2,
"junk_moved": 2,
"trained": 2,
"train_attempted": true
}

Missing, malformed or expired authentication key.

Media typeapplication/json

Authentication failures use an error key rather than message.

object
error
required
string
Examples
Examplemissing

No bearer token sent

{
"error": "JWT passport exception: Missing bearer token in request"
}

The spam features are not enabled for this tenant.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Exampledisabled
{
"message": "Not available"
}

The request body or query string failed validation.

Media typeapplication/json
object
message
required

The first validation message.

string
errors
required

Validation messages keyed by field name.

object
key
additional properties
Array<string>
Examples
Exampleinvalid
{
"message": "The conversations field is required.",
"errors": {
"conversation_ids": [
"The conversations field is required."
]
}
}

Rate limit exceeded. Retry after the window resets.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Examplethrottled
{
"message": "Too Many Attempts."
}

The mail platform did not answer as expected — a folder or message that does not exist, or a transient failure. reference is the code to quote to support and fault_code names the underlying condition. A 503 with the same envelope means the platform is in maintenance; retry shortly.

Media typeapplication/json

Failure raised by the mail platform behind the API rather than by the request itself.

object
error
required

What went wrong, phrased for the end user.

string
status
required

Repeats the HTTP status code.

integer
help
required

Suggested next step.

string
reference
required

Support reference, e.g. MZ-502.

string
fault_code

Names the underlying condition, e.g. mail.NO_SUCH_FOLDER.

string | null
Examples

Unknown folder

{
"error": "The mail server did not answer as expected, so this action could not be completed.",
"status": 502,
"help": "If the problem persists, contact support and inform the error code above.",
"reference": "MZ-502",
"fault_code": "mail.NO_SUCH_FOLDER"
}