> ## Documentation Index
> Fetch the complete documentation index at: https://developers.octaviatech.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimize an article for SEO and save the result

> Optimizes each target language of the article and persists the patched fields plus the recomputed `seo.perLanguage` metrics. When `languages` is omitted, every language present on the article is optimized. `title`, `summary` and `content` default to true; `tags` defaults to false.



## OpenAPI

````yaml /api-reference/ai-cms/openapi.json post /ai/optimizeArticle
openapi: 3.1.0
info:
  title: Blog API
  version: 1.0.0
servers:
  - url: https://api.octaviatech.app/cms
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Tags
    description: Tag management endpoints
paths:
  /ai/optimizeArticle:
    post:
      tags:
        - AI
      summary: Optimize an article for SEO and save the result
      description: >-
        Optimizes each target language of the article and persists the patched
        fields plus the recomputed `seo.perLanguage` metrics. When `languages`
        is omitted, every language present on the article is optimized. `title`,
        `summary` and `content` default to true; `tags` defaults to false.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - articleId
              properties:
                articleId:
                  type: string
                  example: '{{objectId}}'
                primaryKeyword:
                  type: string
                  description: >-
                    Keyword to target; falls back to the article's stored
                    per-language primary keyword
                  example: intermittent fasting
                languages:
                  type: array
                  items:
                    type: string
                  description: >-
                    Language codes to optimize. Ignored codes that the article
                    does not have. Defaults to all available languages.
                  example:
                    - en
                    - es
                fields:
                  type: object
                  additionalProperties: false
                  description: Per-field opt-in. Unspecified fields keep their defaults.
                  properties:
                    title:
                      type: boolean
                      default: true
                    summary:
                      type: boolean
                      default: true
                    content:
                      type: boolean
                      default: true
                    tags:
                      type: boolean
                      default: false
            examples:
              Basic:
                value:
                  articleId: '{{objectId}}'
                  primaryKeyword: intermittent fasting
                  languages:
                    - en
                  fields:
                    title: true
                    content: true
      responses:
        '200':
          description: OK (optimized and saved)
          content:
            application/json:
              example:
                success: true
                statusCode: 200
                message: AI SEO optimization generated and saved successfully
                data:
                  articleId: '{{objectId}}'
                  patched:
                    en:
                      title: …
                      summary: …
                      contentHtml: <p>…</p>
                      tags:
                        - fasting
                  seo:
                    before:
                      en:
                        score: 62
                    after:
                      en:
                        score: 91
                  saved: true
        '400':
          description: articleId missing
        '401':
          description: Unauthorized
        '403':
          description: Forbidden (role not allowed)
        '404':
          description: Article not found
        '406':
          description: No languages available to optimize for this article
        '426':
          description: Upgrade required (ai_tokens limit exceeded)
        '500':
          description: Failed to optimize article SEO
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````