> For the complete documentation index, see [llms.txt](https://docs.coherent.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherent.global/spark-apis/transforms-api.md).

# Transforms API

{% hint style="warning" %}
This feature is only enabled on certain environments and tenants. Please contact [Support](/support/support.md) for more information about this feature.
{% endhint %}

The transforms API allows Spark services to be used as a "drop-in" replacement to legacy calculation systems and services. This works by supporting requests and responses structures that do not conform to the payload structure of the standard .

<figure><img src="/files/X68S47zbtmtRPYryQB7o" alt=""><figcaption></figcaption></figure>

Transforms are not inherently tied to a particular Spark service and can have a many-to-many relationship. This enables:

* Reuse of one transform against multiple services.
* One service can have different transforms applied to it, e.g. a service is consumed by multiple calling systems.

To support this functionality we have developed different [Transform types](/spark-apis/transforms-api/transform-types.md) that may be appropriate for different use cases.

## Build transforms

To build transforms you can follow the instructions under [Transform types](/spark-apis/transforms-api/transform-types.md) to build the code for transforms. For JavaScript developers there is also the [Node Transform Document Builder](https://github.com/floherent/node-transform-builder) that can be used to assist with the development.

## Transform APIs

Please see the additional specifics for the [Transform types](/spark-apis/transforms-api/transform-types.md) you are using.

{% code overflow="wrap" %}

```shellscript
# Transform document is stored in a folder
POST /{tenant}/api/v4/transforms/{transform_folder}/{transform}/for/{folder}/{service}
# Transform document does not apply to a Spark service
POST /{tenant}/api/v4/transforms/{transform_folder}/{transform}/run
# Transform document is stored in apps/transforms
POST /{tenant}/api/v4/transforms/{transform}/for/folders/{folder}/services/{service}
```

{% endcode %}

### Authorization

* `Bearer {token}` accessible from [Authorization - Bearer token](/spark-apis/authorization-bearer-token.md) or systematically via [Client Credentials](/identity-and-access-management/client-credentials.md).
  * The request headers should include a key for `Authorization` with the value `Bearer {token}`.
* API key created from [Authorization - API keys](/spark-apis/authorization-api-keys.md).
  * The request headers should include the keys `x-synthetic-key` and `x-tenant-name` with the values of the API key and tenant name respectively.

Note that the authorization must include permissions that can access:

* The requested Spark service.
* The requested transform.
  * Either the folder that the transform is stored OR
  * If the transform is in the `apps/transforms` folder. This would typically require `user:pf` or `supervisor:pf`.

### **Path parameters**

<table><thead><tr><th width="374">Key</th><th>Value</th></tr></thead><tbody><tr><td><code>tenant</code> *</td><td>Tenant is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL and also available in the <a data-mention href="/pages/ylWjjoVBLOcB7JZks4Cp#user-menu">/pages/ylWjjoVBLOcB7JZks4Cp#user-menu</a>.</td></tr><tr><td><code>transform_folder</code> *</td><td>Folder associated with the transform document of the request.</td></tr><tr><td><code>transform</code> *</td><td>Transform document associated with the transform document of the request (without <code>_transform.json</code>).</td></tr><tr><td><code>folder</code> *</td><td>Folder associated with the Spark service of the request.</td></tr><tr><td><code>service</code> *</td><td>Service associated with the Spark service of the request.</td></tr></tbody></table>

### Request headers

<table data-full-width="false"><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody><tr><td><code>x-transforms-path</code></td><td>Folder name if the transform document is stored in a folder and the URI pattern does not include <code>transform_folder</code>.</td></tr></tbody></table>

### Request body

* Content will differ depending on the [Transform types](/spark-apis/transforms-api/transform-types.md).

### Response body

* Content will differ depending on the [Transform types](/spark-apis/transforms-api/transform-types.md).
* If the transform encounters an error, the error from the transform application will be returned.
