# Method Reference

This section lists **all REST API methods** provided by the ONEWEB **App Runtime**, including their purpose, request format, and expected behavior.

These APIs allow external systems to authenticate, query entity data, persist changes, and manage file uploads and downloads through the ONEWEB runtime.

All endpoints are accessed relative to the application **context root**.

***

### Login

Before calling any other API, clients must authenticate with ONEWEB.\
App Runtime APIs use **JWT‑based authentication**, and the application server validates that all incoming JWTs are issued by the authentication service.

#### Endpoint

```
POST /eaf-rest/login
```

#### Request Header

```
Content-Type: application/json
```

#### Request Body

```
{
    "username": "string",
    "password": "string",
    "ldapproviderurl": "",
    "clientId": "93370c42-0d98-40ca-9a3d-36917a758b04"
}
```

#### Response

```
{
    "timestamp": "1510363014419",
    "validity": 86400,
    "id_token": "eyJhbGciOiJIUzUxMiJ9..."
}
```

The returned `id_token` must be included in subsequent API calls.

***

### Search Entity

Searches entity data using query parameters.

#### Endpoint

```
GET /eaf-rest/entity/{entityID}/search
```

#### Request Example

```
/entity/{entityID}/search?handleForm=Y&page=1&volumePerPage=10&cbMethod=searchHandler
```

#### Request Header

```
Content-Type: application/json
Authorization: Bearer <Token>
clientId: <Client Key>
```

#### Response

```
searchHandler({
    "ALL_VOLUME": "number",
    "DATA": [{
        "COLUMN_1": "value",
        "COLUMN_2": "value",
        "KEY": {
            "ID": "keyValue"
        }
    }]
});
```

***

### Get Entity

Retrieves full entity details after selecting a record.

#### Endpoint

```
GET /eaf-rest/entity/{entityID}/get
```

#### Request Example

```
/entity/{entityID}/get?ID=<KeyID>&cbMethod=getRecordHandler
```

#### Response

```
getRecordHandler({
    "DATA": {
        "ENTITY_ID": "ENTITY",
        "MODULE_ID": [{
            "UPDATE": {
                "TABLE_NAME": {
                    "COLUMN_1": "value",
                    "COLUMN_2": "value",
                    "KEY": {
                        "ID": "keyValue"
                    }
                }
            }
        }]
    },
    "MAIN_KEYTAB": {
        "ID": "keyValue"
    }
});
```

***

### Save Entity (Insert)

Inserts new entity data into the database.

#### Endpoint

```
POST /eaf-rest/entity/{entityID}/save
```

#### Request Example

```
{
    "MODULE_ID": [{
        "INSERT": {
            "TABLE_NAME": {
                "COLUMN_1": "value",
                "COLUMN_2": "value"
            }
        }
    }]
}
```

#### Response

```
saveSuccessHandler({
    "MESSAGE": "Ok Save.",
    "STATUS": "Success.",
    "ID": "keyValue"
});
```

***

### Update Entity

Updates an existing entity record.

#### Endpoint

```
POST /eaf-rest/entity/{entityID}/save
```

#### Request Example

```
{
    "MODULE_ID": [{
        "UPDATE": {
            "TABLE_NAME": {
                "COLUMN_1": "value",
                "COLUMN_2": "value"
            }
        }
    }]
}
```

#### Response

```
saveSuccessHandler({
    "MESSAGE": "Ok Save.",
    "STATUS": "Success.",
    "ID": "keyValue"
});
```

***

### Delete Entity

Deletes an entity record using its primary key.

#### Endpoint

```
POST /eaf-rest/entity/{entityID}/get
```

#### Request Example

```
/entity/{entityID}/get?handleForm=Y&cbMethod=searchHandler&ID=<PrimaryKey>
```

No response body is returned.

***

### Upload File

Uploads a file to the server.

#### Endpoint

```
POST /eaf-rest/file/upload
```

#### Request Header

```
Content-Type: multipart/form-data
Authorization: Bearer <Token>
clientId: <Client Key>
```

***

### Download File

Downloads a previously uploaded file.

#### Endpoint

```
GET /eaf-rest/file/{fileID}/download
```

#### Request Example

```
/file/{fileID}/download?mimetype=application/octet-stream
```

#### Response

* Binary file stream
* Or Base64 encoded file

{% hint style="info" %}
**Note**:\
Supported `mimetype` values are:

* `application/octet-stream`
* `application/base64`
  {% endhint %}

***

### Summary

The App Runtime API provides a **complete REST interface** for interacting with ONEWEB application data.

Key characteristics:

* JWT‑secured access
* Session‑aware execution
* Entity‑centric CRUD operations
* Support for hierarchical data
* File upload and download capabilities

This API enables **external system integration**, **automation**, and **data interoperability** across the ONEWEB platform.


---

# 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.onewebstack.com/api-reference/app-runtime-api/method-reference.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.
