---
sourceDocument: Yokohama API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/yokohama/api-reference

 Release :

    - yokohama

ft:locale :

    - en-US

ft:publication_title :

    - Yokohama API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Retrieve attachments and attachment metadata

# Retrieve attachments and attachment metadata {#ariaid-title1}

Release version: Yokohama  
Updated January 30, 2025  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Retrieve attachments and attachment metadata

TheNowAttachmentService APIallows ServiceNow customers to manage attachments within their ServiceNow instance.
It supports creating, reading, updating, and deleting (CRUD) attachments, as well as retrieving associated metadata.
This API is essential for integrating attachment handling directly into custom applications or workflows, providing a programmatic way to upload, download, delete, validate, and query attachment metadata tied to specific records.
Show full answer Show less  

## Key Features

* **Attachment Upload:** Upload attachments and associate them with specific ServiceNow records.
* **Attachment Download:** Download one or multiple attachments efficiently.
* **Attachment Deletion:** Remove attachments as needed.
* **Attachment Validation:** Validate attachments by comparing computed and expected hashes to ensure data integrity.
* **Metadata Retrieval:** Retrieve metadata generated by ServiceNow when attachments are uploaded.
* **Multiple Result Handling Methods:** API methods support three ways to return results: completion handlers, async/await calls, and (deprecated) Combine publishers, giving flexibility for integration with different Swift concurrency models.
* **Pagination for Metadata:** When retrieving metadata for multiple attachments, use the `attachmentMetadataPaginator` method to handle large data sets via a Paginator object. This supports infinite scroll or paged data views in UI components like UITableView, UICollectionView, or SwiftUI List.
* **Paginator API:** The Paginator object provides methods like `first()`, `last()`, `next()`, `previous()`, and `reset()` to navigate pages of metadata. Some methods may throw exceptions when no more pages exist. It also exposes properties to gain insights into pagination state.

## Practical Use for ServiceNow Customers

To leverage this API, customers must import the `NowData` framework and initialize a `NowAttachmentService` object pointing to their ServiceNow instance URL. This setup enables seamless integration of attachment operations into mobile or custom apps.

Using the paginator for metadata retrieval is particularly useful for interfaces displaying large numbers of attachments, ensuring smooth user experiences with incremental data loading and efficient memory usage.

Overall, the NowAttachmentService API empowers customers to automate and enhance attachment management within their ServiceNow environments, improving data handling and user interactions related to attachments.  
The NowAttachmentService API enables you to perform CRUD operations
on attachments and retrieve attachment metadata from your ServiceNow
instance.
Using this API you can:

* Upload attachments to your ServiceNow instance and associated them to a specific record.
* Download one or more attachments.
* Delete attachments.
* Validate an attachment by comparing the computed hash of the attachment to the expected hash.
* Download attachment metadata. This metadata is generated by your ServiceNow instance when an attachment is uploaded.
{#mobsdk-ios-retrieve_attach_metadata__ul_l5y_qjw_3qb}

For additional information on working with attachments, see [Attachment API](https://servicenow-prod.fluidtopics.net/II9UMLEzxwdzNICHcVHP2w#c_AttachmentAPI "The Attachment API provides endpoints that allow you to upload and query file attachments.").

All [NowAttachmentService](https://servicenow-prod.fluidtopics.net/Aba9jG~lvjvxz5H_~FVptg#NowAttachmentServiceiOSAPI "The NowAttachmentService class provides functions that enable you to upload and query attachments that are associated with records within a table on a ServiceNow instance.") methods provide three implementations for returning results data. One that calls a completion handler with the return results, one that preforms an
async/await, and another that returns a [Combine](https://developer.apple.com/documentation/combine) publisher (deprecated). For example, each upload() method uploads and associates a specified attachment to a specified record. However, the [NowAttachmentService - upload(data: Data, configuration: NowAttachmentUploadConfiguration, progressUpdate: @escaping ProgressUpdate, completion: @escaping (Result<NowAttachmentMetadata, NowDataError>))](https://servicenow-prod.fluidtopics.net/Aba9jG~lvjvxz5H_~FVptg#NAttServiOS-upload_O_O_O_O "Uploads the attachment data and attaches it to a record in a table as specified in the upload configuration.") method calls a completion handler with the return results, the [NowAttachmentService - upload(data: Data, configuration: NowAttachmentUploadConfiguration, progressUpdate: @escaping ProgressUpdate) async throws](https://servicenow-prod.fluidtopics.net/Aba9jG~lvjvxz5H_~FVptg#NAttServiOS-upload-async_O_O_O_O "Uploads the attachment data and attaches it to a record in a table as specified in the upload configuration.") method performs an async/await, and the [NowAttachmentService - upload(data: Data, configuration: NowAttachmentUploadConfiguration, progressUpdate: @escaping ProgressUpdate)](https://servicenow-prod.fluidtopics.net/Aba9jG~lvjvxz5H_~FVptg#NAttServiOS-upload_O_O_O "Uploads the attachment data and attaches it to a record in a table as specified in the upload configuration.") method returns a Combine publisher.  
Before you are able to use the NowAttachmentService API, you must import NowData and then initialize a NowAttachmentService object.

    // Import the NowData framework
    import NowData

    func makeAttachmentService(instanceUrl: URL, 
      completion: @escaping ((Result<NowAttachmentService, NowServiceErrors>) → Void))

## Attachment metadata pagination {#mobsdk-ios-retrieve_attach_metadata__section_stt_34w_3qb}

You can use the NowAttachmentService methods to download attachment
metadata for one or more attachments. When downloading metadata from multiple attachments,
you may want to use the [NowAttachmentService - attachmentMetadataPaginator(filter: Filter, limit: Int)](https://servicenow-prod.fluidtopics.net/Aba9jG~lvjvxz5H_~FVptg#NAttServiOS-attachMetadataPag_S_I "Retrieves the metadata for all the attachments that meet the specified criteria and returns a Paginator object for iterating through the pages of the returned metadata.") method, which returns a [Paginator](https://servicenow-prod.fluidtopics.net/edzp3NEnv0aHm2e6f5NrNQ#PaginatorIOSAPI "The Paginator class provides methods for iterating through a record set returned by a call to the ServiceNow Table API through the NowTableService. It is the object that is returned by the NowTableService paginator() methods. Do not call this method outside of that environment.") object that enables you to easily iterate over the potentially large
amount of data that is returned. You typically use paginated return results to provide
infinite scroll capabilities for data presented inside a UITableView, a UICollectionView
(UIKit), or a List (SwiftUI), or to simplify page iteration of results in general.  
After obtaining a Paginator object, subscribe to its publisher to start receiving data.

    paginator.publisher
      .subscribe(on: DispatchQueue.global())
      .receive(on: DispatchQueue.main)
      .sink { ... }
      .store(in: &subscriptions)

The returned Paginator object provides the following methods that enable you to page through the returned records:

* first()
* last()
* next()
* previous()
* reset()

{#mobsdk-ios-retrieve_attach_metadata__ul_pyb_2w3_3qb}  
Note:  
Some Paginator methods may throw an exception, such as when there are no more pages to fetch.

In addition, the Paginator object provides properties
that enable you to obtain insights into the paginated data. For additional details on these
properties and the available methods, see [Paginator API - iOS](https://servicenow-prod.fluidtopics.net/edzp3NEnv0aHm2e6f5NrNQ#PaginatorIOSAPI "The Paginator class provides methods for iterating through a record set returned by a call to the ServiceNow Table API through the NowTableService. It is the object that is returned by the NowTableService paginator() methods. Do not call this method outside of that environment.").

