Skip to main content

GET /database/tables

Returns all tables in the current database with size and engine metadata.
curl -X GET https://example.com/wp-json/wp-manager-pro/v1/database/tables \
  -H "X-WP-Nonce: YOUR_NONCE"

Response

tables
array
total
integer
Total number of tables.
total_size
number
Combined size of all tables in megabytes.
prefix
string
The WordPress database table prefix (e.g. wp_).

GET /database/table-data

Returns rows from a specific table with pagination and column metadata.
curl -X GET "https://example.com/wp-json/wp-manager-pro/v1/database/table-data?table=wp_options&page=1&limit=50" \
  -H "X-WP-Nonce: YOUR_NONCE"

Parameters

table
string
required
Name of the table to query.
page
integer
Page number. Defaults to 1.
limit
integer
Rows per page. Defaults to 50, maximum 500.

Response

table
string
Table name.
columns
array
Ordered list of column names.
primary_key
string
Name of the primary key column.
rows
array
Array of row objects keyed by column name.
total
integer
Total number of rows in the table.
page
integer
Current page number.
pages
integer
Total number of pages.

POST /database/search-replace

Performs a search and replace across one or more database tables. Handles serialized PHP data correctly by unserializing, replacing, and re-serializing while fixing string lengths.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/database/search-replace \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"search": "http://old.example.com", "replace": "https://new.example.com", "dry_run": true}'

Parameters

The string to search for.
replace
string
required
The string to replace matches with.
tables
array
List of table names to search. Defaults to all tables that start with the WordPress prefix.
dry_run
boolean
If true, counts matches without making any changes. Defaults to false.
case_insensitive
boolean
If true, performs a case-insensitive match. Defaults to false.

Response

success
boolean
Always true.
dry_run
boolean
Whether this was a dry run.
total
integer
Total number of replacements made (or found in a dry run).
results
array
Per-table results with table and count fields.

POST /database/optimize

Runs OPTIMIZE TABLE on one or more tables to reclaim free space and defragment indexes.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/database/optimize \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"tables": ["wp_options", "wp_posts"]}'

Parameters

tables
array
List of table names to optimize. Defaults to all tables that start with the WordPress prefix.

Response

success
boolean
Always true.
results
array
Per-table results with table and optimized boolean fields.

POST /database/query

Runs a read-only SQL query and returns the results.
Only SELECT, SHOW, DESCRIBE, DESC, and EXPLAIN queries are permitted. Any other statement returns a 403 error.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/database/query \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT ID, post_title FROM wp_posts WHERE post_status = \"publish\" LIMIT 10"}'

Parameters

sql
string
required
The SQL query to execute. Must start with SELECT, SHOW, DESCRIBE, DESC, or EXPLAIN.

Response

columns
array
Ordered list of column names in the result set.
rows
array
Array of row objects.
count
integer
Number of rows returned.

POST /database/row

Inserts a new row into a table.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/database/row \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"table": "wp_options", "data": {"option_name": "my_setting", "option_value": "enabled", "autoload": "yes"}}'

Parameters

table
string
required
Name of the table to insert into.
data
object
required
Key-value pairs of column names and values to insert. Only valid column names for the table are accepted.

Response

success
boolean
Always true on success.
insert_id
integer
The auto-increment ID of the inserted row.

PUT /database/row

Updates an existing row in a table identified by its primary key.
curl -X PUT https://example.com/wp-json/wp-manager-pro/v1/database/row \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"table": "wp_options", "primary_key": "option_id", "primary_value": 42, "data": {"option_value": "disabled"}}'

Parameters

table
string
required
Name of the table containing the row.
primary_key
string
required
Name of the primary key column.
primary_value
string | integer
required
Value of the primary key that identifies the row to update.
data
object
required
Key-value pairs of columns to update. Only valid column names are accepted.

Response

success
boolean
Always true on success.
rows_affected
integer
Number of rows updated.

DELETE /database/row

Deletes a row from a table identified by its primary key.
curl -X DELETE https://example.com/wp-json/wp-manager-pro/v1/database/row \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"table": "wp_options", "primary_key": "option_id", "primary_value": 42}'

Parameters

table
string
required
Name of the table containing the row.
primary_key
string
required
Name of the primary key column.
primary_value
string | integer
required
Value of the primary key that identifies the row to delete.

Response

success
boolean
Always true on success.
rows_affected
integer
Number of rows deleted.

GET /database/export

Exports a single table as an SQL dump and streams the file directly to the client. The response is a plain-text SQL file, not a JSON response.
curl -X GET "https://example.com/wp-json/wp-manager-pro/v1/database/export?table=wp_posts" \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -o wp_posts.sql

Parameters

table
string
required
Name of the table to export.
The response is a SQL file download (Content-Type: text/plain), not a JSON object. The SQL dump includes a DROP TABLE IF EXISTS statement, the CREATE TABLE definition, and all INSERT INTO statements.

Build docs developers (and LLMs) love