# External Database

### Get Started

Select a workplace you want to use, then install the External Data from [extension page](https://fruitask.com/extensions/)

### Your Database

We support only **MySQL** for now. We will keep working in other database structure, however you can still use with other database like NoSQL database since Fruitask is formatted with JSON structure.

### Prepare your webhook

You need to provide GET webhook URL with your database credentials and other endpoints. Your webhook API should return this format

```json
{
    "type": "remote", //default
    "dbname": "demo",
    "username": "user_demo",
    "port": 3306,
    "password": "admin1234",
    "location": "198.154.451", //Hosting IP address
    "timestamp": "2025-11-16 19:51:40",
    "disk_storage": "https://example.com/api/upload/",
    "gallery_url": "https://example.com/api/gallery/",
    "base_url": "https://example.com"
}
```

For **security compliance**, you can apply CORS Policy, only Fruitask can access the webhook API or add query params to your webhook URL with workplace token or your Fruitask API.

```php
<?php
// Set the header to return JSON
header('Content-Type: application/json');

//Allow CORS policy for fruitask.com only
//Implement $_GET['token'] for extra authorization

// Example logic or data
$data = [
    'type' => 'remote',
    'dbname' => 'demo',
    'username' => 'user_demo',
    'port' => 3306, //make sure the port exist INBOUND
    'password' => 'admin1234', //this is user password permission
    'location' => '198.154.451', //ip or host domain
    'timestamp' => date('Y-m-d H:i:s'),
    'disk_storage' => 'https://example.com/api/upload/',
    'gallery_url' => 'https://example.com/api/gallery/',
    'base_url' => 'https://example.com'
];

// Return as JSON
echo json_encode($data, JSON_PRETTY_PRINT);

```

You also need to prepare an API endpoint for your files uploading. Since your data from Fruitask will be now saving to your remote database, all your files will do the same.  It's allows you to control about allowed file types, sizes and feel secured since your keeping it in your disk storage.

<table><thead><tr><th>Key</th><th>Description</th><th data-type="files">Template PHP</th></tr></thead><tbody><tr><td><code>disk_storage</code></td><td>Value should be a POST API endpoint for uploading files to your disk storage.</td><td><a href="/files/nTjxXED361P5pDfWfbx0">/files/nTjxXED361P5pDfWfbx0</a></td></tr><tr><td><code>gallery_url</code></td><td>Value should be a GET API endpoint for returning your files from disk storage.</td><td><a href="/files/iw4Irf4JJRBoJt7EIuId">/files/iw4Irf4JJRBoJt7EIuId</a></td></tr></tbody></table>

### Setup Extension (External Data)

Once extension is installed to a workplace and your webhook data is ready, you can start testing it.

1. Open a workplace (Where External Data extension installed)
2. Go to Controls > Setting
3. From **Source Database,** paste your webhook API - It will create a database and copy all data from Fruitask database to your own database.

{% hint style="info" %}
SSL Verification: Make sure you enable HTTPS to you APIs as Fruitask may reject connection.
{% endhint %}

And it's ready. You can try writing data to your workplace and it's now saving to your own database, also try to upload an attachment or file and it should be save to your own disk storage. Now you can do it to your other workplace and experienced BRING YOUR OWN DATABASE here in Fruitask.


---

# 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://avocado-5.gitbook.io/fruitask-api/reference/external-database.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.
