'mxchat-api-access', 'rotated' => 1), admin_url('admin.php'))); exit; } /** * Revoke the existing token (sets the option to empty string). */ add_action('admin_post_mxchat_revoke_api_token', 'mxchat_handle_revoke_api_token'); function mxchat_handle_revoke_api_token() { if (!current_user_can('manage_options')) { wp_die(esc_html__('You do not have permission to do this.', 'mxchat')); } check_admin_referer('mxchat_revoke_api_token'); update_option(MXCHAT_API_TOKEN_OPTION, '', false); delete_option('mxchat_api_token_rotated_at'); wp_safe_redirect(add_query_arg(array('page' => 'mxchat-api-access', 'revoked' => 1), admin_url('admin.php'))); exit; } /** * Render the API Access admin page. */ function mxchat_render_api_admin_page() { if (!current_user_can('manage_options')) { wp_die(esc_html__('You do not have permission to access this page.', 'mxchat')); } $stored_token = (string) get_option(MXCHAT_API_TOKEN_OPTION, ''); $token_set = $stored_token !== ''; $just_rotated = get_transient('mxchat_api_token_just_rotated'); delete_transient('mxchat_api_token_just_rotated'); $rotated_query = isset($_GET['rotated']) ? (bool) $_GET['rotated'] : false; $revoked_query = isset($_GET['revoked']) ? (bool) $_GET['revoked'] : false; $rotated_at = (int) get_option('mxchat_api_token_rotated_at', 0); $base_url = trailingslashit(get_rest_url(null, 'mxchat/v1')); $health_url = $base_url . 'health'; $transcripts_u = $base_url . 'transcripts'; $knowledge_url = $base_url . 'knowledge'; $plugin_url = plugin_dir_url(dirname(__FILE__)); $masked = $token_set ? substr($stored_token, 0, 4) . str_repeat('•', 24) . substr($stored_token, -4) : ''; $rotated_human = $rotated_at > 0 ? sprintf( /* translators: %s: human-readable elapsed time */ esc_html__('%s ago', 'mxchat'), human_time_diff($rotated_at, current_time('timestamp')) ) : esc_html__('Never', 'mxchat'); ?>

GET
GET
POST
DELETE

curl 

curl -H "Authorization: Bearer YOUR_TOKEN" \
  "?role=user&has_rag_context=no&since=2026-05-01&limit=50"

curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Q: How do I enable streaming?\nA: ...","source_url":"https://example.com/faq#streaming","content_type":"faq"}' \
  ""

curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"session_ids":["sess_abc","sess_def"],"cascade":true}' \
  ""