# Usage

### API design

SpreadAPI has to deal with limitations imposed by the Google Apps Script engine. There are two limitations that make running a *state-of-art* REST API impossible in this environment:

1. Each script can respond only on one hardcoded URL. It can't handle request comming at subpaths like */users* or */transactions/15*.
2. Only *GET* and *POST* methods are supported.

Due to the these limitations the SpreadAPI script handles only *POST* requests on a single URL. The actual HTTP method and resource path are provided in request body as shown in the example below:

```javascript
{
    "method": "GET",
    "sheet": "users"
}
```

Other parameters (like payload for *POST* and *PUT*  requests) are provided as additional fields in the request body:

```javascript
{
    "method": "PUT",
    "sheet": "users",
    "id": "2",
    "payload": {
        "firstname": "John",
        "lastname": "Smith"
    }
}

```

For more information on this topic visit [API Reference](/usage/usage.md) documentation page.

{% hint style="info" %}
For each request Google App Scripts first returns status 302 (redirect). To get result of your request you need to make a follow-up GET request (without any payload) to the  URL shared in the Location response headers. Some libraries do this automatically, but that's not always the case.
{% 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://spreadapi.roombelt.com/usage.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.
