Attachment API overview
The Attachment API lets you manage files attached to records in ServiceNow. You can use it to list metadata for multiple attachments, retrieve metadata for a specific attachment, or delete an attachment.
Additionally, it provides specialized endpoints for handling the raw file content (binary data) through the File operations sub-module.
Commonly used for:
- Retrieving a list of attachments associated with a specific record or table.
- Downloading file content for processing.
- Uploading documents, images, or logs to existing ServiceNow records.
- Cleaning up old or redundant attachments.
Basic usage
To interact with attachments, you use the Attachment method from the now namespace.
// Access the attachment API
attachmentAPI := client.Now().Attachment()
// Fetch metadata for all attachments (optionally filtered)
result, err := attachmentAPI.Get(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
Available operations
- List Attachments: Retrieve metadata for multiple attachments.
- Get Attachment Metadata: Retrieve metadata for a specific attachment using its
sys_id. - Delete Attachment: Permanently remove an attachment from the system.
- File Operations: Dedicated endpoints for uploading and downloading the actual file content.
- Upload Attachment: Upload a new file and associate it with a record using
multipart/form-data.