Title: API Support for Adding SEO Metadata and Yoast Blocks Programmatically
Last modified: January 14, 2025

---

# API Support for Adding SEO Metadata and Yoast Blocks Programmatically

 *  Resolved [peppe69](https://wordpress.org/support/users/peppe69/)
 * (@peppe69)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/api-support-for-adding-seo-metadata-and-yoast-blocks-programmatically/)
 * Hello Yoast Support Team,
 * We are working on programmatically adding SEO metadata and using Yoast features
   via the WordPress REST API. However, we are encountering challenges when trying
   to set the following metadata fields:
    1. Main Focus Keyword
    2. Related Synonyms
    3. Related Phrase
    4. Meta Description
    5. SEO Title
    6. Index/Table of Contents (using the Yoast “Table of Contents” block)
 * We would like to know the exact field names and data structures used by Yoast
   to programmatically add these metadata and blocks during post creation or update.
 * For example, we have tried setting `_yoast_wpseo_focuskw`, `_yoast_wpseo_metadesc`,
   and `_yoast_wpseo_title` in the `meta` field of the REST API payload, but some
   fields do not work as expected or are not saved correctly. Additionally, we are
   unable to insert the “Table of Contents” block dynamically.
 * Could you please provide us with documentation or guidance on how to:
    - Add the metadata fields mentioned above.
    - Insert the Table of Contents block programmatically.
 * Thank you for your assistance.
 * Best regards,
   Giuseppe

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Mushrit Shabnam](https://wordpress.org/support/users/611shabnam/)
 * (@611shabnam)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/api-support-for-adding-seo-metadata-and-yoast-blocks-programmatically/#post-18246841)
 * Hi [@peppe69](https://wordpress.org/support/users/peppe69/)
 * **For Meta Description, SEO Title**: you can follow the developer article from
   [here](https://developer.yoast.com/features/seo-tags/descriptions/api/) and [here](https://developer.yoast.com/features/seo-tags/titles/api/).
 * Typically code snippets are added to your theme’s functions.php file. If you’re
   unfamiliar with using code snippets, we’d like to refer you to the WordPress 
   documentation on [how to use a filter](https://developer.wordpress.org/plugins/hooks/filters/#add-filter).
 * We recommend creating regular backups of your site and database for your site’s
   health and safety. A backup is crucial before making important changes on your
   website and provides you with a safety net if something were to go wrong. Learn
   more about the [benefits of regular backups](https://yoast.com/help/how-to-backup-your-wordpress-site/).
 * **Focus keyword, Related Keyphrase and Synonyms: **
 * We don’t have API to add these.
 * The objective is to help you optimize the content using the focus keyphrase. 
   So you will edit each individual post or page, add a focus keyphrase, and then
   work on the feedback in the content analysis provided by Yoast SEO. Since the
   focus keyphrase, related keyphrase or keyphrase synonym do not output in the 
   page source, adding these through an API won’t be useful if you don’t edit the
   post itself.
 * **Table of Contents:**
 * This forum is reserved for supporting the free version of Yoast SEO. As the Table
   of Content is about a premium plugin, this thread has been marked as resolved
   per the [forum guidelines](https://wordpress.org/support/guidelines/#do-not-post-about-commercial-products).
 *  Plugin Support [Jose Varghese](https://wordpress.org/support/users/josevarghese/)
 * (@josevarghese)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/api-support-for-adding-seo-metadata-and-yoast-blocks-programmatically/#post-18255809)
 * This thread was marked resolved due to a lack of recent activity. The original
   poster can change the status to `Not Resolved` to re-open the issue or [open a new topic](https://wordpress.org/support/plugin/wordpress-seo#new-topic-0).
 * If you are not the original poster but have a similar issue, please [open a new topic](https://wordpress.org/support/plugin/wordpress-seo#new-topic-0).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘API Support for Adding SEO Metadata and Yoast Blocks Programmatically’
is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [metadata](https://wordpress.org/support/topic-tag/metadata/)

 * 2 replies
 * 3 participants
 * Last reply from: [Jose Varghese](https://wordpress.org/support/users/josevarghese/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/api-support-for-adding-seo-metadata-and-yoast-blocks-programmatically/#post-18255809)
 * Status: resolved