# REST Commands

![](https://t.gyazo.com/teams/chicksgold/c890f671bc6eb73d316045cfb9af2560.png)

### Configuration

Specify the API Url to set what REST endpoint will be called when executing the command. As of this moment you can choose from POST / PUT / PATCH / DELETE / GET

#### URL Configuration

The URL used also accepts dynamic URL that are driven by the parameter name using the same syntax as the Message Template Engine. Anything wrapped in ${} will be replaced with the matching value for the given parameter name.&#x20;

In the event you are using a parameter for a dynamic URL the response, the parameter that matches parameter mapping will go unused. Anything can be put into this.

In the example below I am target the public Star Wars API to allow fetching of any available endpoints and their matching ID parameters. <https://swapi.py4e.com/>

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

#### Header Configuration

The header configurable allows you to set custom headers that may be required for the REST endpoint to work as expected

Add a new header by clicking the "Add Header" button. You can then enter the name and value for that header

{% hint style="warning" %}
Any set headers will overwrite default headers.
{% endhint %}

#### Command Parameters

Create up to 25 parameters of different types. This determines how they are formatted when building the JSON to send to the specified URL

<table><thead><tr><th width="214.76053818313892">Configuration Option</th><th>Explanation</th></tr></thead><tbody><tr><td>Name</td><td>This is the name of the parameter in the discord command. This is not used in the data mapping</td></tr><tr><td>Description</td><td>This is the description of the parameter for the discord command. This is not used in the data mapping</td></tr><tr><td>Type</td><td>View below for information on types</td></tr><tr><td>Mapping</td><td>The dot notation form to map the parameter values to the generation JSON data. Refer to <a data-mention href="#understanding-the-dot-notation-property-mapping">#understanding-the-dot-notation-property-mapping</a></td></tr></tbody></table>

**There are various types that have different JSON mapping behavior.**&#x20;

* String
  * A plain text parameter that allows any plain text characters. There is little to no validation around this parameter
* Number
  * Parameter must be a numeric value. Allows decimals. Validation is handled by Discord. Will be sent as a number in the JSON object
* Integer
  * Parameter must be a whole number. Decimals are not allowed. Validation is handled by Discord. Will be sent as a number in the JSON object
* Boolean
  * Parameter must be true or false. Options are pre-populated by Discord in the parameter for quickly being able to select. Validation is handled by Discord. Will be sent as a boolean in the JSON object.

#### Default Data

Default data can be used to add any additional information that is not captured in a parameter. This allows you to have static information that may be required for every request to that endpoint.

<table><thead><tr><th width="214.76053818313892">Configuration Option</th><th>Explanation</th></tr></thead><tbody><tr><td>Name</td><td>This is just used for you to better know what these are used for. These are for you only.</td></tr><tr><td>Type</td><td>View below for information on types</td></tr><tr><td>Mapping</td><td>The dot notation form to map the parameter values to the generation JSON data. Refer to <a data-mention href="#understanding-the-dot-notation-property-mapping">#understanding-the-dot-notation-property-mapping</a></td></tr><tr><td>Value</td><td>The value to be inserted into the data.</td></tr></tbody></table>

### Understanding the Dot Notation Property Mapping

For this example I am going to assume you have read the above and understand how to make properties and then show you an example and how it would behave for the data mapping.

Let's take the following parameters as an example

<table><thead><tr><th width="150">Name</th><th width="150">Value</th><th width="150">Type</th><th>Mapping</th></tr></thead><tbody><tr><td>param1</td><td>something</td><td>string</td><td>someObject.param1</td></tr><tr><td>param2</td><td>1.50</td><td>number</td><td>param2</td></tr><tr><td>param3</td><td>true</td><td>boolean</td><td>someObject.boolean</td></tr><tr><td>param4</td><td>5</td><td>integer</td><td>someObject.anotherObject.param4</td></tr></tbody></table>

Using the above parameters you will have a generation JSON that looks like the following:

```json
{
    "someObject": {
        "param1": "something",
        "boolean": true,
        "anotherObject": {
            "param4": 5
        }
    },
    "param2": 1.50
}
```

{% hint style="info" %}
Note that the name of the parameter does not matter. See how param3's mapping has someObject.boolean and the name "param3" is not present anywhere.
{% 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.betsybot.xyz/configurable-commands/data-commands/rest-commands.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.
