Skip to content

Strip attachments

POST/quarantine/messages/{id}/attachments/strip

Email Management API · Quarantine

Strips one or more attachments from message.

Parameters

Name In Type Required Description
X-Tenant-ID header string (uuid) Yes Tenant ID.
id path string (uuid) Yes ID from 'X-Sophos-Email-ID' MIME header.

Request body

Content type: application/json

Request body fields

attachmentsarray of string
List of attachments to strip or reattach. If you specify attachment names, only those attachments are stripped or reattached.
forRecipientsarray of string
Target email addresses.

Request samples

curl -X POST "https://api-<data-region>.central.sophos.com/email/v1/quarantine/messages/<id>/attachments/strip" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
  \"attachments\": [
    \"employee.xslx\"
  ],
  \"forRecipients\": [
    \"user_bob@sophos.com\"
  ]
}"

import requests

response = requests.post(
    "https://api-<data-region>.central.sophos.com/email/v1/quarantine/messages/<id>/attachments/strip",
    headers={
        "Authorization": "Bearer <access-token>",
        "X-Tenant-ID": "<tenant-id>",
        "Content-Type": "application/json",
    },
    json={'attachments': ['employee.xslx'], 'forRecipients': ['user_bob@sophos.com']},
)
print(response.json())

$headers = @{
    "Authorization" = "Bearer <access-token>"
    "X-Tenant-ID" = "<tenant-id>"
    "Content-Type" = "application/json"
}
$body = '{
  "attachments": [
    "employee.xslx"
  ],
  "forRecipients": [
    "user_bob@sophos.com"
  ]
}'
Invoke-RestMethod -Method POST -Uri "https://api-<data-region>.central.sophos.com/email/v1/quarantine/messages/<id>/attachments/strip" -Headers $headers -Body $body -ContentType "application/json"

package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    req, err := http.NewRequest("POST", "https://api-<data-region>.central.sophos.com/email/v1/quarantine/messages/<id>/attachments/strip", strings.NewReader(`{
  "attachments": [
    "employee.xslx"
  ],
  "forRecipients": [
    "user_bob@sophos.com"
  ]
}`))
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer <access-token>")
    req.Header.Set("X-Tenant-ID", "<tenant-id>")
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}

const response = await fetch("https://api-<data-region>.central.sophos.com/email/v1/quarantine/messages/<id>/attachments/strip", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "attachments": [
    "employee.xslx"
  ],
  "forRecipients": [
    "user_bob@sophos.com"
  ]
}),
});
const data = await response.json();
console.log(data);

Responses

200 — Attachments stripped from a quarantined message.

Response fields

itemsarray of object
List of items for which the action was successful.
Show child attributesHide child attributes
attachmentstringrequired
Attachment name.
recipientstringrequired
Target email address.
errorsarray of object
List of items for which requested action failed.
Show child attributesHide child attributes
attachmentstringrequired
Attachment name.
recipientstringrequired
Email address associated with failed action.
errorstring
Reason for error.

Errors

Status Meaning
400 Bad request.
404 Not found.
500 Unexpected error.

All error responses share the same shape — see the error response object.

Response examples

200

{
  "items": [
    {
      "attachment": "employees.xslx",
      "recipient": "user_bob@sophos.com"
    }
  ],
  "errors": [
    {
      "attachment": "employees.xslx",
      "recipient": "user_bob@sophos.com",
      "error": "Already released"
    }
  ]
}

See the guide for a narrative walkthrough of this API.