|
| 1 | +# API Endpoints: Databases |
| 2 | + |
| 3 | +[More info about Databases](/databases.html). |
| 4 | + |
| 5 | +## Run Query |
| 6 | + |
| 7 | +#### Request |
| 8 | + |
| 9 | +**POST** <code>https://webhook.site/database/<span class="url-param">databaseId</span>/query</code> |
| 10 | + |
| 11 | +* `query`: The SQL query to execute. |
| 12 | + |
| 13 | +```json |
| 14 | +{ |
| 15 | + "query": "select * from mytable;" |
| 16 | +} |
| 17 | +``` |
| 18 | + |
| 19 | +#### Response |
| 20 | + |
| 21 | +* `result`: (array) The returned data. |
| 22 | +* `error`: (string) If the query results in an error, the error is represented here. |
| 23 | +* `time`: (float) Query execution time in milliseconds. |
| 24 | + |
| 25 | +```json |
| 26 | +{ |
| 27 | + "result": [ |
| 28 | + { |
| 29 | + "id": 1, |
| 30 | + "value": "hello world" |
| 31 | + }, |
| 32 | + { |
| 33 | + "id": 2, |
| 34 | + "value": "it's a great day to be a query" |
| 35 | + } |
| 36 | + ], |
| 37 | + "error": null, |
| 38 | + "time": 0 |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +Or, for an error: |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "result": null, |
| 47 | + "error": "Undefined table: 7 ERROR: relation \"nonexisting_table\" does not exist", |
| 48 | + "time": 0 |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +## Create database |
| 53 | + |
| 54 | +* Requires [authentication](/api/about.html#api-key) |
| 55 | +* Will return `401 Unauthorized` when no databases purchased in subscription |
| 56 | + |
| 57 | +#### Request |
| 58 | + |
| 59 | +**POST** `https://webhook.site/databases` |
| 60 | + |
| 61 | +* `name` (required) The name of the database. |
| 62 | +* `group_id` Enter a group ID to attach database to a group. |
| 63 | +* `plan` (required) Either `db-s`, `db-m`, `db-l`. |
| 64 | + |
| 65 | +```json |
| 66 | +{ |
| 67 | + "name": "My Database", |
| 68 | + "group_id": null, |
| 69 | + "plan": "db-s" |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +#### Response |
| 74 | + |
| 75 | +```json |
| 76 | +{ |
| 77 | + "id": "23984", |
| 78 | + "name": "My Database", |
| 79 | + "plan": "db-s", |
| 80 | + "group_id": null, |
| 81 | + "max_bytes": 104857600, |
| 82 | + "max_tables": 1, |
| 83 | + "team_id": 181, |
| 84 | + "updated_at": "2025-09-24T08:52:50.000000Z", |
| 85 | + "created_at": "2025-09-24T08:52:50.000000Z" |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +## Get all databases |
| 90 | + |
| 91 | +**GET** `https://webhook.site/database?page=1&per_page=15` |
| 92 | + |
| 93 | +#### Response |
| 94 | + |
| 95 | +```json |
| 96 | +{ |
| 97 | + "current_page": 1, |
| 98 | + "data": [ |
| 99 | + { |
| 100 | + "id": "23984", |
| 101 | + "name": "My Database", |
| 102 | + "plan": "db-s", |
| 103 | + "team_id": 345987, |
| 104 | + "group_id": null, |
| 105 | + "max_bytes": 104857600, |
| 106 | + "max_tables": 1, |
| 107 | + "bytes_used": 0, |
| 108 | + "tables_used": 1, |
| 109 | + "created_at": "2025-09-23T10:26:51.000000Z", |
| 110 | + "updated_at": "2025-09-23T10:26:55.000000Z", |
| 111 | + "group": null |
| 112 | + } |
| 113 | + ], |
| 114 | + "first_page_url": "https:\/\/webhook.test\/databases?page=1", |
| 115 | + "from": 1, |
| 116 | + "last_page": 1, |
| 117 | + "last_page_url": "https:\/\/webhook.test\/databases?page=1", |
| 118 | + "links": [ |
| 119 | + { |
| 120 | + "url": null, |
| 121 | + "label": "« Previous", |
| 122 | + "active": false |
| 123 | + }, |
| 124 | + { |
| 125 | + "url": "https:\/\/webhook.test\/databases?page=1", |
| 126 | + "label": "1", |
| 127 | + "active": true |
| 128 | + }, |
| 129 | + { |
| 130 | + "url": null, |
| 131 | + "label": "Next »", |
| 132 | + "active": false |
| 133 | + } |
| 134 | + ], |
| 135 | + "next_page_url": null, |
| 136 | + "path": "https:\/\/webhook.test\/databases", |
| 137 | + "per_page": 15, |
| 138 | + "prev_page_url": null, |
| 139 | + "to": 1, |
| 140 | + "total": 1 |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +## Update database |
| 145 | + |
| 146 | +#### Request |
| 147 | + |
| 148 | +**PUT** `https://webhook.site/databases` |
| 149 | + |
| 150 | +* `name` (required) The name of the database. |
| 151 | +* `group_id` Enter a group ID to attach database to a group. |
| 152 | + |
| 153 | +```json |
| 154 | +{ |
| 155 | + "name": "My Updated Database", |
| 156 | + "group_id": null |
| 157 | +} |
| 158 | +``` |
| 159 | + |
| 160 | +#### Response |
| 161 | + |
| 162 | +```json |
| 163 | +{ |
| 164 | + "id": "100014", |
| 165 | + "name": "My Updated Database", |
| 166 | + "plan": "db-s", |
| 167 | + "team_id": 181, |
| 168 | + "group_id": null, |
| 169 | + "max_bytes": 104857600, |
| 170 | + "max_tables": 1, |
| 171 | + "bytes_used": 0, |
| 172 | + "tables_used": 0, |
| 173 | + "created_at": "2025-09-24T08:52:50.000000Z", |
| 174 | + "updated_at": "2025-09-24T08:56:29.000000Z" |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +## Delete database |
| 179 | + |
| 180 | +#### Request |
| 181 | + |
| 182 | +**DELETE** <code>https://webhook.site/database/<span class="url-param">databaseId</span></code> |
| 183 | + |
| 184 | +#### Response |
| 185 | + |
| 186 | +`204 No content` |
| 187 | + |
0 commit comments