Using the WordPress REST API, you can easily add or update mapped domains in Domain Mapping System.
Domain Mapping System takes advantage of the WordPress REST API to allow adding and deleting of domain mappings.
When Domain Mapping System is installed, by default, the REST API URL is available on your site at this kind of URL:
https://your-domain.com/api/dms/v1
Be sure to replace your-domain with your primary domain name configured on your WordPress site. This can be founder under the Settings > General tab in the WP-Admin Menu.
The API requires a Token Request for valid authentication. Then, you can add/update mappings as desired.
1. Token Request
Authentication to the REST API is facilitated via JSON Web Token (JWT).
First, you must request a token by logging in using the below endpoint and valid WordPress admin credentials.
When requesting the token by logging in, the new JWT will be generated for you and passed in response to the request.
The token will later be required to authorize all calls to the API using the Bearer Token authentication method.
The token is tied to the admin user account. If the admin user account is ever deleted, the token will no longer work.
{"code": "unable_to_get_token","message": "Unable to get token. Please contact the site administrator owner and review our documentation","data": {"status": 400 }}
{"code": "technical_error","message": "Technical error. Please contact support and review our documentation","data": {"status": 400 }}
2. Add/Update Mapping
This request does not support bulk changes. You can add/update only one object per request. If the website is using the free version of the plugin, then you will not be able to add multiple values per mapping or set up a primary value. This means you cannot set up Microsites (or a Microsite homepage), which are paid features.
{"code": "duplicate_entries_detected_with_the_same_root_domain_and_subdirectory","message": "Duplicate entries detected with the same root domain and subdirectory","data": {"status": 400 }}
{"code": "duplicate_entries_detected_with_the_same_root_domain_and_subdirectory","message": "Duplicate entries detected with the same root domain and subdirectory","data": {"status": 400 }}