# Prepare custom domains

`management_groups.prepare_domains`

Configure and provision the provider and client portal hostnames together. This returns the DNS records the domain owner must add; it does not activate unverified domains. For ordinary setup, supply only base_domain so the team portal uses portal.<base_domain> and client application links use apply.<base_domain>. Supply provider_host or client_host only when the user requests different subdomains. Use mode replacement when replacing active hostnames, then refresh status before activation.

[Branding guide](https://docs.levr.ai/mcp/resources/management_group_branding.md)

Availability depends on live discovery and your access to the record. Do not infer MCP calls from REST paths.

Operation: write. Required OAuth scopes: mcp.

## Input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "domains": {
      "additionalProperties": false,
      "properties": {
        "base_domain": {
          "description": "Organization domain used for both branded addresses, such as example.com.",
          "maxLength": 255,
          "type": "string"
        },
        "client_host": {
          "description": "Optional client-application hostname. Omit it to use the recommended default apply.<base_domain>.",
          "maxLength": 255,
          "type": "string"
        },
        "mode": {
          "enum": [
            "setup",
            "replacement"
          ],
          "type": "string"
        },
        "provider_host": {
          "description": "Optional team-portal hostname. Omit it to use the recommended default portal.<base_domain>.",
          "maxLength": 255,
          "type": "string"
        }
      },
      "required": [
        "base_domain"
      ],
      "type": "object"
    },
    "expected_revision": {
      "description": "Copy branding.revision unchanged from management_groups.get_branding; not an integer draft revision.",
      "maxLength": 64,
      "minLength": 64,
      "type": "string"
    },
    "management_group_slug": {
      "description": "Copy management_group_slug from management_groups.list. Prefix: mgmt_.",
      "maxLength": 255,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "management_group_slug",
    "expected_revision",
    "domains"
  ],
  "type": "object"
}
```

## Output schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "oneOf": [
    {
      "not": {
        "required": [
          "error"
        ]
      },
      "properties": {
        "ok": {
          "const": true
        }
      },
      "required": [
        "data"
      ]
    },
    {
      "not": {
        "required": [
          "data"
        ]
      },
      "properties": {
        "ok": {
          "const": false
        }
      },
      "required": [
        "error"
      ]
    }
  ],
  "properties": {
    "data": {
      "additionalProperties": false,
      "properties": {
        "branding": {
          "additionalProperties": false,
          "properties": {
            "capabilities": {
              "type": "object"
            },
            "domains": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "activated_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "cname_target": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "dns_records": {
                    "type": [
                      "array",
                      "object",
                      "null"
                    ]
                  },
                  "host": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "last_checked_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "normalized_error_code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "normalized_error_message": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "surface": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "tls_status": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "txt_record_name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "txt_record_value": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "surface",
                  "host",
                  "status",
                  "cname_target",
                  "txt_record_name",
                  "txt_record_value",
                  "dns_records",
                  "tls_status",
                  "normalized_error_code",
                  "normalized_error_message",
                  "last_checked_at",
                  "activated_at"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "email_sender": {
              "type": "object"
            },
            "frontend_links": {
              "type": "object"
            },
            "managed_provider_count": {
              "type": "integer"
            },
            "management_group_slug": {
              "description": "Canonical mgmt_ identifier; copy the returned value unchanged.",
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "profile": {
              "type": "object"
            },
            "public_contact_email": {
              "type": "string"
            },
            "readiness": {
              "type": "object"
            },
            "recent_activity": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "event": {
                    "type": "string"
                  },
                  "occurred_at": {
                    "type": "string"
                  }
                },
                "required": [
                  "event",
                  "occurred_at"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "revision": {
              "type": "string"
            }
          },
          "required": [
            "management_group_slug",
            "name",
            "managed_provider_count",
            "revision",
            "frontend_links",
            "profile",
            "domains",
            "public_contact_email",
            "email_sender",
            "readiness",
            "capabilities"
          ],
          "type": "object"
        }
      },
      "required": [
        "branding"
      ],
      "type": "object"
    },
    "error": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "details": {
          "additionalProperties": true,
          "description": "Optional bounded, agent-safe correction or recovery facts.",
          "type": "object"
        },
        "message": {
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        }
      },
      "required": [
        "code",
        "message",
        "retryable"
      ],
      "type": "object"
    },
    "meta": {
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "type": "string"
        }
      },
      "required": [
        "request_id"
      ],
      "type": "object"
    },
    "ok": {
      "description": "Whether the tool completed successfully.",
      "type": "boolean"
    }
  },
  "required": [
    "ok",
    "meta"
  ],
  "type": "object"
}
```

Check the result, then read the affected record to confirm your change.
