# Turso

> Manage Turso Cloud databases, groups and their configuration.

App · 20 actions. Web page: https://docs.lodol.com/docs/integrations/turso

## Actions

### Create database

Creates a new database in a group for the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Name (`name`, text, required): The name of the new database. Must contain only lowercase letters, numbers, dashes. No longer than 64 characters.
- Group (`group`, text, required): The name of the group where the database should be created. The group must already exist.
- Seed (`seed`, object): Seed.
- Size limit (`size_limit`, text): The maximum size of the database in bytes. Values with units are also accepted, e.g. 1mb, 256mb, 1gb.
- Remote encryption (`remote_encryption`, object): Encryption configuration for the database. Can be used when creating a new encrypted database, creating a encrypted database from upload (seed.type = "database_upload"), or forking from an encrypted database (required when the source database is encrypted).

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "database": {
      "DbId": "example",
      "Hostname": "example",
      "Name": "example"
    }
  }
}
```

### Create group

Creates a new group for the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Name (`name`, text, required): The name of the new group.
- Location (`location`, text, required): The location key for the new group.
- Extensions (`extensions`, text): The extensions to enable for new databases created in this group. Users looking to enable vector extensions should instead use the native libSQL vector datatype.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "group": {
      "delete_protection": false,
      "locations": [],
      "name": "example",
      "primary": "example",
      "uuid": "example",
      "version": "example"
    }
  }
}
```

### Delete database

Delete a database belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "database": "example"
  }
}
```

### Delete group

Delete a group belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Group name (`group_name`, text, required): The name of the group.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "group": {
      "delete_protection": false,
      "locations": [],
      "name": "example",
      "primary": "example",
      "uuid": "example",
      "version": "example"
    }
  }
}
```

### Get current user

Returns information about the currently authenticated user.

**Inputs**: None.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "user": {
      "avatarUrl": "example",
      "email": "example",
      "has_pending_invites": false,
      "mfa": false,
      "name": "example",
      "plan": "example",
      "username": "example"
    }
  }
}
```

### Get database

Returns a database belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "database": {
      "DbId": "example",
      "Hostname": "example",
      "Name": "example",
      "block_reads": false,
      "block_writes": false,
      "delete_protection": false,
      "group": "example",
      "parent": {
        "branched_at": "example",
        "id": "example",
        "name": "example"
      },
      "primaryRegion": "example",
      "regions": []
    }
  }
}
```

### Get database configuration

Retrieve an individual database configuration belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "allow_attach": false,
    "allowed_aws_vpc_ids": [],
    "allowed_ips": [],
    "block_reads": false,
    "block_writes": false,
    "delete_protection": false,
    "size_limit": "example"
  }
}
```

### Get database instance

Return the individual database instance by name.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.
- Instance name (`instance_name`, text, required): The name of the instance (location code).

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "instance": {
      "hostname": "example",
      "name": "example",
      "region": "example",
      "type": "example",
      "uuid": "example"
    }
  }
}
```

### Get database statistics

Fetch the top queries of a database, including the count of rows read and written.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "top_queries": []
  }
}
```

### Get database usage

Fetch activity usage for a database in a given time period.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.
- Start time (`start_time`, date and time): The datetime to retrieve usage from in ISO 8601 format. Defaults to the current calendar month if not provided. Example: 2023-01-01T00:00:00Z
- End time (`end_time`, date and time): The datetime to retrieve usage to in ISO 8601 format. Defaults to the current calendar month if not provided. Example: 2023-02-01T00:00:00Z

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "database": {
      "instances": [],
      "total": {
        "bytes_synced": 1,
        "rows_read": 1,
        "rows_written": 1,
        "storage_bytes": 1
      },
      "uuid": "example"
    }
  }
}
```

### Get group

Returns a group belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Group name (`group_name`, text, required): The name of the group.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "group": {
      "delete_protection": false,
      "locations": [],
      "name": "example",
      "primary": "example",
      "uuid": "example",
      "version": "example"
    }
  }
}
```

### Get group configuration

Retrieve an individual group configuration belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Group name (`group_name`, text, required): The name of the group.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "delete_protection": false
  }
}
```

### Get organization

Retrieve details of a specific organization.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "organization": {
      "blocked_reads": false,
      "blocked_writes": false,
      "name": "example",
      "overages": false,
      "plan_id": "example",
      "plan_timeline": "example",
      "platform": "example",
      "require_mfa": false,
      "restore_enabled": false,
      "slug": "example",
      "type": "example"
    }
  }
}
```

### List database instances

Returns a list of instances of a database. Instances are the individual primary or replica databases in each region defined by the group.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "instances": []
  }
}
```

### List databases

Returns a list of databases belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Group (`group`, text): Filter databases by group name.
- Schema (`schema`, text): The schema database name that can be used to get databases that belong to that parent schema.
- Parent (`parent`, text): Filter database branches by using their parent database ID.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "databases": []
  }
}
```

### List groups

Returns a list of groups belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "groups": []
  }
}
```

### List locations

Returns a list of locations where you can create or replicate databases.

**Inputs**: None.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "locations": {}
  }
}
```

### List organizations

Returns a list of organizations the authenticated user owns or is a member of.

**Inputs**: None.

**Outputs**

- `data` (list): Result.

**Example output**

```json
{
  "data": []
}
```

### Update database configuration

Update a database configuration belonging to the organization or user.

**Inputs**

- Organization slug (`organization_slug`, text, required): The slug of the organization or user account.
- Database name (`database_name`, text, required): The name of the database.
- Size limit (`size_limit`, text): The maximum size of the database in bytes. Values with units are also accepted, e.g. 1mb, 256mb, 1gb.
- Allow attach (`allow_attach`, true/false): Allow or disallow attaching databases to the current database.
- Block reads (`block_reads`, true/false): Block all database reads.
- Block writes (`block_writes`, true/false): Block all database writes.
- Delete protection (`delete_protection`, true/false): Prevent the database from being deleted.
- Allowed ips (`allowed_ips`, list): List of allowed IP addresses and CIDR blocks. Only connections from these sources are accepted. Pass an empty array to clear the list. Omit to leave unchanged.
- Allowed aws vpc IDS (`allowed_aws_vpc_ids`, list): List of allowed AWS VPC endpoint IDs (vpce-...). Only connections arriving through these endpoints are accepted. Pass an empty array to clear the list. Omit to leave unchanged.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "allow_attach": false,
    "allowed_aws_vpc_ids": [],
    "allowed_ips": [],
    "block_reads": false,
    "block_writes": false,
    "delete_protection": false,
    "size_limit": "example"
  }
}
```

### Validate platform token

Validates an API token belonging to a user.

**Inputs**: None.

**Outputs**

- `data` (object): Result.

**Example output**

```json
{
  "data": {
    "exp": 1
  }
}
```
