Skip to content

Delete mailboxes

POST/mailboxes/delete

Email Management API · Mailbox Management

Delete multiple mailboxes.

Parameters

Name In Type Required Description
X-Tenant-ID header string (uuid) Yes Tenant ID.

Request body

Content type: application/json

Request body fields

itemsarray of objectrequired
List of mailbox IDs.
Must contain at most 20 items.
Mailbox ID.
Show child attributesHide child attributes
idstring (uuid)required
Mailbox ID.

Request samples

curl -X POST "https://api-<data-region>.central.sophos.com/email/v1/mailboxes/delete" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
  \"items\": [
    {
      \"id\": \"00000000-0000-0000-0000-000000000000\"
    }
  ]
}"

import requests

response = requests.post(
    "https://api-<data-region>.central.sophos.com/email/v1/mailboxes/delete",
    headers={
        "Authorization": "Bearer <access-token>",
        "X-Tenant-ID": "<tenant-id>",
        "Content-Type": "application/json",
    },
    json={'items': [{'id': '00000000-0000-0000-0000-000000000000'}]},
)
print(response.json())

$headers = @{
    "Authorization" = "Bearer <access-token>"
    "X-Tenant-ID" = "<tenant-id>"
    "Content-Type" = "application/json"
}
$body = '{
  "items": [
    {
      "id": "00000000-0000-0000-0000-000000000000"
    }
  ]
}'
Invoke-RestMethod -Method POST -Uri "https://api-<data-region>.central.sophos.com/email/v1/mailboxes/delete" -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/mailboxes/delete", strings.NewReader(`{
  "items": [
    {
      "id": "00000000-0000-0000-0000-000000000000"
    }
  ]
}`))
    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/mailboxes/delete", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "items": [
    {
      "id": "00000000-0000-0000-0000-000000000000"
    }
  ]
}),
});
const data = await response.json();
console.log(data);

Responses

200 — All or few mailboxes successfully deleted.

Response fields

itemsarray of object
List of mailbox IDs for successfully deleted mailboxes.
Mailbox ID.
Show child attributesHide child attributes
idstring (uuid)required
Mailbox ID.
errorsarray of object
List of mailbox IDs for which mailbox deletion failed.
Error message.
Show child attributesHide child attributes
idstring (uuid)required
Mailbox ID for which mailbox deletion was failed.
errorstringrequired
Reason of mailbox deletion failure.

Errors

Status Meaning
400 Bad request.
500 Unexpected error.

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

Response examples

200

{
  "items": [
    {
      "id": "00000000-0000-0000-0000-000000000000"
    }
  ],
  "errors": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "error": "string"
    }
  ]
}

See the guide for a narrative walkthrough of this API.