Delete an attachment

Delete an uploaded file given its attachment ID.

Note that uploaded files that have been referenced in at least one message are automatically deleted once the last message containing a link to them is deleted (whether directly or via a message retention policy).

Uploaded files that are never used in a message are automatically deleted a few weeks after being uploaded.

Attachment IDs can be contained from GET /attachments.

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Delete the attachment with given attachment_id.

url = "attachments/" + str(attachment_id)
result = client.call_endpoint(
    url=url,
    method="DELETE",
)
print(result)

curl -sSX DELETE https://chat.outreachy.org/api/v1/attachments/1 \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY

Parameters

attachment_id string required in path

Example: "1"

The ID of the attachment to be deleted.


Response

Example response

A typical successful JSON response may look like:

{
    "msg": "",
    "result": "success"
}

A typical failed JSON response for when the attachment_id is invalid

{
    "code": "BAD_REQUEST",
    "msg": "Invalid attachment",
    "result": "error"
}

A typical failed JSON response for when the user is not logged in

{
    "msg": "Not logged in: API authentication or user session required",
    "result": "error"
}