AIOSEO generates SEO metadata from post content — the REST API won’t let you override it
As part of an automated content pipeline I was building, one of the requirements was to publish articles to WordPress via the REST API. Each article needed a custom SEO title and meta description. My initial approach was to pass these as `aioseo_title` and `aioseo_description` fields in the POST request body when creating a new post.
WordPress accepted the new post, but it silently ignored the AIOSEO fields I provided. When I checked the published article, the SEO title and description were still auto-generated by AIOSEO from the post’s title and content, not reflecting my custom values. This was a clear sign that my assumption about how to set these values via the API was incorrect.
Investigation into AIOSEO’s REST API behavior
To understand why my custom fields were being ignored, I decided to inspect the WordPress REST API response for an existing post. I used `context=edit` on a post with ID 12795. The `context=edit` parameter is useful because it typically exposes all available fields, including those usually hidden, giving a comprehensive view of what’s present and potentially writable.
The response did contain AIOSEO data, but its structure was quite surprising:
* The `meta` object, which typically holds custom post meta fields, only exposed `_uag_custom_page_level_css` and `footnotes`. Crucially, there were **no writable AIOSEO meta fields** within this object.
* AIOSEO’s core data, such as `aioseo_meta_data`, `aioseo_head`, `aioseo_head_json`, and `aioseo_breadcrumb`, appeared as **read-only top-level fields** in the response. This immediately suggested they weren’t direct database fields I could modify.
This structure indicated that these top-level AIOSEO fields are computed by the plugin at response time, rather than being stored directly as custom post meta that could be updated via the standard `meta` endpoint.
To further confirm if there was any dedicated AIOSEO endpoint for managing post-level SEO data, I tried accessing a specific AIOSEO REST endpoint mentioned in some documentation I had seen:
GET /wp-json/aioseo/v3/posts/12795
This request, however, returned a 404 error: “No route was found matching the URL and request method.” This confirmed that AIOSEO version 5.0.4, which I was using, does not expose a writable REST API endpoint for post-level SEO data.
The cause: AIOSEO’s auto-generation and read-only API exposure
The investigation revealed the core issue: AIOSEO 5.0.4 is designed to auto-generate SEO metadata (title, meta description, Open Graph, schema) primarily from the post’s title, content, and excerpt. The WordPress REST API, in turn, exposes this generated output as read-only computed fields. It does not provide a writable endpoint for overriding these specific per-post SEO values directly.
The only safe interaction I had previously established with AIOSEO via the REST API was passing `aioseo_notices: []` to suppress any plugin-generated notices, which my existing pipeline already handled. This confirmed that *some* AIOSEO-related fields could be passed, but not the critical SEO metadata. My mistake was assuming that because AIOSEO displayed UI fields for custom SEO titles and descriptions in the WordPress admin, these would automatically be exposed as writable fields in the REST API.
The implementation: Working with AIOSEO, not against it
Understanding that AIOSEO prefers to generate SEO data from the post’s core content, I shifted my pipeline’s strategy. Instead of trying to force specific AIOSEO fields via the API, I focused on providing high-quality input to WordPress itself, allowing AIOSEO to do its job effectively.
I changed the pipeline to ensure that every post generated and published through the API had:
1. **A good, unique title:** AIOSEO uses the post title as the primary source for the SEO title.
2. **A meaningful excerpt:** AIOSEO uses the post excerpt as the primary source for the meta description.
3. **Quality content with proper H2/H3 structure:** AIOSEO leverages the content and its structure for generating Open Graph metadata and schema data.
My pipeline now explicitly generates the post title and a concise, meaningful excerpt using Gemini AI before the article is published to WordPress. With these elements in place, AIOSEO correctly picks them up and generates the desired SEO metadata.
Verification
After implementing these changes and publishing a test post with a custom title and excerpt generated by the AI, I again inspected the `aioseo_meta_data` object in the REST API response for the newly created post. I confirmed that:
* The `title` field within `aioseo_meta_data` matched the generated SEO title.
* The `description` field matched the generated meta description.
* Related fields like `og_title`, `og_description`, `twitter_title`, and `twitter_description` were all correctly populated.
* The schema data was present and appeared valid.
This verification confirmed that AIOSEO works correctly when provided with good input in the standard WordPress fields. My initial mistake was trying to bypass its auto-generation mechanism rather than feeding it the information it expects.
What I would check first next time
This experience was a valuable lesson in API integration. When integrating with a WordPress SEO plugin or any complex plugin via the REST API, I will now always prioritize checking the actual API response structure before making assumptions about field names or writability.
The plugin’s settings page in the WordPress admin may show UI fields for configuration, but the REST API can expose a completely different schema or simply not expose certain fields for direct modification. Testing with `context=edit` on a real, existing post is the most reliable way to understand what data is actually available and, more importantly, what is truly writable via the API. This simple diagnostic step would have saved me significant time and effort.




