Endpoints
Login
Post to the endpoint to log in as a registered WordPress User.
Arguments
logstring | The username or email address. Max length: 100 |
pwdstring | The password. Max length: 4096 |
redirect_tostring | The URL to redirect to upon successful login. |
remembermestring | Whether to “remember” the user login. Increases the time that the cookie will be kept. The WordPress default is 2 days. If the login is “remembered,” the default is increased to 14 days. One of: 0, 1 |
_cnoncestring | The site action token is used to validate the request origin and action. |
Example Request
fetch("https://example.com/wp-json/cn-api/v1/account/login", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
log: "username",
pwd: "password",
_cnonce: "123456789A",
}),
})
.then((response) => response.json())
.then((data) => console.log(data));Example Response
{
"id": "55",
"reload": true
}Request Reset Password
Post a username or user email address to the endpoint to request a new user password.
Arguments
logstring | The username or email address. Max length: 100 |
redirectstring | The URL to redirect to upon successful request reset password. |
_cnoncestring | The site action token is used to validate the request origin and action. |
Example Request
fetch("https://example.com/wp-json/cn-api/v1/account/request-reset-password", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
log: "username",
_cnonce: "123456789A",
}),
})
.then((response) => response.json())
.then((data) => console.log(data));Example Response
{
"id": "89",
"reset": true
}Reset Password
Post a user reset password to the endpoint to set a new password.
Important
Posting to this endpoint requires the reset password key from the reset password confirmation email. A cookie is also required for the request to be successful. The cookie’s name is wp-resetpass-{COOKIEHASH} and the value is {user_login}:{key}.
Arguments
pass1string | The new password. Max length: 4096 |
pass2string | Confirm password. Must match pass1.Max length: 4096 |
keystring | Password reset key from the user request reset password confirmation email. |
redirectstring | The URL to redirect to upon successful reset password. |
_cnoncestring | The site action token is used to validate the request origin and action. |
Example Request
fetch("https://example.com/wp-json/cn-api/v1/account/reset-password", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
log: "username",
pass1: "DmFjdCo9JcLrhrE!yKBTq3tp",
pass2: "DmFjdCo9JcLrhrE!yKBTq3tp",
key: "s2BVzGFNxnGn7snuffgv",
_cnonce: "123456789A",
}),
})
.then((response) => response.json())
.then((data) => console.log(data));Example Response
{
"id": "47",
"reset": true
}Register
Post to register a new user.
Arguments
user_loginstring | The username. Max length: 60 |
user_emailstring | The user email. Max length: 100 |
redirectstring | The URL to redirect to upon successful uer registration. |
_cnoncestring | The site action token is used to validate the request origin and action. |
Example Request
fetch("https://example.com/wp-json/cn-api/v1/account/register", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
user_login: "testuser",
user_email: "test@email.com",
_cnonce: "123456789A",
}),
})
.then((response) => response.json())
.then((data) => console.log(data));Example Response
{
"id": "47",
"redirect": "https://example.com/registration/success"
}