Create, find, list or edit site-wide Outlinks links over REST
These are the routes behind Settings → Site-wide Links and Guest Manager’s guest editor. They are install-wide, with no show in the path: every method needs manage_options (send an X-WP-Nonce for wp_rest from a browser) and Outlinks switched on for at least one show, else 403 benecaster_outlinks_not_active. While Outlinks is off for every show the routes do not exist at all (404 rest_no_route).
POST /benecaster-outlinks/v1/site-linkswith{ url, slug? }answers with the link, asbenecaster_outlinks_site_link()returns it:201withcreated: truewhen it was made,200withcreated: falsewhen a site-wide link to that URL already existed. Errors match the function:400 benecaster_outlinks_url_invalid(data.fieldisurl),400 benecaster_outlinks_slug_invalidand409 benecaster_outlinks_slug_taken(with a free name indata.suggestion).GETanswers{ go_base, items }, oldest first, site-wide links only. Each item hasid,slug,go_url,destination_url,affiliate_url,expiry_date,expiry_fallback_url,geo_rules(each{ country_code, destination_url, affiliate_url }),clicks,bot_clicks,last_clicked_at,last_clicked,statusandhttp_status.clickscounts people only andbot_clicksthe filtered ones.last_clicked_atis the last person’s click in ISO 8601 UTC (2026-11-02T10:30:00Z) andlast_clickedthe same moment in the site’s date and time formats; both are null when no person has clicked.status(healthy,broken,expired,uncheckedorexcluded) andhttp_statusare Link Health’s.PATCH …/site-links/{id}with any ofdestination_url,affiliate_url,expiry_date,expiry_fallback_urlandgeo_rulesanswers200with the item. The rules match a show’s tracked link: only the keys you send change,''ornullclears an optional one,geo_rulesreplaces the whole set, URLs must behttporhttps, and a bad field is400withdata.fieldnaming the first one.destination_urlcan be changed here because a site-wide link has no library item to follow; it cannot be cleared. An id that is not a site-wide link (unknown, or a show’s tracked link) is404 benecaster_outlinks_redirect_not_found.
Code
<?php
$request = new WP_REST_Request( 'POST', '/benecaster-outlinks/v1/site-links' );
$request->set_body_params( [ 'url' => 'https://example.com/books/the-lean-startup', 'slug' => 'lean-startup-book' ] );
$response = rest_do_request( $request ); // As a user with manage_options.
$go_url = $response->is_error() ? null : $response->get_data()['go_url'];
Need this built rather than just documented? See our services →