> For the complete documentation index, see [llms.txt](https://genfarmer-support.gitbook.io/genfarmer-eng/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://genfarmer-support.gitbook.io/genfarmer-eng/main-menu-bar/api.md).

# API

## GenFarmer API Documentation

Welcome to the GenFarmer API documentation. This guide helps you understand how to interact with the GenFarmer automation system via RESTful APIs.

***

### 🧠 Overview

GenFarmer provides endpoints to manage **Automation Apps**, **Tasks**, and **Runs** that can be assigned to devices for automation scenarios.

***

### 📦 Base URL

```
http://127.0.0.1:55554/
```

***

### 📁 Automation APIs

#### 🔍 List Apps

* **Method:** `GET`
* **Endpoint:** `/automation/apps`

**cURL Example:**

```bash
curl -X GET 'http://127.0.0.1:55554/automation/apps?userId=3&page=1&limit=25&order=desc&orderBy=updatedAt'
```

🔍 Get App Details

* **Method:** `GET`
* **Endpoint:** `/automation/apps/:id`

**cURL Example:**

```bash
curl -X GET 'http://127.0.0.1:55554/automation/apps/adoFNVNN6Jwl8FlbZCfni'
```

#### 🔧 Update App

* **Method:** `PUT`
* **Endpoint:** `/automation/apps`

**cURL Example:**

```bash
curl -X PUT 'http://127.0.0.1:55554/automation/apps' \
  -H 'Content-Type: application/json' \
  -d '{"id":"adoFNVNN6Jwl8FlbZCfni","userId":3,"name":"New App","description":"","version":"1.0.0","script":{"flow":{"nodes":[],"edges":[]}}}'
```

#### ❌ Delete App

* **Method:** `DELETE`
* **Endpoint:** `/automation/apps`

**cURL Example:**

```bash
curl -X DELETE 'http://127.0.0.1:55554/automation/apps' \
  -H 'Content-Type: application/json' \
  -d '{"ids": ["2ykTiCbEOAYC_5_tR5Wp-"]}'
```

***

### 🧾 Task APIs

#### ➕ Create Task

* **Method:** `POST`
* **Endpoint:** `/automation/tasks`

**cURL Example:**

```bash
curl -X POST 'http://127.0.0.1:55554/automation/tasks' \
  -H 'Content-Type: application/json' \
  -d '{"appId":"adoFNVNN6Jwl8FlbZCfni","input":[],"userId":3,"name":"test","devices":{"enable":true,"list":[]}}'
```

#### 📄 List Tasks

* **Method:** `GET`
* **Endpoint:** `/automation/runs`

**cURL Example:**

```bash
curl -X GET 'http://127.0.0.1:55554/automation/runs?userId=3&page=1&limit=25&order=desc&orderBy=createdAt'
```

#### 🛠 Update Task

* **Method:** `PUT`
* **Endpoint:** `/automation/tasks/:id`

**cURL Example:**

```bash
curl -X PUT 'http://127.0.0.1:55554/automation/tasks/uNDVKT_VwhEDuXT3PGUUv' \
  -H 'Content-Type: application/json' \
  -d '{"id":"uNDVKT_VwhEDuXT3PGUUv","userId":3,"appId":"adoFNVNN6Jwl8FlbZCfni","taskSource":0,"name":"test","input":[],"enableInput":true,"devices":{"enable":true,"list":[{"id":"emulator-5554","serialNo":"00f65a5d","name":"SM-G960N"}]}}'
```

#### 🔗 Assign Devices to Task

* **Method:** `PUT`
* **Endpoint:** `/automation/tasks/:id/add-devices`

**cURL Example:**

```bash
curl -X PUT 'http://127.0.0.1:55554/automation/tasks/uNDVKT_VwhEDuXT3PGUUv/add-devices' \
  -H 'Content-Type: application/json' \
  -d '{"devices":{"enabled":true,"list":[{"id":"emulator-5554","serialNo":"00f65a5d","name":"SM-G960N"}]}}'
```

#### 🔗 Remove Devices from Task

* **Method:** `PUT`
* **Endpoint:** `/automation/tasks/:id/remove-devices`

#### 🗑 Delete Task

* **Method:** `DELETE`
* **Endpoint:** `/automation/tasks`

**cURL Example:**

```bash
curl -X DELETE 'http://127.0.0.1:55554/automation/tasks' \
  -H 'Content-Type: application/json' \
  -d '{"ids": ["uNDVKT_VwhEDuXT3PGUUv"]}'
```

***

### 🚀 Run APIs

#### ▶️ Create Run

* **Method:** `POST`
* **Endpoint:** `/automation/runs`

**cURL Example:**

```bash
curl -X POST 'http://127.0.0.1:55554/automation/runs' \
  -H 'Content-Type: application/json' \
  -d '{"userId":3,"taskId":"uNDVKT_VwhEDuXT3PGUUv","appId":"adoFNVNN6Jwl8FlbZCfni","status":0}'
```

#### ▶️ Execute Run

* **Method:** `PUT`
* **Endpoint:** `/automation/runs/:id/run`

**cURL Example:**

```bash
curl -X PUT 'http://127.0.0.1:55554/automation/runs/xhfjAeUOB5SXC8d5RiK_c/run' \
  -H 'Content-Type: application/json' \
  -d '{"deviceIds":[]}'
```

#### 📊 Get Run Output

* **Method:** `GET`
* **Endpoint:** `/automation/runs/:id/storages`

**cURL Example:**

```bash
curl -X GET 'http://127.0.0.1:55554/automation/runs/xhfjAeUOB5SXC8d5RiK_c/storages?page=1&limit=25'
```

***

### 👤 Me API

#### 🙋‍♂️ Get Current User

* **Method:** `GET`
* **Endpoint:** `/backend/auth/me`

**cURL Example:**

```bash
curl -X GET 'http://127.0.0.1:55554/backend/auth/me'
```

***

### 📘 Notes

* Replace all `:id` placeholders with the actual `id` of your app, task, or run.
* The `script.flow` field in Update App allows defining an automation logic visually using nodes and edges.

***

### 📥 Download Postman Collection

{% file src="/files/ExHhxZGi5KkVTvuK0afT" %}

### 📞 Support

For further help, please contact the GenFarmer support team.
