# Schemas

## Schemas

> note: If you are using a Devii API, these docs do not pertain to you. Devii produces a unique schema for each user dependent on the access-token so we just use that at runtime

Api Schemas are foundationally how the Natural Language API knows how to interact with your api and when. The intention is for you add uploading your schema to the NLAPI as apart of your deployment pipeline. If you have mulitple schemas for your application, give each schema a unique name and the NLAPI will have access to all schemas. If you upload a schema with the same name of one we have, we will replace it with the latest version.

To update your schema send us a file to this post route: `/portal/schemas`. If you haven't created an application yet, please see [Portal.md Docs](https://the-nlapi.gitbook.io/the-nlapi-docs/portal).

This is a `multipart/form-data` endpoint that accepts binary type `file` key value.\
Example Request:

````bash
curl --location --globoff 'https://api.nlapi.io/portal/schemas' \
--header 'Authorization: Bearer [your-access-token]' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"~/Desktop/schema.json"' \ # Replace with your file 
--form 'application_id="your_application_id"' \
--form 'name="your_schema_name"'

Example Response: 
```json
{
    "message" : "Your schema has been Uploaded Successfully", 
    "status_code" : 201
}
````

*NOTE: Depending on the file size, this could take up to a couple of minutes to process and be 'live' through the NLAPI, The NLAPI will continue to use the previous schema until the new one is processed to prevent any downtime*

### Hiding Routes:

For OpenAPI schemas add the tag 'no-nlapi' to your route and we will not process it. Common routes that our developer community hides are `/login` `/signup` or anything where the user would have to provide sensitive information like access tokens.

### Next Steps:

You are all set up. Now go to the main [Documentation](https://the-nlapi.gitbook.io/the-nlapi-docs/documentation) to get started using the NLAPI!

### Schema Support List:

* [OpenAPI](https://www.openapis.org/)
* [Devii](https://devii.io)

#### Auto-Generation Schema Resources:

**Applications:**

* [Devii](https://devii.io)

**Python:**

* [Fast API](https://the-nlapi.gitbook.io/the-nlapi-docs/schemas)

**Ruby:**

* [rswag](https://the-nlapi.gitbook.io/the-nlapi-docs/schemas)

## FAQ's

**Q: Can I have more than one schema per application?**

A: Yes! By passing in the `name` field in the body of your request when uploading a schema, we will make sure that schema overrides the schema with the same name in that application. So if you have two schemas with different names, the NLAPI will have access to both of the latest versions of those at run time. *Note -> Currently both schemas have to have the same base url.*

**Q: How are schemas used in enterprise applications?**

A: For enterprise applications, schemas can be used to train a private model to increase accuracy for your specific application and user requests.

**Q: Can I hide routes I don't want the NLAPI to use?**

A: (OpenApi Users) Yes! If you are using an OpenAPI spec, use the tag no-nlapi in your definition and we will drop that endpoint when processing so the LLM doesn't see it exists. Note -> LLMs are still relatively unpredictable so if your user asks for a specific endpoint or a task that the endpoint would be relatively predictable, it's plausible that the LLM will still attempt to make an api call to an endpoint it doesn't know about. -> If you need extra constraints please reach out and we can ensure the LLM doesn't call any other endpoints than what you have given access to. -> The tradeoff is a little speed.

A: (Devii Users) If you are using Devii, the graphql your logged in user has access to from your policy will be the only actions the LLM sees to take action on the user's behalf. Currently there is not a way to seperate what the LLM can do on the user's behalf vs the user directly in the API.

**Q: Can I use the NLAPI if I'm not using an Open API schema or Devii?**

A: Potentially, to see how we can support you, please email <jase@jasekraft.com>


---

# 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://the-nlapi.gitbook.io/the-nlapi-docs/schemas.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.
