# Update a custom hostname

Partially updates a custom hostname by replacing the defaultSiteId, defaultContextId, or both, as needed.

The hostname itself cannot be updated after the custom hostname has been created and registered. As a workaround, you must delete the existing custom hostname and create a new one to change the hostname.

Endpoint: PATCH /api/admin/v1/hostnames/{hostname}
Version: 1.0
Security: BearerAuth

## Path parameters:

  - `hostname` (string, required)
    The specific custom hostname you want to interact with.
    Example: "sitecore-api-preview.example.com"

## Request fields (application/json):

  - `defaultSiteId` (string)
    The default [site ID](https://doc.sitecore.com/xmc/en/developers/xm-cloud/get-the-environment-variables-for-a-site.html) associated with the custom hostname.

If you don't specify a value for defaultSiteId, you'll need to manually include it in the query parameter or body with each request to the custom hostname to ensure it is [resolved correctly](https://doc.sitecore.com/portal/en/developers/sitecore-cloud-portal/resolving-a-custom-hostname-during-a-request.html).
    Example: "playsummit"

  - `defaultContextId` (string)
    The default [context ID](https://doc.sitecore.com/xmc/en/developers/xm-cloud/the-context-id-environment-variable.html) associated with the custom hostname.

If you don't specify a value for defaultContextId, you'll need to manually include it in the query parameter or header with each request to the custom hostname to ensure it is [resolved correctly](https://doc.sitecore.com/portal/en/developers/sitecore-cloud-portal/resolving-a-custom-hostname-during-a-request.html).
    Example: "3BTl4aU7w12A5M76m9p8IA"

## Response 202 fields (application/json):

  - `defaultSiteId` (string)
    The default [site ID](https://doc.sitecore.com/xmc/en/developers/xm-cloud/get-the-environment-variables-for-a-site.html) associated with the custom hostname.

If you don't specify a value for defaultSiteId, you'll need to manually include it in the query parameter or body with each request to the custom hostname to ensure it is [resolved correctly](https://doc.sitecore.com/portal/en/developers/sitecore-cloud-portal/resolving-a-custom-hostname-during-a-request.html).
    Example: "playsummit"

  - `defaultContextId` (string)
    The default [context ID](https://doc.sitecore.com/xmc/en/developers/xm-cloud/the-context-id-environment-variable.html) associated with the custom hostname.

If you don't specify a value for defaultContextId, you'll need to manually include it in the query parameter or header with each request to the custom hostname to ensure it is [resolved correctly](https://doc.sitecore.com/portal/en/developers/sitecore-cloud-portal/resolving-a-custom-hostname-during-a-request.html).
    Example: "3BTl4aU7w12A5M76m9p8IA"

## Response 400 fields (application/json):

  - `status` (integer, required)
    The HTTP response status code.
    Example: 400

  - `title` (string, required)
    The error description.
    Example: "BAD REQUEST"

  - `detail` (string, required)
    The error details.
    Example: "URL format is invalid"

  - `type` (string, required)
    URL to get more information about the error.
    Example: "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1"

  - `instance` (string, required)
    The instance where the error was encountered.
    Example: "https://edge-platform-admin-api.sitecorecloud.io/api/admin/v1/hostnames/example.com"

## Response 401 fields (application/json):

  - `status` (integer, required)
    The HTTP response status code.
    Example: 401

  - `title` (string, required)
    The error description.
    Example: "UNAUTHORIZED"

  - `detail` (string, required)
    The error details.
    Example: "Authentication credentials are required to access the resource. All requests must be authenticated."

  - `type` (string, required)
    URL to get more information about the error.
    Example: "https://datatracker.ietf.org/doc/html/rfc7235#section-3.1"

  - `instance` (string, required)
    The instance where the error was encountered.
    Example: "https://edge-platform-admin-api.sitecorecloud.io/api/admin/v1/hostnames/example.com"

## Response 403 fields (application/json):

  - `status` (integer, required)
    The HTTP response status code.
    Example: 403

  - `title` (string, required)
    The error description.
    Example: "FORBIDDEN"

  - `detail` (string, required)
    The error details.
    Example: "No access to the requested resource"

  - `type` (string, required)
    URL to get more information about the error.
    Example: "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3"

  - `instance` (string, required)
    The instance where the error was encountered.
    Example: "https://edge-platform-admin-api.sitecorecloud.io/api/admin/v1/hostnames/example.com"

## Response 404 fields (application/json):

  - `status` (integer, required)
    The HTTP response status code.
    Example: 404

  - `title` (string, required)
    The error description.
    Example: "RESOURCE NOT FOUND"

  - `detail` (string, required)
    The error details.
    Example: "The specified resource does not exist."

  - `type` (string, required)
    URL to get more information about the error.
    Example: "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4"

  - `instance` (string, required)
    The instance where the error was encountered.
    Example: "https://edge-platform-admin-api.sitecorecloud.io/api/admin/v1/hostnames/example.com"

## Response 500 fields (application/json):

  - `status` (integer, required)
    The HTTP response status code.
    Example: 500

  - `title` (string, required)
    The error description.
    Example: "INTERNAL SERVER ERROR"

  - `detail` (string, required)
    The error details.
    Example: "The server was unable to complete your request. Please try again later."

  - `type` (string, required)
    URL to get more information about the error.
    Example: "https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1"

  - `instance` (string, required)
    The instance where the error was encountered.
    Example: "https://edge-platform-admin-api.sitecorecloud.io/api/admin/v1/hostnames/example.com"


