OneMeta registers a complete REST API under the onemeta/v1 namespace. All endpoints require WordPress authentication with the manage_options capability.
Base URL: https://yoursite.com/wp-json/onemeta/v1
Authentication
All endpoints require authentication. Use the X-WP-Nonce header with a valid WordPress nonce:
javascript
const response = await fetch( '/wp-json/onemeta/v1/field-groups', {
headers: {
'X-WP-Nonce': wpApiSettings.nonce
}
} );
Or use HTTP Basic Auth / Application Passwords for external requests.
Endpoints
GET /field-groups
Retrieve all field groups.
Request:
GET /wp-json/onemeta/v1/field-groups
Response:
json
[
{
"id": "hero_fields",
"title": "Hero Fields",
"config": {
"title": "Hero Fields",
"type": "post",
"post_type": "post",
"fields": { ... }
},
"status": "active",
"created_at": "2025-12-25 10:00:00",
"updated_at": "2025-12-25 10:00:00"
}
]
GET /field-groups/{id}
Retrieve a single field group by its key.
Request:
GET /wp-json/onemeta/v1/field-groups/hero_fields
Response:
json
{
"id": "hero_fields",
"title": "Hero Fields",
"config": { ... },
"status": "active",
"created_at": "2025-12-25 10:00:00",
"updated_at": "2025-12-25 10:00:00"
}
Error (404):
json
{ "error": "Field group not found" }
POST /field-groups
Create a new field group.
Request:
POST /wp-json/onemeta/v1/field-groups
Content-Type: application/json
Body:
json
{
"group_key": "hero_fields",
"title": "Hero Fields",
"config": {
"title": "Hero Fields",
"type": "post",
"post_type": "post",
"position": "normal",
"fields": {
"hero_title": {
"type": "text",
"label": "Hero Title"
}
}
}
}
Response (201):
json
{
"success": true,
"message": "Field group created successfully",
"id": "hero_fields"
}
PUT /field-groups/{id}
Update an existing field group.
Request:
PUT /wp-json/onemeta/v1/field-groups/hero_fields
Content-Type: application/json
Body:
json
{
"title": "Updated Hero Fields",
"config": { ... }
}
Response (200):
json
{
"success": true,
"message": "Field group updated successfully"
}
DELETE /field-groups/{id}
Delete a field group permanently.
Request:
DELETE /wp-json/onemeta/v1/field-groups/hero_fields
Response (200):
json
{
"success": true,
"message": "Field group deleted successfully"
}
POST /field-groups/{id}/toggle
Toggle a field group between active and inactive status.
Request:
POST /wp-json/onemeta/v1/field-groups/hero_fields/toggle
Response (200):
json
{
"success": true,
"status": "inactive",
"message": "Field group status updated"
}
GET /field-schemas
Retrieve field type schemas (available settings per field type). Requires manage_options.
Request:
GET /wp-json/onemeta/v1/field-schemas
Error Responses
| HTTP Status | Meaning |
|---|---|
400 | Bad request — missing or invalid parameters |
401 | Unauthorized — not authenticated |
403 | Forbidden — authenticated but insufficient permissions |
404 | Not found — field group key does not exist |
500 | Server error — database operation failed |
JavaScript Example
javascript
// Fetch all field groups
const response = await fetch( '/wp-json/onemeta/v1/field-groups', {
headers: { 'X-WP-Nonce': wpApiSettings.nonce }
} );
const groups = await response.json();
// Toggle a field group status
await fetch( '/wp-json/onemeta/v1/field-groups/hero_fields/toggle', {
method: 'POST',
headers: { 'X-WP-Nonce': wpApiSettings.nonce }
} );