---
schema_version: "1"
id: 8f9adbc5503eedb4e05de89c6e38da0d3d123efda615abb2daacc7c6f530b45f
title: Configure a Gateway API for External Storage Search
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/aps_external_storage_search_gateway.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.aps_external_storage_search_gateway.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 2f70157c31c1cd12dbe27923179fe358ca3d81566628212d089c349ab2af1a75
description: Expose Amazon Bedrock or Amazon Kendra through an AWS API that accepts Salesforce search requests and returns supported search results.
products:
  - Public Sector
release: "264"
---
# Configure a Gateway API for External Storage Search

Expose Amazon Bedrock or Amazon Kendra through an AWS API that accepts Salesforce search requests and returns supported search results.

Before you begin, set up and test an Amazon Bedrock knowledge base or Amazon Kendra index.

1. Create a Lambda function that accepts the External Storage Search request.
2. Configure the function to accept a natural-language query, Salesforce ContentDocument IDs, additional filters, a maximum result count, and a search handle, as applicable.
3. Configure the function to query the selected AWS search service and apply supported filters.
4. Transform each result into the response fields expected by Salesforce.
    
    The response must include these values, as applicable:
    
    | Field | Type | Description |
    | --- | --- | --- |
    | contentDocumentIds | String array | Normalized IDs from the contentDocumentId metadata field |
    | contentType | String or null | File type |
    | excerpt | String | Matched chunk's content.text |
    | externalDocumentInfo2 | String | Amazon S3 URI |
    | relevanceScore | Number | Relevance score returned by the search service |
    | sourceUrl | String | Amazon S3 URI |
    | title | String | File name derived from the Amazon S3 URI |
    | pageNumber | String or null | Page number from chunk metadata |
    | startTimeMs | Number or null | Relevant media start time in milliseconds |
    | endTimeMs | Number or null | Relevant media end time in milliseconds |
    
    See [Sample input and output response](https://help.salesforce.com/s/articleView?id=ind.aps_external_storage_search_gateway.htm&release=264.0.0&type=5).
5. Grant the Lambda execution role permission to query the selected search service.
6. In API Gateway, create a REST API.
7. Create a search resource, such as `/search`.
8. Create a POST method that uses the Lambda function as its integration target.
9. Enable Lambda proxy integration.
10. Set the method authorization to AWS\_IAM.
11. Deploy the API to a stage, such as `prod`.
12. Record the invoke URL.
13. Create an IAM principal with permission to invoke the gateway API.
14. Send a test request.
15. Verify the response schema, Salesforce file IDs, relevance scores, excerpts, and source locations.
16. The gateway API is ready to connect to Salesforce.

Sample Input and Output Response

```
Here is a sample input:
{
  "searchQuery": "Jason image",
  "contentDocumentIds": [
    "069xx0000004Dea",
    "069LT000001BuuL",
    "069xx0000004Deb",
    "069LT000001Bv41"
  ],
  "additionalFilters": {},
  "maxResults": 100,
  "searchHandle": null
}

Here is a sample output:
{
    "executionTimeMs": 1720,
    "hasMore": false,
    "nextSearchHandle": null,
    "results": [
        {
            "contentDocumentIds": [
                "069xx0000004Dea",
                "069xx0000004CIi"
            ],
            "contentType": "PDF",
            "excerpt": "Jason...",
            "externalDocumentInfo2": "s3://my-bucket/Stockholm-Resume-Template-Simple.pdf",
            "relevanceScore": 0.3837699,
            "sourceUrl": "s3://my-bucket/Stockholm-Resume-Template-Simple.pdf",
            "title": "Stockholm-Resume-Template-Simple.pdf",
            "pageNumber": "1",
            "startTimeMs": null,
            "endTimeMs": null
        },
                {
            "contentDocumentIds": [
                "069LT000001BuuL"
            ],
            "contentType": "MP3",
            "excerpt": "",
            "externalDocumentInfo2": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/Hyde_1783590525379.mp3",
            "relevanceScore": 0.3344161,
            "sourceUrl": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/Hyde_1783590525379.mp3",
            "title": "Hyde_1783590525379.mp3",
            "pageNumber": null,
            "startTimeMs": 730,
            "endTimeMs": 55110
        },
        {
            "contentDocumentIds": [
                "069xx0000004Deb"
            ],
            "contentType": "MP4",
            "excerpt": "",
            "externalDocumentInfo2": "s3://my-bucket/Multi-File Edit.mp4",
            "relevanceScore": 0.34692305,
            "sourceUrl": "s3://my-bucket/Multi-File Edit.mp4",
            "title": "Multi-File Edit.mp4",
            "pageNumber": null,
            "startTimeMs": 0,
            "endTimeMs": 27849
        },
        {
            "contentDocumentIds": [
                "069LT000001Bv41"
            ],
            "contentType": "PNG",
            "excerpt": "The image describes...",
            "externalDocumentInfo2": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/image_1783590602375.png",
            "relevanceScore": 0.3374139,
            "sourceUrl": "s3://my-bucket/__sfdcroot__/Case/500LT00000K5Ty5YAF/image_1783590602375.png",
            "title": "image_1783590602375.png",
            "pageNumber": null,
            "startTimeMs": null,
            "endTimeMs": null
        }
    ]
}
```

For detailed instructions for Bedrock service, see these AWS documentation references:

- [Bedrock Retrieve API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html)
- [Bedrock RetrievalFilter (filter operators)](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrievalFilter.html)
- [Create a REST API with a Lambda proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html)

For detailed instructions for Kendra service, see these AWS documentation references:

- [Searching an index - Amazon Kendra](https://docs.aws.amazon.com/kendra/latest/dg/searching.html)
- [Kendra `AttributeFilter` (filter operators)](https://docs.aws.amazon.com/kendra/latest/APIReference/API_AttributeFilter.html)
- [Filtering queries / custom attributes](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html)
- [Create a REST API with a Lambda proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html)

- **[Sample Input and Output Response](https://help.salesforce.com/s/articleView?id=ind.aps_external_storage_search_gateway_sample.htm&release=264.0.0&type=5)**  
    Review sample request and response payloads for the External Storage Search gateway API.