docs/platform/connector-development/connector-builder-ui/async-streams.md
In the Connector Builder UI, you can create two types of streams: Synchronous Request and Asynchronous Job. Understanding the difference is important for efficiently extracting data from APIs that use asynchronous processing.
Synchronous streams operate in real-time, where:
This is the simpler, more common pattern used for most APIs that can return data immediately.
Asynchronous streams handle scenarios where data extraction happens over multiple steps:
This approach is necessary for APIs that handle large datasets or resource-intensive operations that cannot be completed in a single request-response cycle.
Use asynchronous streams when:
Common examples include analytics report generation, large data exports (like SendGrid contacts), complex data processing operations, and batch-processed operations.
To make an existing stream asynchronous, use the Retrieval Type selector at the top-right of the stream configuration and select Asynchronous Job.
To create a new stream as an asynchronous stream, click the + add stream button, and select Retrieval Type > Asynchronous Job.
An asynchronous stream in the Connector Builder UI is divided into four main tabs: Creation, Polling, Download, and Schema. The first three tabs correspond to the three phases of asynchronous data extraction, while the Schema tab allows you to configure the stream's data schema.
The Creation tab configures how to request that a job be created on the server.
Additional configuration options are available in the collapsed "Advanced" section for less common use cases.
In the UI, for the SendGrid contacts export, you would configure:
https://api.sendgrid.com/v3/marketing/contacts/exportsPOSTJSONThe Polling tab defines how to check the status of a running job.
{{ creation_response }} variable to reference the creation request response when constructing this URLThe Status Extractor and Status Mapping work together:
Status Extractor defines a path to extract the status value from the API response. It uses a field path to point into the JSON response to find the status value.
Status Mapping maps the extracted status values to standard connector statuses:
For each of these, you should put all of the possible status values that the API might return which indicate that the job is in that state.
The connector first uses the Status Extractor to get the raw status value, then uses the Status Mapping to determine what action to take next.
The Download Target Extractor works similarly to the Status Extractor but extracts a download URL or identifier from the successful API response during the Polling stage. This extracted value will be used in the Download stage to retrieve the data.
The Download Target Requester (Optional) makes an additional API request once jobs have completed to retrieve download URLs or identifiers. When configured, the Download Target Extractor will operate on this API response rather than the API response from the Polling stage. This is typically only needed for complex APIs.
:::note
The Download Target Extractor is optional if not using the Download Target Requester. If not specified, the connector will make a single request during the Download stage without the download_target interpolation context. This is suitable for simple APIs.
:::
In the UI, for the SendGrid contacts export, you would configure:
https://api.sendgrid.com/v3/marketing/contacts/exports/{{creation_response['id']}}GETstatusreadyfailedpendingtimeouturls30 for 30 minutes)The Download tab configures how to retrieve the results once the job is complete. This tab provides comprehensive configuration options for processing the downloaded data.
{{ download_target }} variable to reference the value extracted by the Download Target Extractor. Use the {{ creation_response }} variable to reference the creation request response when constructing this URL and use the {{ polling_response }} to reference the polling response when constructing the download URL.In the UI, for the SendGrid contacts export, you would configure:
{{ download_target }}GETCSVCONTACT_IDClick the "Test" button in the top right corner of the Connector Builder UI to test your connector.
Asynchronous streams can take longer to test than synchronous streams, so be patient. However, you can use the Cancel button to stop the test at any time.
After the test completes, you'll see several important panels that help you understand what's happening during the asynchronous process:
The main Records / Request / Response tabs in the testing panel show the final download phase of your asynchronous stream:
Records Tab: Shows the records that were created from the final download response.
Request Tab: Shows the HTTP request sent to download the final data, including the download URL, headers, and any request parameters.
Response Tab: Shows the actual data returned from the API, which is used to produce the records you're trying to sync.
For the SendGrid example, the main Request tab would show a GET request to the URL extracted from the polling response, and the Response tab would show the CSV data containing the contacts.
The Other Requests panel can be helpful for debugging asynchronous streams. This panel shows the intermediate requests and responses that occurred during the asynchronous process:
Creation Requests: Shows the request sent to create the job and the API's response, including any job ID or token returned.
Polling Requests: Shows each polling request sent to check the job status and the API's response, including the status values returned.
To view the details of the creation and polling stages:
Let's walk through the complete flow using the SendGrid contacts export example:
Job Creation:
Status Checking:
Status Evaluation:
Download URL Extraction:
Result Download:
Verify Each Stage: Use the Other Requests panel to verify that each stage is working correctly:
Configure Status Mapping Properly: Include all possible API status values in your status mapping.
Use the Right HTTP Response Format: Make sure you select the correct HTTP Response Format (JSON, CSV, XML, etc.) for both creation and download phases.
Configure Appropriate Timeouts: Set reasonable values for polling_job_timeout to avoid indefinite waiting for job completion.
Handle Rate Limits: Many APIs limit how frequently you can poll for job status. Configure appropriate error handling and retry strategies.
Test Thoroughly: Test the stream verify each phase of the asynchronous process works correctly.
Leverage Enhanced Interpolation: Take advantage of creation_response and polling_response contexts to simplify your configuration. For APIs that provide download URLs directly in creation or polling responses, you may not need a Download Target Extractor at all.
Remember that asynchronous streams often take longer to test than synchronous streams, especially if the API takes time to process jobs.