Skip to content

Add wp.com POST /sites/<site_id>/domains/primary endpoint#1392

Open
oguzkocer wants to merge 2 commits into
trunkfrom
add/wpcom-set-primary-domain-endpoint
Open

Add wp.com POST /sites/<site_id>/domains/primary endpoint#1392
oguzkocer wants to merge 2 commits into
trunkfrom
add/wpcom-set-primary-domain-endpoint

Conversation

@oguzkocer

Copy link
Copy Markdown
Contributor

Description

Adds the POST /rest/v1.1/sites/<site_id>/domains/primary/ endpoint for setting a site's primary domain. The request body carries a single domain field, and the response is { "success": bool }. Used after a successful domain registration to designate the newly registered domain as the site's primary.

Changes

  • New SetPrimaryDomainParams (request body, single domain: DomainName field) and SetPrimaryDomainResponse (success: bool) types in domains.rs
  • New SetPrimary POST variant on the DomainsRequest enum, served from the RestV1.1 namespace
  • Idempotent domains::set_primary e2e test: reads the site's current primary domain via site_domains and sets it again, so the endpoint is exercised against the live test site without changing its effective primary domain

Changelog

  • I've added an entry to CHANGELOG.md under ## [Unreleased], using the Keep a Changelog categories (Added, Changed, Deprecated, Removed, Fixed, Security). Prefix breaking changes with **BREAKING:**.

Adds an endpoint for setting a site's primary domain. The request body
carries a single `domain` field and the response is `{ "success": bool }`.

- `SetPrimaryDomainParams` / `SetPrimaryDomainResponse` types in `domains.rs`
- `SetPrimary` `POST` variant on `DomainsRequest` (`RestV1.1`) + URL unit test
- Idempotent `domains::set_primary` e2e test that reads the current primary
  domain and sets it again, exercising the endpoint without mutating the
  test site's effective primary
- Changelog entry and checklist update
@wpmobilebot

Copy link
Copy Markdown
Collaborator

XCFramework Build

This PR's XCFramework is available for testing. Add to your Package.swift:

.package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1392")

Built from 5f2a563

@oguzkocer oguzkocer marked this pull request as ready for review June 15, 2026 11:01
@oguzkocer oguzkocer requested a review from crazytonyli June 15, 2026 11:01
#[derive(Debug, Clone, Serialize, Deserialize, uniffi::Record)]
pub struct SetPrimaryDomainResponse {
/// Whether the primary domain was set successfully.
pub success: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if success is false? I remember some WP.com API would return error message and code in the response. Not sure about this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants