# Call Spark service APIs (Xcall)

## Introduction

By connecting Spark services together, users can use data from different sources and to better externalize calculations and data. The `Xcall` has 2 parts, the `Xcall` block to define the request, and a user-defined function, to receive responses. Multiple `Xcall`s can be included in a single Spark Service.

## Prerequisites

* Two Spark services are required. One is upstream, to make an API request and receive a response. The other one is downstream, to give an API response depending on the request from upstream.
* [Coherent Assistant](https://docs.coherent.global/assistant/) is required to help build the `CS.SPARK_XCALL()` user-defined function to connect the two services through a native Excel function.
* Both Spark services must be uploaded under the same tenant and accessible with the same credentials.

<figure><img src="/files/kIkyVowuCcfEiCW6cu3c" alt=""><figcaption><p>XCall: Flow of Data</p></figcaption></figure>

### Downstream Service

This is a usual Spark service that provides data to the upstream service when an `Xcall` is executed in the upstream service. This file will contain usual `Xinput`s and `Xoutput`s which will be used as parameters when called from the upstream service. This file would not contain any custom/user-defined functions.

### Upstream Service

This Spark service uses `Xcall` to call an API to get data from the downstream service by passing the necessary parameters. The Excel file for this service would contain the `Xcall` block as well as custom/user-defined functions to execute the API call.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherent.global/build-spark-services/call-spark-service-apis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
