# Deploying Custom API Endpoints

### Overview

Neurelo instantly creates an API end point for every custom query once it is committed in a branch. This custom query API end point can be deployed to one or many environments inside a project. Here is how to use it:

### Deploying your custom query endpoints with commit:

* Create a custom query using AI Assist or manually.
* Click on "Commit" to save this custom query
* At the time of the commit, Neurelo offers a choice to deploy this custom query to one or more running environment if there are no schema related migrations needed in the environment.
  * Select environment(s) that you would like to deploy this custom query as part of the commit step. You can always also go into the Environments
  * Your environment should be ready to go. Make sure you have the appropriate environment API Key so you can use it to hit the Custom Query Endpoint
  * You can access this custom query API endpoint at the URL for your Environment&#x20;
    * For REST, this endpoint can be accessed at `${API_URL_BASE}/custom/<endpointName>` (e.g. custom/authorsNumBooks) using the configured HTTP method (`GET`/`POST`/`PATCH`/`DELETE`) for the endpoint
    * For GraphQL, this endpoint can be accessed with a `POST` at `${API_URL_BASE}/graphql` using `custom_<endpointName>` (e.g. custom\_authorsNumBooks) as the field name in a Query or Mutation operation.

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

{% hint style="info" %}
If the "Deploy" option is not offered as part of the commit step (because migrations are needed in the environment) or you want to skip the "Deploy" step here, you can deploy this Commit later from Environment settings option.
{% endhint %}

### Deploying your custom query endpoints from Environment settings:

* To deploy custom queries in a specific environment, access the specific environment from the left navigation panel under a project
* You must Stop Runner sfrom the top right side of the page. And once the runners have been stopped, you can select the appropriate Commit of the Definition to be used for the environment from the Commit drop down right next to the Start/Stop Runner button
* Once the appropriate definition has been selected, click on Start Runner. Runners should start in a few seconds and the new definition would be deployed and be live in that specific environment.

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

{% hint style="info" %}
You can test your custom query using any HTTP Client (Postman, Insomnia, or even Curl) and write a request with the following format:

* `REST: GET/POST/PATCH/DELETE ${API_URL_BASE}/custom/<your_custom_query_name>`
* `GraphQL: Query or Mutation with custom_<endpointName> as the field name at POST ${API_URL_BASE}/graphQL`&#x20;

Headers needed:

`X-API-KEY`: `Your_Environment_API_KEY`
{% endhint %}

{% hint style="danger" %}
Custom Query Endpoints currently are only supported with API Keys that have both Read and Write permissions. Custom Query endpoints will not work with Read-Only keys and will return a "403 - Forbidden" error.&#x20;
{% endhint %}


---

# 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.neurelo.com/definitions/custom-apis-for-complex-queries/deploying-custom-api-endpoints.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.
