REST API endpoints and authentication for elementor-cli.
Uses WordPress Application Passwords (available since WordPress 5.6).
Authorization: Basic base64(username:application_password)
curl -X GET "https://example.com/wp-json/wp/v2/pages" \
-H "Authorization: Basic $(echo -n 'admin:xxxx xxxx xxxx xxxx' | base64)"| Action | Method | Endpoint |
|---|---|---|
| List pages | GET | /wp-json/wp/v2/pages |
| Get page | GET | /wp-json/wp/v2/pages/<id> |
| Create page | POST | /wp-json/wp/v2/pages |
| Update page | PUT | /wp-json/wp/v2/pages/<id> |
| Delete page | DELETE | /wp-json/wp/v2/pages/<id> |
| Get revisions | GET | /wp-json/wp/v2/pages/<id>/revisions |
List pages:
GET /wp-json/wp/v2/pages?_fields=id,title,status,modified&per_page=100
Get page for editing:
GET /wp-json/wp/v2/pages/<id>?context=edit
When fetching a page with context=edit, Elementor data is in the meta object:
{
"id": 42,
"title": { "rendered": "Home" },
"status": "publish",
"meta": {
"_elementor_data": "[{\"id\":\"abc123\",...}]",
"_elementor_page_settings": "{...}",
"_elementor_edit_mode": "builder"
}
}| Meta Field | Type | Description |
|---|---|---|
_elementor_data |
JSON string | Element tree (array of elements) |
_elementor_page_settings |
object | Page-level settings (must be sent as object, not JSON string) |
_elementor_edit_mode |
string | Set to "builder" for Elementor pages |
PUT /wp-json/wp/v2/pages/42
Content-Type: application/json
{
"title": "Updated Title",
"meta": {
"_elementor_data": "[{\"id\":\"abc123\",\"elType\":\"container\",...}]",
"_elementor_page_settings": {"background_color": "#ffffff"}
}
}_elementor_datamust be a JSON string (double-encoded)_elementor_page_settingsmust be an object (not a JSON string) -- sending it as a JSON string will cause WordPress to reject or misinterpret the data- Always include
_elementor_edit_mode: "builder"for Elementor pages - Use
context=editwhen fetching to get raw meta values
POST /wp-json/wp/v2/pages
Content-Type: application/json
{
"title": "New Page",
"status": "draft",
"meta": {
"_elementor_edit_mode": "builder",
"_elementor_data": "[]",
"_elementor_page_settings": "{}"
}
}GET /wp-json/wp/v2/pages/42/revisionsResponse:
[
{
"id": 156,
"parent": 42,
"date": "2024-01-20T14:30:00",
"author": 1,
"meta": {
"_elementor_data": "[...]"
}
}
]To restore a revision, copy its _elementor_data to the parent page:
PUT /wp-json/wp/v2/pages/42
Content-Type: application/json
{
"meta": {
"_elementor_data": "<data from revision>"
}
}| Status | Code | Description |
|---|---|---|
| 401 | rest_cannot_read |
Invalid or missing credentials |
| 403 | rest_forbidden |
User lacks permission |
| 404 | rest_post_invalid_id |
Page not found |
| 400 | rest_invalid_param |
Invalid request data |
{
"code": "rest_cannot_read",
"message": "Sorry, you are not allowed to read this post.",
"data": { "status": 401 }
}WordPress doesn't have built-in rate limiting, but:
- Some hosts impose limits
- Use reasonable delays between requests
- Batch operations where possible
# Test connection
curl -s "https://example.com/wp-json/wp/v2/users/me" \
-H "Authorization: Basic $(echo -n 'admin:xxxx xxxx' | base64)" \
| jq .name
# List Elementor pages
curl -s "https://example.com/wp-json/wp/v2/pages?meta_key=_elementor_edit_mode" \
-H "Authorization: Basic $(echo -n 'admin:xxxx xxxx' | base64)" \
| jq '.[].title.rendered'