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

# Update Website

> Sets, replaces, or clears the partner `external_id` mapped to a website. **Partner integrations only:** pass `external_id` as a non-empty string to set or replace the mapping, or as `null` to clear it. Requires a global API key. Works on deleted websites too, because deleting a website does not release its `external_id`. An `external_id` already mapped to another website in your organization returns `409` naming the current holder; to move an id from one website to another, clear it on the current holder first, then set it on the new one.



## OpenAPI

````yaml /api-reference/openapi.json patch /api/v1/websites/{website_id}
openapi: 3.1.0
info:
  title: AthenaHQ API
  description: >-
    AthenaHQ API provides programmatic access to manage your websites and
    prompts for AI-powered content optimization.
  version: 1.0.0
  contact:
    email: support@athenahq.ai
servers:
  - url: https://api.athenahq.ai
    description: Production server
security:
  - apiKey: []
tags:
  - name: Basics
    description: Core API operations for managing websites and prompts
  - name: Metrics
    description: Metrics and analytics endpoints for tracking AI visibility
  - name: Billing
    description: Billing and credits endpoints for managing usage
  - name: Team Management
    description: Endpoints for managing team members and invitations
  - name: Groups
    description: Endpoints for managing groups of websites
  - name: Content
    description: >-
      Endpoints for accessing Content Hub data — tabs, tracked URLs, and per-URL
      prompt breakdowns.
  - name: Pitch Workspace
    description: >-
      Endpoints for accessing pitch workspace reports — org-scoped pitch runs
      with competitors, prompts, attributes, and aggregate metrics.
  - name: Knowledge Base
    description: >-
      Endpoints for reading the brand Knowledge Base — approved brand facts and
      the pillars that organize them.
paths:
  /api/v1/websites/{website_id}:
    parameters:
      - name: website_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: The unique identifier of the website
        example: 123e4567-e89b-12d3-a456-426614174000
    patch:
      tags:
        - Basics
      summary: Update Website
      description: >-
        Sets, replaces, or clears the partner `external_id` mapped to a website.
        **Partner integrations only:** pass `external_id` as a non-empty string
        to set or replace the mapping, or as `null` to clear it. Requires a
        global API key. Works on deleted websites too, because deleting a
        website does not release its `external_id`. An `external_id` already
        mapped to another website in your organization returns `409` naming the
        current holder; to move an id from one website to another, clear it on
        the current holder first, then set it on the new one.
      operationId: updateWebsite
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateWebsiteRequest'
      responses:
        '200':
          description: >-
            Mapping updated. `externalId` is always present on this response:
            the new value, or `null` after a clear. Like the `external_id`
            lookup responses, and unlike the `GET /api/v1/websites` listing,
            this endpoint does not return `baseCountry`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - website
                properties:
                  website:
                    type: object
                    required:
                      - id
                      - websiteName
                      - websiteUrl
                      - onboardingStep
                      - externalId
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: Unique identifier for the website
                        example: 123e4567-e89b-12d3-a456-426614174000
                      websiteName:
                        type: string
                        description: Display name of the website
                        example: My Awesome Blog
                      websiteUrl:
                        type: string
                        description: The domain of the website (without protocol)
                        example: example.com
                      onboardingStep:
                        type: integer
                        nullable: true
                        description: >-
                          Current onboarding step for the website. Null
                          indicates onboarding is complete.
                        example: null
                      externalId:
                        type: string
                        nullable: true
                        description: >-
                          The partner-supplied identifier now mapped to this
                          website, or `null` when the request cleared the
                          mapping.
                        example: ws_a7f3b2c9
        '400':
          description: Bad request - Validation error or invalid website ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_external_id:
                  summary: external_id was not sent
                  value:
                    error: '''external_id'' is required'
                invalid_website_id:
                  summary: Website id is not a UUID
                  value:
                    error: Invalid website ID format
                invalid_json:
                  summary: Body is not valid JSON
                  value:
                    error: Invalid JSON body
                unrecognized_field:
                  summary: Unknown keys are rejected rather than ignored
                  value:
                    error: 'Unrecognized key: "externalId"'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Forbidden - Requires a global API key, and the key must belong to an
            organization flagged as a partner.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                global_required:
                  summary: Global API key required
                  value:
                    error: 'Forbidden: global API key required'
                partner_required:
                  summary: Partner API key required for external_id
                  value:
                    error: 'Forbidden: partner API key required'
        '404':
          description: >-
            Not found - Website does not exist or does not belong to your
            organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Website not found
        '409':
          description: >-
            Conflict - the supplied `external_id` is already mapped to another
            website in your organization. Clear it on that website first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExternalIdConflictError'
              examples:
                external_id_conflict:
                  summary: Partner external_id already mapped
                  value:
                    error: external_id_conflict
                    message: external_id ws_a7f3b2c9 is already mapped to a website
                    existing:
                      id: 123e4567-e89b-12d3-a456-426614174000
                      externalId: ws_a7f3b2c9
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
components:
  schemas:
    UpdateWebsiteRequest:
      type: object
      additionalProperties: false
      description: >-
        Request body for updating a website. `external_id` is required; unknown
        fields are rejected with `400`.
      required:
        - external_id
      properties:
        external_id:
          type: string
          minLength: 1
          maxLength: 255
          nullable: true
          description: >-
            **Partner-only.** Partner-supplied identifier to attach to this
            website. Pass a non-empty string to set or replace the mapping, or
            `null` to clear an existing mapping. Surrounding whitespace is
            trimmed; a blank value or one longer than 255 characters returns
            `400`. Accepted only when authenticating with an API key for an
            organization flagged as a partner. Sending this field as a direct
            customer returns `403 Forbidden`. Must be unique per resource type
            within your organization: setting a value already used by another
            website returns `409` with the existing website in the payload.
          example: ws_a7f3b2c9
    Error:
      type: object
      description: Error response object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message describing what went wrong
          example: Unauthorized
    ExternalIdConflictError:
      type: object
      description: >-
        Returned when a partner tries to set an `external_id` that is already
        mapped to another resource of the same type within the organization. The
        `existing` field identifies the resource that currently holds the ID,
        letting the partner recover from a retry or reconcile their mapping.
      required:
        - error
        - message
        - existing
      properties:
        error:
          type: string
          enum:
            - external_id_conflict
          description: Machine-readable error code. Always `external_id_conflict`.
          example: external_id_conflict
        message:
          type: string
          description: Human-readable explanation of the conflict.
          example: external_id ws_a7f3b2c9 is already mapped to a website
        existing:
          type: object
          required:
            - id
            - externalId
          description: The resource that currently holds the conflicting `external_id`.
          properties:
            id:
              type: string
              format: uuid
              description: Athena ID of the existing resource.
              example: 123e4567-e89b-12d3-a456-426614174000
            externalId:
              type: string
              description: The external_id that is already mapped.
              example: ws_a7f3b2c9
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. You can create one
        [here](https://app.athenahq.ai/organization?tab=api).

````